Skip to content

Commit

Permalink
Add specs for owner_tags_on and owner_tags methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brilyuhns committed Aug 7, 2016
1 parent 17ae122 commit 65669df
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion spec/acts_as_taggable_on/single_table_inheritance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,27 @@
expect(taggable.tags_from(student)).to eq(%w(ruby scheme))
end

it 'returns all owner tags on the taggable' do
student.tag(taggable, with: 'ruby, scheme', on: :tags)
student.tag(taggable, with: 'skill_one', on: :skills)
student.tag(taggable, with: 'english, spanish', on: :language)
expect(taggable.owner_tags(student).count).to eq(5)
expect(taggable.owner_tags(student).sort == %w(english ruby scheme skill_one spanish))
end


it 'returns owner tags on the tagger' do
student.tag(taggable, with: 'ruby, scheme', on: :tags)
expect(taggable.owner_tags_on(student, :tags).count).to eq(2)
end

it 'returns owner tags on the taggable for an array of contexts' do
student.tag(taggable, with: 'ruby, scheme', on: :tags)
student.tag(taggable, with: 'skill_one, skill_two', on: :skills)
expect(taggable.owner_tags_on(student, [:tags, :skills]).count).to eq(4)
expect(taggable.owner_tags_on(student, [:tags, :skills]).sort == %w(ruby scheme skill_one skill_two))
end

it 'should scope objects returned by tagged_with by owners' do
student.tag(taggable, with: 'ruby, scheme', on: :tags)
expect(TaggableModel.tagged_with(%w(ruby scheme), owned_by: student).count).to eq(1)
Expand Down Expand Up @@ -208,4 +224,3 @@
end
end
end

0 comments on commit 65669df

Please sign in to comment.