take acts-as-taggable-on gem from git, solve tag case-sensitivity

This commit is contained in:
Florian Staudacher 2012-05-21 16:35:36 +02:00
parent 4819850c92
commit d815cf5d82
7 changed files with 43 additions and 8 deletions

View file

@ -92,7 +92,7 @@ gem 'SystemTimer', '1.2.3', :platforms => :ruby_18
# tags
gem 'acts-as-taggable-on', '~> 2.2.2'
gem 'acts-as-taggable-on', :git => "git://github.com/mbleigh/acts-as-taggable-on.git"
# URIs and HTTP

View file

@ -13,6 +13,13 @@ GIT
specs:
settingslogic (2.0.8)
GIT
remote: git://github.com/mbleigh/acts-as-taggable-on.git
revision: 4690e041e59114ad1d42efaa463462140a703dba
specs:
acts-as-taggable-on (2.2.2)
rails (~> 3.0)
GIT
remote: git://github.com/pivotal/jasmine-gem.git
revision: 1e075fbf5a69812fcc914c453f002ecf5bed38ab
@ -57,8 +64,6 @@ GEM
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
acts-as-taggable-on (2.2.2)
rails (~> 3.0)
acts_as_api (0.4)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
@ -462,7 +467,7 @@ PLATFORMS
DEPENDENCIES
SystemTimer (= 1.2.3)
activerecord-import (~> 0.2.9)
acts-as-taggable-on (~> 2.2.2)
acts-as-taggable-on!
acts_as_api
addressable (~> 2.2)
airbrake

View file

@ -0,0 +1,3 @@
ActsAsTaggableOn.force_lowercase = true

View file

@ -12,7 +12,7 @@ class Stream::Tag < Stream::Base
end
def tag
@tag ||= ActsAsTaggableOn::Tag.find_by_name(tag_name)
@tag ||= ActsAsTaggableOn::Tag.named(tag_name).first
end
def tag_follow_count

View file

@ -72,6 +72,19 @@ describe Stream::Tag do
end
end
describe 'case insensitivity' do
before do
@post_lc = alice.post(:status_message, :text => '#newhere', :public => true, :to => 'all')
@post_uc = alice.post(:status_message, :text => '#NewHere', :public => true, :to => 'all')
@post_cp = alice.post(:status_message, :text => '#NEWHERE', :public => true, :to => 'all')
end
it 'returns posts regardless of the tag case' do
stream = Stream::Tag.new(nil, "newhere")
stream.posts.should == [@post_lc, @post_uc, @post_cp]
end
end
describe 'shared behaviors' do
before do
@stream = Stream::Tag.new(Factory(:user), "test")

View file

@ -259,6 +259,20 @@ STR
@object = Factory.build(:status_message)
end
it_should_behave_like 'it is taggable'
it 'associates different-case tags to the same tag entry' do
assert_equal ActsAsTaggableOn.force_lowercase, true
msg_lc = Factory.build(:status_message, :text => '#newhere')
msg_uc = Factory.build(:status_message, :text => '#NewHere')
msg_cp = Factory.build(:status_message, :text => '#NEWHERE')
msg_lc.save; msg_uc.save; msg_cp.save
tag_array = msg_lc.tags
msg_uc.tags.should == tag_array
msg_cp.tags.should == tag_array
end
end
describe "XML" do