mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
Merge branch 'master' into pm-tags
This commit is contained in:
@ -169,6 +169,7 @@ describe Post do
|
||||
let(:post_two_images) { post_with_body("<img src='http://discourse.org/logo.png'> <img src='http://bbc.co.uk/sherlock.jpg'>", newuser) }
|
||||
let(:post_with_avatars) { post_with_body('<img alt="smiley" title=":smiley:" src="/assets/emoji/smiley.png" class="avatar"> <img alt="wink" title=":wink:" src="/assets/emoji/wink.png" class="avatar">', newuser) }
|
||||
let(:post_with_favicon) { post_with_body('<img src="/assets/favicons/wikipedia.png" class="favicon">', newuser) }
|
||||
let(:post_image_within_quote) { post_with_body('[quote]<img src="coolimage.png">[/quote]', 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) }
|
||||
|
||||
@ -188,6 +189,28 @@ describe Post do
|
||||
expect(post_with_avatars.image_count).to eq(0)
|
||||
end
|
||||
|
||||
it "allows images by default" do
|
||||
expect(post_one_image).to be_valid
|
||||
end
|
||||
|
||||
it "doesn't allow more than `min_trust_to_post_images`" do
|
||||
SiteSetting.min_trust_to_post_images = 4
|
||||
post_one_image.user.trust_level = 3
|
||||
expect(post_one_image).not_to be_valid
|
||||
end
|
||||
|
||||
it "doesn't allow more than `min_trust_to_post_images`" do
|
||||
SiteSetting.min_trust_to_post_images = 4
|
||||
post_one_image.user.trust_level = 3
|
||||
expect(post_image_within_quote).not_to be_valid
|
||||
end
|
||||
|
||||
it "doesn't allow more than `min_trust_to_post_images`" do
|
||||
SiteSetting.min_trust_to_post_images = 4
|
||||
post_one_image.user.trust_level = 4
|
||||
expect(post_one_image).to be_valid
|
||||
end
|
||||
|
||||
it "doesn't count favicons as images" do
|
||||
PrettyText.stubs(:cook).returns(post_with_favicon.raw)
|
||||
expect(post_with_favicon.image_count).to eq(0)
|
||||
|
@ -15,6 +15,13 @@ describe Tag do
|
||||
SiteSetting.min_trust_level_to_tag_topics = 0
|
||||
end
|
||||
|
||||
it "can delete tags on deleted topics" do
|
||||
tag = Fabricate(:tag)
|
||||
topic = Fabricate(:topic, tags: [tag])
|
||||
topic.trash!
|
||||
expect { tag.destroy }.to change { Tag.count }.by(-1)
|
||||
end
|
||||
|
||||
describe '#top_tags' do
|
||||
it "returns nothing if nothing has been tagged" do
|
||||
make_some_tags(tag_a_topic: false)
|
||||
|
@ -72,6 +72,11 @@ describe TopicEmbed do
|
||||
expect(TopicEmbed.topic_id_for_embed('http://example.com/post/24')).to eq(nil)
|
||||
expect(TopicEmbed.topic_id_for_embed('http://example.com/post')).to eq(nil)
|
||||
end
|
||||
|
||||
it "finds the topic id when the embed_url contains a query string" do
|
||||
topic_embed = Fabricate(:topic_embed, embed_url: "http://example.com/post/248?key=foo")
|
||||
expect(TopicEmbed.topic_id_for_embed('http://example.com/post/248?key=foo')).to eq(topic_embed.topic_id)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.find_remote' do
|
||||
|
9
spec/models/user_second_factor_spec.rb
Normal file
9
spec/models/user_second_factor_spec.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UserSecondFactor do
|
||||
describe '.methods' do
|
||||
it 'should retain the right order' do
|
||||
expect(described_class.methods[:totp]).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
@ -1619,4 +1619,21 @@ describe User do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#activate" do
|
||||
let!(:inactive) { Fabricate(:user, active: false) }
|
||||
|
||||
it 'confirms email token and activates user' do
|
||||
inactive.activate
|
||||
inactive.reload
|
||||
expect(inactive.email_confirmed?).to eq(true)
|
||||
expect(inactive.active).to eq(true)
|
||||
end
|
||||
|
||||
it 'activates user even if email token is already confirmed' do
|
||||
token = inactive.email_tokens.find_by(email: inactive.email)
|
||||
token.update_column(:confirmed, true)
|
||||
inactive.activate
|
||||
expect(inactive.active).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user