take acts-as-taggable-on gem from git, solve tag case-sensitivity
This commit is contained in:
parent
4819850c92
commit
d815cf5d82
7 changed files with 43 additions and 8 deletions
2
Gemfile
2
Gemfile
|
|
@ -92,7 +92,7 @@ gem 'SystemTimer', '1.2.3', :platforms => :ruby_18
|
||||||
|
|
||||||
# tags
|
# 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
|
# URIs and HTTP
|
||||||
|
|
||||||
|
|
|
||||||
11
Gemfile.lock
11
Gemfile.lock
|
|
@ -13,6 +13,13 @@ GIT
|
||||||
specs:
|
specs:
|
||||||
settingslogic (2.0.8)
|
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
|
GIT
|
||||||
remote: git://github.com/pivotal/jasmine-gem.git
|
remote: git://github.com/pivotal/jasmine-gem.git
|
||||||
revision: 1e075fbf5a69812fcc914c453f002ecf5bed38ab
|
revision: 1e075fbf5a69812fcc914c453f002ecf5bed38ab
|
||||||
|
|
@ -57,8 +64,6 @@ GEM
|
||||||
activesupport (3.2.2)
|
activesupport (3.2.2)
|
||||||
i18n (~> 0.6)
|
i18n (~> 0.6)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
acts-as-taggable-on (2.2.2)
|
|
||||||
rails (~> 3.0)
|
|
||||||
acts_as_api (0.4)
|
acts_as_api (0.4)
|
||||||
activemodel (>= 3.0.0)
|
activemodel (>= 3.0.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
|
@ -462,7 +467,7 @@ PLATFORMS
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
SystemTimer (= 1.2.3)
|
SystemTimer (= 1.2.3)
|
||||||
activerecord-import (~> 0.2.9)
|
activerecord-import (~> 0.2.9)
|
||||||
acts-as-taggable-on (~> 2.2.2)
|
acts-as-taggable-on!
|
||||||
acts_as_api
|
acts_as_api
|
||||||
addressable (~> 2.2)
|
addressable (~> 2.2)
|
||||||
airbrake
|
airbrake
|
||||||
|
|
|
||||||
3
config/initializers/acts_as_taggable_on.rb
Normal file
3
config/initializers/acts_as_taggable_on.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
ActsAsTaggableOn.force_lowercase = true
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ class Stream::Tag < Stream::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag
|
def tag
|
||||||
@tag ||= ActsAsTaggableOn::Tag.find_by_name(tag_name)
|
@tag ||= ActsAsTaggableOn::Tag.named(tag_name).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_follow_count
|
def tag_follow_count
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,19 @@ describe Stream::Tag do
|
||||||
end
|
end
|
||||||
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
|
describe 'shared behaviors' do
|
||||||
before do
|
before do
|
||||||
@stream = Stream::Tag.new(Factory(:user), "test")
|
@stream = Stream::Tag.new(Factory(:user), "test")
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,20 @@ STR
|
||||||
@object = Factory.build(:status_message)
|
@object = Factory.build(:status_message)
|
||||||
end
|
end
|
||||||
it_should_behave_like 'it is taggable'
|
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
|
end
|
||||||
|
|
||||||
describe "XML" do
|
describe "XML" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue