Skip to content

Commit

Permalink
Merge pull request #585 from konukhov/ordered_taggable_ownership_bug_fix
Browse files Browse the repository at this point in the history
fix owned ordered taggable bug
  • Loading branch information
seuros committed Sep 1, 2014
2 parents 19826a3 + f092ea5 commit e30d15f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/acts_as_taggable_on/taggable/ownership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def save_owned_tags
tags = find_or_create_tags_from_list_with_context(tag_list.uniq, context)

# Tag objects for owned tags
owned_tags = owner_tags_on(owner, context)
owned_tags = owner_tags_on(owner, context).to_a

# Tag maintenance based on whether preserving the created order of tags
if self.class.preserve_tag_order?
Expand Down
13 changes: 13 additions & 0 deletions spec/acts_as_taggable_on/tagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,17 @@
}).to_not change(ActsAsTaggableOn::Tagging, :count)
end

it 'should change tags order in ordered taggable' do
@ordered_taggable = OrderedTaggableModel.create name: 'hey!'

@user.tag @ordered_taggable, with: 'tag, tag1', on: :tags
expect(@ordered_taggable.reload.tags_from(@user)).to eq(['tag', 'tag1'])

@user.tag @ordered_taggable, with: 'tag2, tag1', on: :tags
expect(@ordered_taggable.reload.tags_from(@user)).to eq(['tag2', 'tag1'])

@user.tag @ordered_taggable, with: 'tag1, tag2', on: :tags
expect(@ordered_taggable.reload.tags_from(@user)).to eq(['tag1', 'tag2'])
end

end

0 comments on commit e30d15f

Please sign in to comment.