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
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
11
Gemfile.lock
11
Gemfile.lock
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ class TagFollowing < ActiveRecord::Base
|
|||
belongs_to :tag, :class_name => "ActsAsTaggableOn::Tag"
|
||||
|
||||
validates_uniqueness_of :tag_id, :scope => :user_id
|
||||
|
||||
|
||||
def self.user_is_following?(user, tagname)
|
||||
tagname.nil? ? false : joins(:tag).where(:tags => {:name => tagname.downcase}, :user_id => user.id).exists?
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
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
|
||||
|
||||
def tag
|
||||
@tag ||= ActsAsTaggableOn::Tag.find_by_name(tag_name)
|
||||
@tag ||= ActsAsTaggableOn::Tag.named(tag_name).first
|
||||
end
|
||||
|
||||
def tag_follow_count
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
@ -90,7 +103,7 @@ describe Stream::Tag do
|
|||
stream.tag_name.should == 'what'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#publisher" do
|
||||
it 'creates a publisher with the tag prefill' do
|
||||
Publisher.should_receive(:new).with(anything(), anything)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue