fix issue #315: Duplicate handle error on multilingual sites
did
committed Aug 29, 2016
commit 73ef3493eea8cc74974d16e1b91af36e15ba637b
Showing 3
changed files with
17 additions
and 5 deletions
locomotive/wagon/commands/push_sub_commands/push_pages_command.rb b/lib/locomotive/wagon/commands/push_sub_commands/push_pages_command.rb
+5
-2
| @@ | @@ -49,7 +49,10 @@ module Locomotive::Wagon |
| end | |
| def can_update?(local_entity) | |
| - | if local_entity.handle && id = remote_entity_id_from_handle(local_entity) |
| + | # checking pathes only if the current locale is the default one |
| + | if local_entity.__locale__.to_s == default_locale.to_s && |
| + | local_entity.handle && |
| + | id = remote_entity_id_from_handle(local_entity) |
| remote_entity_folder_path(id) == local_entity.folder_path | |
| else | |
| true | |
| @@ | @@ -79,7 +82,7 @@ module Locomotive::Wagon |
| @remote_entities = {}.tap do |hash| | |
| api_client.pages.fullpaths(default_locale).each do |entity| | |
| - | hash[entity.fullpath] = entity._id |
| + | hash[entity.fullpath] = entity._id |
| if entity.respond_to?(:handle) && entity.handle.present? | |
| # to_sym: trick to not have conflicts with fullpaths | |
locomotive/wagon/decorators/page_decorator.rb b/lib/locomotive/wagon/decorators/page_decorator.rb
+2
-2
| @@ | @@ -8,10 +8,10 @@ module Locomotive |
| attr_accessor :__content_assets_pusher__, :__persist_content__ | |
| - | def initialize(object, locale = nil, content_assets_pusher, persist_content) |
| + | def initialize(object, locale, content_assets_pusher, persist_content) |
| self.__content_assets_pusher__ = content_assets_pusher | |
| self.__persist_content__ = persist_content | |
| - | super(object, locale, nil) |
| + | super(object, locale, nil) # we don't need a fallback to the default locale |
| end | |
| def __attributes__ | |
spec/unit/commands/push_sub_commands/push_pages_command_spec.rb
+10
-1
| @@ | @@ -86,7 +86,8 @@ describe Locomotive::Wagon::PushPagesCommand do |
| let(:handle) { nil } | |
| let(:folder) { '' } | |
| - | let(:page) { instance_double('Page', fullpath: 'modified-about-us', folder_path: folder, handle: handle) } |
| + | let(:locale) { :en } |
| + | let(:page) { instance_double('Page', fullpath: 'modified-about-us', folder_path: folder, handle: handle, __locale__: locale, __default_locale__: :en) } |
| subject { command.send(:can_update?, page) } | |
| @@ | @@ -111,6 +112,14 @@ describe Locomotive::Wagon::PushPagesCommand do |
| end | |
| + | context 'another locale' do |
| + | |
| + | let(:locale) { :fr } |
| + | |
| + | it { is_expected.to eq true } |
| + | |
| + | end |
| + | |
| end | |
| end | |