Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
seuros committed Apr 18, 2014
1 parent 1393443 commit 68eddd1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions spec/acts_as_taggable_on/taggable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
context 'should be able to create and find tags in languages without capitalization :' do
ActsAsTaggableOn.strict_case_match = false
{
japanese: {name: 'Chihiro', tag_list: '日本の'},
japanese: {name: 'Chihiro', tag_list: '日本の'},
hebrew: {name: 'Salim', tag_list: 'עברית'},
chinese: {name: 'Ieie', tag_list: '中国的'},
arabic: {name: 'Yasser', tag_list: 'العربية'},
Expand Down Expand Up @@ -715,36 +715,37 @@
context 'tag_counts and aggreating scopes, compatability with MySQL ' do
before(:each) do
clean_database!
TaggableModel.new(:name => "Barb Jones").tap{|t| t.tag_list = ['awesome', 'fun'] }.save
TaggableModel.new(:name => "John Doe").tap{|t| t.tag_list = ['cool', 'fun', 'hella'] }.save
TaggableModel.new(:name => "Jo Doe").tap{|t| t.tag_list = ['curious', 'young', 'naive', 'sharp'] }.save
TaggableModel.new(:name => 'Barb Jones').tap { |t| t.tag_list = %w(awesome fun) }.save
TaggableModel.new(:name => 'John Doe').tap { |t| t.tag_list = %w(cool fun hella) }.save
TaggableModel.new(:name => 'Jo Doe').tap { |t| t.tag_list = %w(curious young naive sharp) }.save

TaggableModel.all.each{|t| t.save }
TaggableModel.all.each { |t| t.save }
end

context 'Model.limit(x).tag_counts.sum(:tags_count)' do
it 'should not break on Mysql' do
expect( TaggableModel.limit(2).tag_counts.sum('tags_count') ).to eq 5
# Activerecord 3.2 return a string
expect(TaggableModel.limit(2).tag_counts.sum('tags_count').to_i).to eq(5)
end
end

context 'regression prevention, just making sure these esoteric queries still work' do
context 'Model.tag_counts.limit(x)' do
it 'should limit the tag objects (not very useful, of course)' do
array_of_tag_counts = TaggableModel.tag_counts.limit(2)
expect(array_of_tag_counts.count).to eq 2
expect(array_of_tag_counts.count).to eq(2)
end
end

context 'Model.tag_counts.sum(:tags_count)' do
it 'should limit the total tags used' do
expect( TaggableModel.tag_counts.sum(:tags_count) ).to eq 9
expect(TaggableModel.tag_counts.sum(:tags_count).to_i).to eq(9)
end
end

context 'Model.tag_counts.limit(2).sum(:tags_count)' do
it 'limit should have no effect; this is just a sanity check' do
expect( TaggableModel.tag_counts.limit(2).sum(:tags_count) ).to eq 9
expect(TaggableModel.tag_counts.limit(2).sum(:tags_count).to_i).to eq(9)
end
end
end
Expand Down

0 comments on commit 68eddd1

Please sign in to comment.