diff options
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | Gemfile.lock | 11 | ||||
-rw-r--r-- | app/models/tag_following.rb | 4 | ||||
-rw-r--r-- | config/initializers/acts_as_taggable_on.rb | 3 | ||||
-rw-r--r-- | lib/stream/tag.rb | 2 | ||||
-rw-r--r-- | spec/lib/stream/tag_spec.rb | 15 | ||||
-rw-r--r-- | spec/models/status_message_spec.rb | 14 |
7 files changed, 43 insertions, 8 deletions
@@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 10bca9dde..d1fcd4009 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,13 @@ GIT 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 specs: @@ -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 diff --git a/app/models/tag_following.rb b/app/models/tag_following.rb index 8705f185f..b47fbb973 100644 --- a/app/models/tag_following.rb +++ b/app/models/tag_following.rb @@ -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 diff --git a/config/initializers/acts_as_taggable_on.rb b/config/initializers/acts_as_taggable_on.rb new file mode 100644 index 000000000..1160cfafd --- /dev/null +++ b/config/initializers/acts_as_taggable_on.rb @@ -0,0 +1,3 @@ + +ActsAsTaggableOn.force_lowercase = true + diff --git a/lib/stream/tag.rb b/lib/stream/tag.rb index 0c96e0a23..db6551db0 100644 --- a/lib/stream/tag.rb +++ b/lib/stream/tag.rb @@ -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 diff --git a/spec/lib/stream/tag_spec.rb b/spec/lib/stream/tag_spec.rb index e7f71001a..978104e5d 100644 --- a/spec/lib/stream/tag_spec.rb +++ b/spec/lib/stream/tag_spec.rb @@ -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) diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 02370e3d7..50293c818 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -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 |