From be835785f856bc4a7b946b7b52d8ddc639693f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= <regis@hanol.fr> Date: Thu, 12 Dec 2013 15:05:18 +0100 Subject: [PATCH] FIX: allow new user to post emojis --- app/models/post.rb | 2 +- spec/models/post_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index 6b0692e47..e36ec68fc 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -111,7 +111,7 @@ class Post < ActiveRecord::Base end def self.white_listed_image_classes - @white_listed_image_classes ||= ['avatar', 'favicon', 'thumbnail'] + @white_listed_image_classes ||= ['avatar', 'favicon', 'thumbnail', 'emoji'] end def post_analyzer diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index c7e259d0f..cab31474a 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -125,6 +125,7 @@ describe Post do let(:post_with_favicon) { post_with_body('<img src="/assets/favicons/wikipedia.png" class="favicon">', newuser) } let(:post_with_thumbnail) { post_with_body('<img src="/assets/emoji/smiley.png" class="thumbnail">', newuser) } let(:post_with_two_classy_images) { post_with_body("<img src='http://discourse.org/logo.png' class='classy'> <img src='http://bbc.co.uk/sherlock.jpg' class='classy'>", newuser) } + let(:post_with_emojis) { post_with_body("<img src='/plugins/emoji/images/smile.png' title=':smile:' class='emoji' alt='smile'><img src='/plugins/emoji/images/wink.png' title=':wink:' class='emoji' alt='wink'>", newuser) } it "returns 0 images for an empty post" do Fabricate.build(:post).image_count.should == 0 @@ -150,6 +151,10 @@ describe Post do post_with_thumbnail.image_count.should == 0 end + it "doesn't count emojies as images" do + post_with_emojis.image_count.should == 0 + end + it "doesn't count whitelisted images" do Post.stubs(:white_listed_image_classes).returns(["classy"]) post_with_two_classy_images.image_count.should == 0 @@ -166,6 +171,10 @@ describe Post do post_one_image.should be_valid end + it "allows a new user to post emojies" do + post_with_emojis.should be_valid + end + it "doesn't allow more than the maximum" do post_two_images.should_not be_valid end