Merge pull request #2580 from robhogg/2565_nsfw_regex

"#nsfw tag filter appears to be case-sensitive"
This commit is contained in:
Jonne Hass 2012-01-02 14:26:16 -08:00
commit 7841d02edd
2 changed files with 13 additions and 1 deletions

View file

@ -68,7 +68,7 @@ class StatusMessage < Post
end
def nsfw?
self.raw_message.include?('#nsfw')
self.raw_message.match(/#nsfw/i)
end
def formatted_message(opts={})

View file

@ -226,6 +226,18 @@ STR
end
end
describe "#nsfw?" do
it 'returns MatchObject (true) if the post contains #nsfw (however capitalised)' do
status = Factory(:status_message, :text => "This message is #nSFw")
status.nsfw?.should be_true
end
it 'returns nil (false) if the post does not contain #nsfw' do
status = Factory(:status_message, :text => "This message is #sFW")
status.nsfw?.should be_false
end
end
describe "#notify_person" do
it 'notifies the person mentioned' do
Notification.should_receive(:notify).with(alice, anything, anything)