mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 14:08:32 +08:00
Nuke all SiteSetting.stubs
from our codebase.
This commit is contained in:
@ -28,7 +28,7 @@ describe ComposerMessagesFinder do
|
||||
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'createTopic') }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:educate_until_posts).returns(10)
|
||||
SiteSetting.educate_until_posts = 10
|
||||
end
|
||||
|
||||
it "returns a message for a user who has not posted any topics" do
|
||||
@ -66,7 +66,7 @@ describe ComposerMessagesFinder do
|
||||
let(:finder) { ComposerMessagesFinder.new(user, composer_action: 'reply') }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:educate_until_posts).returns(10)
|
||||
SiteSetting.educate_until_posts = 10
|
||||
end
|
||||
|
||||
it "returns a message for a user who has not posted any topics" do
|
||||
@ -152,13 +152,13 @@ describe ComposerMessagesFinder do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:educate_until_posts).returns(10)
|
||||
SiteSetting.educate_until_posts = 10
|
||||
user.stubs(:post_count).returns(11)
|
||||
|
||||
Fabricate(:post, topic: topic, user: user)
|
||||
Fabricate(:post, topic: topic, user: user)
|
||||
|
||||
SiteSetting.stubs(:sequential_replies_threshold).returns(2)
|
||||
SiteSetting.sequential_replies_threshold = 2
|
||||
end
|
||||
|
||||
it "does not give a message for new topics" do
|
||||
@ -189,7 +189,7 @@ describe ComposerMessagesFinder do
|
||||
end
|
||||
|
||||
it "doesn't notify a user who has less than the `sequential_replies_threshold` threshold posts" do
|
||||
SiteSetting.stubs(:sequential_replies_threshold).returns(5)
|
||||
SiteSetting.sequential_replies_threshold = 5
|
||||
expect(finder.check_sequential_replies).to be_blank
|
||||
end
|
||||
|
||||
@ -224,16 +224,16 @@ describe ComposerMessagesFinder do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:educate_until_posts).returns(10)
|
||||
SiteSetting.educate_until_posts = 10
|
||||
user.stubs(:post_count).returns(11)
|
||||
|
||||
SiteSetting.stubs(:summary_posts_required).returns(1)
|
||||
SiteSetting.summary_posts_required = 1
|
||||
|
||||
Fabricate(:post, topic: topic, user: user)
|
||||
Fabricate(:post, topic: topic, user: user)
|
||||
Fabricate(:post, topic: topic, user: Fabricate(:user))
|
||||
|
||||
SiteSetting.stubs(:sequential_replies_threshold).returns(2)
|
||||
SiteSetting.sequential_replies_threshold = 2
|
||||
end
|
||||
|
||||
it "does not give a message for new topics" do
|
||||
@ -254,7 +254,7 @@ describe ComposerMessagesFinder do
|
||||
end
|
||||
|
||||
it "does not notify if the `summary_posts_required` has not been reached" do
|
||||
SiteSetting.stubs(:summary_posts_required).returns(100)
|
||||
SiteSetting.summary_posts_required = 100
|
||||
expect(finder.check_dominating_topic).to be_blank
|
||||
end
|
||||
|
||||
@ -269,12 +269,12 @@ describe ComposerMessagesFinder do
|
||||
end
|
||||
|
||||
it "doesn't notify a user if the topic has less than `summary_posts_required` posts" do
|
||||
SiteSetting.stubs(:summary_posts_required).returns(5)
|
||||
SiteSetting.summary_posts_required = 5
|
||||
expect(finder.check_dominating_topic).to be_blank
|
||||
end
|
||||
|
||||
it "doesn't notify a user if they've posted less than the percentage" do
|
||||
SiteSetting.stubs(:dominating_topic_minimum_percent).returns(100)
|
||||
SiteSetting.dominating_topic_minimum_percent = 100
|
||||
expect(finder.check_dominating_topic).to be_blank
|
||||
end
|
||||
|
||||
@ -433,7 +433,7 @@ describe ComposerMessagesFinder do
|
||||
context "a reply" do
|
||||
context "warn_reviving_old_topic_age is 180 days" do
|
||||
before do
|
||||
SiteSetting.stubs(:warn_reviving_old_topic_age).returns(180)
|
||||
SiteSetting.warn_reviving_old_topic_age = 180
|
||||
end
|
||||
|
||||
it "does not notify if last post is recent" do
|
||||
@ -449,7 +449,7 @@ describe ComposerMessagesFinder do
|
||||
|
||||
context "warn_reviving_old_topic_age is 0" do
|
||||
before do
|
||||
SiteSetting.stubs(:warn_reviving_old_topic_age).returns(0)
|
||||
SiteSetting.warn_reviving_old_topic_age = 0
|
||||
end
|
||||
|
||||
it "does not notify if last post is new" do
|
||||
|
@ -298,21 +298,21 @@ describe CookedPostProcessor do
|
||||
|
||||
it "resizes when only width is specified" do
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'width' => 100}
|
||||
SiteSetting.stubs(:crawl_images?).returns(true)
|
||||
SiteSetting.crawl_images = true
|
||||
FastImage.expects(:size).returns([200, 400])
|
||||
expect(cpp.get_size_from_attributes(img)).to eq([100, 200])
|
||||
end
|
||||
|
||||
it "resizes when only height is specified" do
|
||||
img = { 'src' => 'http://foo.bar/image3.png', 'height' => 100}
|
||||
SiteSetting.stubs(:crawl_images?).returns(true)
|
||||
SiteSetting.crawl_images = true
|
||||
FastImage.expects(:size).returns([100, 300])
|
||||
expect(cpp.get_size_from_attributes(img)).to eq([33, 100])
|
||||
end
|
||||
|
||||
it "doesn't raise an error with a weird url" do
|
||||
img = { 'src' => nil, 'height' => 100}
|
||||
SiteSetting.stubs(:crawl_images?).returns(true)
|
||||
SiteSetting.crawl_images = true
|
||||
expect(cpp.get_size_from_attributes(img)).to be_nil
|
||||
end
|
||||
|
||||
@ -346,7 +346,7 @@ describe CookedPostProcessor do
|
||||
end
|
||||
|
||||
it "caches the results" do
|
||||
SiteSetting.stubs(:crawl_images?).returns(true)
|
||||
SiteSetting.crawl_images = true
|
||||
FastImage.expects(:size).returns([200, 400])
|
||||
cpp.get_size("http://foo.bar/image3.png")
|
||||
expect(cpp.get_size("http://foo.bar/image3.png")).to eq([200, 400])
|
||||
@ -354,7 +354,9 @@ describe CookedPostProcessor do
|
||||
|
||||
context "when crawl_images is disabled" do
|
||||
|
||||
before { SiteSetting.stubs(:crawl_images?).returns(false) }
|
||||
before do
|
||||
SiteSetting.crawl_images = false
|
||||
end
|
||||
|
||||
it "doesn't call FastImage" do
|
||||
FastImage.expects(:size).never
|
||||
@ -525,14 +527,15 @@ describe CookedPostProcessor do
|
||||
before { cpp.stubs(:available_disk_space).returns(90) }
|
||||
|
||||
it "does not run when download_remote_images_to_local is disabled" do
|
||||
SiteSetting.stubs(:download_remote_images_to_local).returns(false)
|
||||
SiteSetting.download_remote_images_to_local = false
|
||||
Jobs.expects(:cancel_scheduled_job).never
|
||||
cpp.pull_hotlinked_images
|
||||
end
|
||||
|
||||
context "when download_remote_images_to_local? is enabled" do
|
||||
|
||||
before { SiteSetting.stubs(:download_remote_images_to_local).returns(true) }
|
||||
before do
|
||||
SiteSetting.download_remote_images_to_local = true
|
||||
end
|
||||
|
||||
it "does not run when there is not enough disk space" do
|
||||
cpp.expects(:disable_if_low_on_disk_space).returns(true)
|
||||
|
@ -53,12 +53,7 @@ describe Discourse do
|
||||
let!(:another_admin) { Fabricate(:admin) }
|
||||
|
||||
it 'returns the user specified by the site setting site_contact_username' do
|
||||
SiteSetting.stubs(:site_contact_username).returns(another_admin.username)
|
||||
expect(Discourse.site_contact_user).to eq(another_admin)
|
||||
end
|
||||
|
||||
it 'returns the user specified by the site setting site_contact_username regardless of its case' do
|
||||
SiteSetting.stubs(:site_contact_username).returns(another_admin.username.upcase)
|
||||
SiteSetting.site_contact_username = another_admin.username
|
||||
expect(Discourse.site_contact_user).to eq(another_admin)
|
||||
end
|
||||
|
||||
@ -211,4 +206,3 @@ describe Discourse do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -254,7 +254,7 @@ describe Email::Receiver do
|
||||
end
|
||||
|
||||
it 'does nothing unless unsubscribe_via_email is turned on' do
|
||||
SiteSetting.stubs("unsubscribe_via_email").returns(false)
|
||||
SiteSetting.unsubscribe_via_email = false
|
||||
before_deliveries = ActionMailer::Base.deliveries.count
|
||||
expect { process("unsubscribe_subject") }.to raise_error { Email::Receiver::BadDestinationAddress }
|
||||
expect(before_deliveries).to eq ActionMailer::Base.deliveries.count
|
||||
@ -272,7 +272,7 @@ describe Email::Receiver do
|
||||
end
|
||||
|
||||
it 'does nothing unless unsubscribe_via_email is turned on' do
|
||||
SiteSetting.stubs(:unsubscribe_via_email).returns(false)
|
||||
SiteSetting.unsubscribe_via_email = false
|
||||
before_deliveries = ActionMailer::Base.deliveries.count
|
||||
expect { process("unsubscribe_body") }.to raise_error { Email::Receiver::InvalidPost }
|
||||
expect(before_deliveries).to eq ActionMailer::Base.deliveries.count
|
||||
|
@ -117,7 +117,7 @@ describe Email::Styles do
|
||||
|
||||
context "without https" do
|
||||
before do
|
||||
SiteSetting.stubs(:force_https).returns(false)
|
||||
SiteSetting.force_https = false
|
||||
end
|
||||
|
||||
it "rewrites the href to have http" do
|
||||
@ -138,7 +138,7 @@ describe Email::Styles do
|
||||
|
||||
context "with https" do
|
||||
before do
|
||||
SiteSetting.stubs(:force_https).returns(true)
|
||||
SiteSetting.force_https = true
|
||||
end
|
||||
|
||||
it "rewrites the forum URL to have https" do
|
||||
|
@ -209,13 +209,13 @@ describe FileStore::S3Store do
|
||||
end
|
||||
|
||||
it "uses the proper endpoint" do
|
||||
SiteSetting.stubs(:s3_region).returns("us-east-1")
|
||||
SiteSetting.s3_region = "us-east-1"
|
||||
expect(FileStore::S3Store.new(s3_helper).absolute_base_url).to eq("//s3-upload-bucket.s3.amazonaws.com")
|
||||
|
||||
SiteSetting.stubs(:s3_region).returns("us-east-2")
|
||||
expect(FileStore::S3Store.new(s3_helper).absolute_base_url).to eq("//s3-upload-bucket.s3-us-east-2.amazonaws.com")
|
||||
SiteSetting.s3_region = "us-west-2"
|
||||
expect(FileStore::S3Store.new(s3_helper).absolute_base_url).to eq("//s3-upload-bucket.s3-us-west-2.amazonaws.com")
|
||||
|
||||
SiteSetting.stubs(:s3_region).returns("cn-north-1")
|
||||
SiteSetting.s3_region = "cn-north-1"
|
||||
expect(FileStore::S3Store.new(s3_helper).absolute_base_url).to eq("//s3-upload-bucket.s3.cn-north-1.amazonaws.com.cn")
|
||||
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
require 'rails_helper'
|
||||
require 'rails_helper';
|
||||
|
||||
require 'guardian'
|
||||
require_dependency 'post_destroyer'
|
||||
|
||||
@ -322,7 +323,7 @@ describe Guardian do
|
||||
end
|
||||
|
||||
it 'returns false when the local logins are disabled' do
|
||||
SiteSetting.stubs(:enable_local_logins).returns(false)
|
||||
SiteSetting.enable_local_logins = false
|
||||
expect(Guardian.new(user).can_invite_to_forum?).to be_falsey
|
||||
expect(Guardian.new(moderator).can_invite_to_forum?).to be_falsey
|
||||
end
|
||||
@ -536,7 +537,7 @@ describe Guardian do
|
||||
|
||||
it "restricts static doc topics" do
|
||||
tos_topic = Fabricate(:topic, user: Discourse.system_user)
|
||||
SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id)
|
||||
SiteSetting.tos_topic_id = tos_topic.id
|
||||
|
||||
expect(Guardian.new(build(:user)).can_edit?(tos_topic)).to be_falsey
|
||||
expect(Guardian.new(moderator).can_edit?(tos_topic)).to be_falsey
|
||||
@ -609,7 +610,7 @@ describe Guardian do
|
||||
let(:post_revision) { Fabricate(:post_revision) }
|
||||
|
||||
context 'edit_history_visible_to_public is true' do
|
||||
before { SiteSetting.stubs(:edit_history_visible_to_public).returns(true) }
|
||||
before { SiteSetting.edit_history_visible_to_public = true }
|
||||
|
||||
it 'is false for nil' do
|
||||
expect(Guardian.new.can_see?(nil)).to be_falsey
|
||||
@ -625,7 +626,7 @@ describe Guardian do
|
||||
end
|
||||
|
||||
context 'edit_history_visible_to_public is false' do
|
||||
before { SiteSetting.stubs(:edit_history_visible_to_public).returns(false) }
|
||||
before { SiteSetting.edit_history_visible_to_public = false }
|
||||
|
||||
it 'is true for staff' do
|
||||
expect(Guardian.new(Fabricate(:admin)).can_see?(post_revision)).to be_truthy
|
||||
@ -685,12 +686,12 @@ describe Guardian do
|
||||
end
|
||||
|
||||
it "is false if user has not met minimum trust level" do
|
||||
SiteSetting.stubs(:min_trust_to_create_topic).returns(1)
|
||||
SiteSetting.min_trust_to_create_topic = 1
|
||||
expect(Guardian.new(build(:user, trust_level: 0)).can_create?(Topic,Fabricate(:category))).to be_falsey
|
||||
end
|
||||
|
||||
it "is true if user has met or exceeded the minimum trust level" do
|
||||
SiteSetting.stubs(:min_trust_to_create_topic).returns(1)
|
||||
SiteSetting.min_trust_to_create_topic = 1
|
||||
expect(Guardian.new(build(:user, trust_level: 1)).can_create?(Topic,Fabricate(:category))).to be_truthy
|
||||
expect(Guardian.new(build(:user, trust_level: 2)).can_create?(Topic,Fabricate(:category))).to be_truthy
|
||||
expect(Guardian.new(build(:admin, trust_level: 0)).can_create?(Topic,Fabricate(:category))).to be_truthy
|
||||
@ -1094,7 +1095,7 @@ describe Guardian do
|
||||
end
|
||||
|
||||
it 'returns false when another user has too low trust level to edit wiki post' do
|
||||
SiteSetting.stubs(:min_trust_to_edit_wiki_post).returns(2)
|
||||
SiteSetting.min_trust_to_edit_wiki_post = 2
|
||||
post.wiki = true
|
||||
coding_horror.trust_level = 1
|
||||
|
||||
@ -1102,7 +1103,7 @@ describe Guardian do
|
||||
end
|
||||
|
||||
it 'returns true when another user has adequate trust level to edit wiki post' do
|
||||
SiteSetting.stubs(:min_trust_to_edit_wiki_post).returns(2)
|
||||
SiteSetting.min_trust_to_edit_wiki_post = 2
|
||||
post.wiki = true
|
||||
coding_horror.trust_level = 2
|
||||
|
||||
@ -1110,7 +1111,7 @@ describe Guardian do
|
||||
end
|
||||
|
||||
it 'returns true for post author even when he has too low trust level to edit wiki post' do
|
||||
SiteSetting.stubs(:min_trust_to_edit_wiki_post).returns(2)
|
||||
SiteSetting.min_trust_to_edit_wiki_post = 2
|
||||
post.wiki = true
|
||||
post.user.trust_level = 1
|
||||
|
||||
@ -1119,8 +1120,9 @@ describe Guardian do
|
||||
|
||||
context 'post is older than post_edit_time_limit' do
|
||||
let(:old_post) { build(:post, topic: topic, user: topic.user, created_at: 6.minutes.ago) }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:post_edit_time_limit).returns(5)
|
||||
SiteSetting.post_edit_time_limit = 5
|
||||
end
|
||||
|
||||
it 'returns false to the author of the post' do
|
||||
@ -1148,7 +1150,7 @@ describe Guardian do
|
||||
context "first post of a static page doc" do
|
||||
let!(:tos_topic) { Fabricate(:topic, user: Discourse.system_user) }
|
||||
let!(:tos_first_post) { build(:post, topic: tos_topic, user: tos_topic.user) }
|
||||
before { SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id) }
|
||||
before { SiteSetting.tos_topic_id = tos_topic.id }
|
||||
|
||||
it "restricts static doc posts" do
|
||||
expect(Guardian.new(build(:user)).can_edit?(tos_first_post)).to be_falsey
|
||||
@ -1246,7 +1248,7 @@ describe Guardian do
|
||||
context 'very old' do
|
||||
let(:old_topic) { build(:topic, user: user, created_at: 6.minutes.ago) }
|
||||
|
||||
before { SiteSetting.stubs(:post_edit_time_limit).returns(5) }
|
||||
before { SiteSetting.post_edit_time_limit = 5 }
|
||||
|
||||
it 'returns true as a moderator' do
|
||||
expect(Guardian.new(moderator).can_edit?(old_topic)).to be_truthy
|
||||
@ -1433,7 +1435,7 @@ describe Guardian do
|
||||
|
||||
it 'returns false for static doc topics' do
|
||||
tos_topic = Fabricate(:topic, user: Discourse.system_user)
|
||||
SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id)
|
||||
SiteSetting.tos_topic_id = tos_topic.id
|
||||
expect(Guardian.new(admin).can_delete?(tos_topic)).to be_falsey
|
||||
end
|
||||
end
|
||||
@ -1478,7 +1480,7 @@ describe Guardian do
|
||||
|
||||
it 'returns false when post is first in a static doc topic' do
|
||||
tos_topic = Fabricate(:topic, user: Discourse.system_user)
|
||||
SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id)
|
||||
SiteSetting.tos_topic_id = tos_topic.id
|
||||
post.update_attribute :post_number, 1
|
||||
post.update_attribute :topic_id, tos_topic.id
|
||||
expect(Guardian.new(admin).can_delete?(post)).to be_falsey
|
||||
@ -1487,7 +1489,7 @@ describe Guardian do
|
||||
context 'post is older than post_edit_time_limit' do
|
||||
let(:old_post) { build(:post, topic: topic, user: topic.user, post_number: 2, created_at: 6.minutes.ago) }
|
||||
before do
|
||||
SiteSetting.stubs(:post_edit_time_limit).returns(5)
|
||||
SiteSetting.post_edit_time_limit = 5
|
||||
end
|
||||
|
||||
it 'returns false to the author of the post' do
|
||||
@ -1781,7 +1783,7 @@ describe Guardian do
|
||||
|
||||
context "when must_approve_users is false" do
|
||||
before do
|
||||
SiteSetting.stubs(:must_approve_users?).returns(false)
|
||||
SiteSetting.must_approve_users = false
|
||||
end
|
||||
|
||||
it "returns true for a nil user" do
|
||||
@ -1795,7 +1797,7 @@ describe Guardian do
|
||||
|
||||
context 'when must_approve_users is true' do
|
||||
before do
|
||||
SiteSetting.stubs(:must_approve_users?).returns(true)
|
||||
SiteSetting.must_approve_users = true
|
||||
end
|
||||
|
||||
it "returns false for a nil user" do
|
||||
@ -1860,7 +1862,7 @@ describe Guardian do
|
||||
it "is true if user is not an admin and first post is not too old" do
|
||||
user = Fabricate.build(:user, created_at: 100.days.ago)
|
||||
user.stubs(:first_post_created_at).returns(9.days.ago)
|
||||
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
|
||||
SiteSetting.delete_user_max_post_age = 10
|
||||
expect(Guardian.new(actor).can_delete_user?(user)).to be_truthy
|
||||
end
|
||||
|
||||
@ -1871,7 +1873,7 @@ describe Guardian do
|
||||
it "is false if user's first post is too old" do
|
||||
user = Fabricate.build(:user, created_at: 100.days.ago)
|
||||
user.stubs(:first_post_created_at).returns(11.days.ago)
|
||||
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
|
||||
SiteSetting.delete_user_max_post_age = 10
|
||||
expect(Guardian.new(actor).can_delete_user?(user)).to be_falsey
|
||||
end
|
||||
end
|
||||
@ -1902,21 +1904,21 @@ describe Guardian do
|
||||
|
||||
shared_examples "can_delete_all_posts examples" do
|
||||
it "is true if user has no posts" do
|
||||
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
|
||||
SiteSetting.delete_user_max_post_age = 10
|
||||
expect(Guardian.new(actor).can_delete_all_posts?(Fabricate(:user, created_at: 100.days.ago))).to be_truthy
|
||||
end
|
||||
|
||||
it "is true if user's first post is newer than delete_user_max_post_age days old" do
|
||||
user = Fabricate(:user, created_at: 100.days.ago)
|
||||
user.stubs(:first_post_created_at).returns(9.days.ago)
|
||||
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
|
||||
SiteSetting.delete_user_max_post_age = 10
|
||||
expect(Guardian.new(actor).can_delete_all_posts?(user)).to be_truthy
|
||||
end
|
||||
|
||||
it "is false if user's first post is older than delete_user_max_post_age days old" do
|
||||
user = Fabricate(:user, created_at: 100.days.ago)
|
||||
user.stubs(:first_post_created_at).returns(11.days.ago)
|
||||
SiteSetting.stubs(:delete_user_max_post_age).returns(10)
|
||||
SiteSetting.delete_user_max_post_age = 10
|
||||
expect(Guardian.new(actor).can_delete_all_posts?(user)).to be_falsey
|
||||
end
|
||||
|
||||
@ -1927,14 +1929,14 @@ describe Guardian do
|
||||
it "is true if number of posts is small" do
|
||||
u = Fabricate(:user, created_at: 1.day.ago)
|
||||
u.stubs(:post_count).returns(1)
|
||||
SiteSetting.stubs(:delete_all_posts_max).returns(10)
|
||||
SiteSetting.delete_all_posts_max = 10
|
||||
expect(Guardian.new(actor).can_delete_all_posts?(u)).to be_truthy
|
||||
end
|
||||
|
||||
it "is false if number of posts is not small" do
|
||||
u = Fabricate(:user, created_at: 1.day.ago)
|
||||
u.stubs(:post_count).returns(11)
|
||||
SiteSetting.stubs(:delete_all_posts_max).returns(10)
|
||||
SiteSetting.delete_all_posts_max = 10
|
||||
expect(Guardian.new(actor).can_delete_all_posts?(u)).to be_falsey
|
||||
end
|
||||
end
|
||||
@ -2064,7 +2066,7 @@ describe Guardian do
|
||||
|
||||
context 'for an old user' do
|
||||
before do
|
||||
SiteSetting.stubs(:username_change_period).returns(3)
|
||||
SiteSetting.username_change_period = 3
|
||||
end
|
||||
|
||||
let(:target_user) { Fabricate(:user, created_at: 4.days.ago) }
|
||||
@ -2087,7 +2089,7 @@ describe Guardian do
|
||||
|
||||
context 'when editing is disabled in preferences' do
|
||||
before do
|
||||
SiteSetting.stubs(:username_change_period).returns(0)
|
||||
SiteSetting.username_change_period = 0
|
||||
end
|
||||
|
||||
include_examples "staff can always change usernames"
|
||||
@ -2099,8 +2101,8 @@ describe Guardian do
|
||||
|
||||
context 'when SSO username override is active' do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_sso).returns(true)
|
||||
SiteSetting.stubs(:sso_overrides_username).returns(true)
|
||||
SiteSetting.enable_sso = true
|
||||
SiteSetting.sso_overrides_username = true
|
||||
end
|
||||
|
||||
it "is false for admins" do
|
||||
@ -2120,7 +2122,7 @@ describe Guardian do
|
||||
describe "can_edit_email?" do
|
||||
context 'when allowed in settings' do
|
||||
before do
|
||||
SiteSetting.stubs(:email_editable?).returns(true)
|
||||
SiteSetting.email_editable = true
|
||||
end
|
||||
|
||||
it "is false when not logged in" do
|
||||
@ -2146,7 +2148,7 @@ describe Guardian do
|
||||
|
||||
context 'when not allowed in settings' do
|
||||
before do
|
||||
SiteSetting.stubs(:email_editable?).returns(false)
|
||||
SiteSetting.email_editable = false
|
||||
end
|
||||
|
||||
it "is false when not logged in" do
|
||||
@ -2172,8 +2174,8 @@ describe Guardian do
|
||||
|
||||
context 'when SSO email override is active' do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_sso).returns(true)
|
||||
SiteSetting.stubs(:sso_overrides_email).returns(true)
|
||||
SiteSetting.enable_sso = true
|
||||
SiteSetting.sso_overrides_email = true
|
||||
end
|
||||
|
||||
it "is false for admins" do
|
||||
@ -2217,7 +2219,7 @@ describe Guardian do
|
||||
|
||||
context 'when name is disabled in preferences' do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_names).returns(false)
|
||||
SiteSetting.enable_names = false
|
||||
end
|
||||
|
||||
it 'is false for the user to change their own name' do
|
||||
@ -2235,13 +2237,13 @@ describe Guardian do
|
||||
|
||||
context 'when name is enabled in preferences' do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_names).returns(true)
|
||||
SiteSetting.enable_names = true
|
||||
end
|
||||
|
||||
context 'when SSO is disabled' do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_sso).returns(false)
|
||||
SiteSetting.stubs(:sso_overrides_name).returns(false)
|
||||
SiteSetting.enable_sso = false
|
||||
SiteSetting.sso_overrides_name = false
|
||||
end
|
||||
|
||||
it 'is true for admins' do
|
||||
@ -2259,12 +2261,12 @@ describe Guardian do
|
||||
|
||||
context 'when SSO is enabled' do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_sso).returns(true)
|
||||
SiteSetting.enable_sso = true
|
||||
end
|
||||
|
||||
context 'when SSO name override is active' do
|
||||
before do
|
||||
SiteSetting.stubs(:sso_overrides_name).returns(true)
|
||||
SiteSetting.sso_overrides_name = true
|
||||
end
|
||||
|
||||
it 'is false for admins' do
|
||||
@ -2282,7 +2284,7 @@ describe Guardian do
|
||||
|
||||
context 'when SSO name override is not active' do
|
||||
before do
|
||||
SiteSetting.stubs(:sso_overrides_name).returns(false)
|
||||
SiteSetting.sso_overrides_name = false
|
||||
end
|
||||
|
||||
it 'is true for admins' do
|
||||
|
@ -4,8 +4,8 @@ require 'image_sizer'
|
||||
describe ImageSizer do
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:max_image_width).returns(500)
|
||||
SiteSetting.stubs(:max_image_height).returns(500)
|
||||
SiteSetting.max_image_width = 500
|
||||
SiteSetting.max_image_height = 500
|
||||
end
|
||||
|
||||
it 'returns the same dimensions when smaller than the maximums' do
|
||||
|
@ -8,19 +8,19 @@ describe Onebox::Engine::FlashVideoOnebox do
|
||||
|
||||
context "when SiteSetting.enable_flash_video_onebox is true" do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_flash_video_onebox).returns(true)
|
||||
SiteSetting.enable_flash_video_onebox = true
|
||||
end
|
||||
|
||||
it "generates a flash video" do
|
||||
expect(@o.to_html).to match_html(
|
||||
"<object width='100%' height='100%'><param name='http://player.56.com/v_OTMyNTk1MzE.swf' value='http://player.56.com/v_OTMyNTk1MzE.swf'><embed src='http://player.56.com/v_OTMyNTk1MzE.swf' width='100%' height='100%'></embed></object>"
|
||||
"<object width='100%' height='100%'><param name='http://player.56.com/v_OTMyNTk1MzE.swf' value='http://player.56.com/v_OTMyNTk1MzE.swf'><embed src='http://player.56.com/v_OTMyNTk1MzE.swf' width='100%' height='100%'></embed></object>"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when SiteSetting.enable_flash_video_onebox is false" do
|
||||
before do
|
||||
SiteSetting.stubs(:enable_flash_video_onebox).returns(false)
|
||||
SiteSetting.enable_flash_video_onebox = false
|
||||
end
|
||||
|
||||
it "generates a link" do
|
||||
|
@ -51,7 +51,7 @@ describe PostDestroyer do
|
||||
|
||||
describe 'destroy_old_stubs' do
|
||||
it 'destroys stubs for deleted by user posts' do
|
||||
SiteSetting.stubs(:delete_removed_posts_after).returns(24)
|
||||
SiteSetting.delete_removed_posts_after = 24
|
||||
Fabricate(:admin)
|
||||
topic = post.topic
|
||||
reply1 = create_post(topic: topic)
|
||||
@ -102,7 +102,7 @@ describe PostDestroyer do
|
||||
PostDestroyer.new(reply1.user, reply1).destroy
|
||||
PostDestroyer.new(reply2.user, reply2).destroy
|
||||
|
||||
SiteSetting.stubs(:delete_removed_posts_after).returns(1)
|
||||
SiteSetting.delete_removed_posts_after = 1
|
||||
|
||||
reply2.update_column(:updated_at, 70.minutes.ago)
|
||||
|
||||
@ -114,7 +114,7 @@ describe PostDestroyer do
|
||||
expect(reply1.deleted_at).to eq(nil)
|
||||
expect(reply2.deleted_at).not_to eq(nil)
|
||||
|
||||
SiteSetting.stubs(:delete_removed_posts_after).returns(72)
|
||||
SiteSetting.delete_removed_posts_after = 72
|
||||
|
||||
reply1.update_column(:updated_at, 2.days.ago)
|
||||
|
||||
@ -122,7 +122,7 @@ describe PostDestroyer do
|
||||
|
||||
expect(reply1.reload.deleted_at).to eq(nil)
|
||||
|
||||
SiteSetting.stubs(:delete_removed_posts_after).returns(47)
|
||||
SiteSetting.delete_removed_posts_after = 47
|
||||
|
||||
PostDestroyer.destroy_stubs
|
||||
|
||||
@ -134,7 +134,7 @@ describe PostDestroyer do
|
||||
topic = post.topic
|
||||
reply1 = create_post(topic: topic)
|
||||
|
||||
SiteSetting.stubs(:delete_removed_posts_after).returns(0)
|
||||
SiteSetting.delete_removed_posts_after = 0
|
||||
|
||||
PostDestroyer.new(reply1.user, reply1).destroy
|
||||
|
||||
|
@ -73,7 +73,7 @@ describe PostRevisor do
|
||||
|
||||
describe 'ninja editing' do
|
||||
it 'correctly applies edits' do
|
||||
SiteSetting.stubs(:editing_grace_period).returns(1.minute)
|
||||
SiteSetting.editing_grace_period = 1.minute
|
||||
|
||||
subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 10.seconds)
|
||||
post.reload
|
||||
@ -86,7 +86,7 @@ describe PostRevisor do
|
||||
end
|
||||
|
||||
it "doesn't create a new version" do
|
||||
SiteSetting.stubs(:editing_grace_period).returns(1.minute)
|
||||
SiteSetting.editing_grace_period = 1.minute
|
||||
|
||||
# making a revision
|
||||
subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds)
|
||||
@ -106,7 +106,7 @@ describe PostRevisor do
|
||||
let!(:revised_at) { post.updated_at + 2.minutes }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:editing_grace_period).returns(1.minute.to_i)
|
||||
SiteSetting.editing_grace_period = 1.minute
|
||||
subject.revise!(post.user, { raw: 'updated body' }, revised_at: revised_at)
|
||||
post.reload
|
||||
end
|
||||
@ -244,7 +244,7 @@ describe PostRevisor do
|
||||
let(:changed_by) { Fabricate(:admin) }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:newuser_max_images).returns(0)
|
||||
SiteSetting.newuser_max_images = 0
|
||||
url = "http://i.imgur.com/wfn7rgU.jpg"
|
||||
Oneboxer.stubs(:onebox).with(url, anything).returns("<img src='#{url}'>")
|
||||
subject.revise!(changed_by, { raw: "So, post them here!\n#{url}" })
|
||||
@ -262,7 +262,7 @@ describe PostRevisor do
|
||||
|
||||
describe "new user editing their own post" do
|
||||
before do
|
||||
SiteSetting.stubs(:newuser_max_images).returns(0)
|
||||
SiteSetting.newuser_max_images = 0
|
||||
url = "http://i.imgur.com/FGg7Vzu.gif"
|
||||
Oneboxer.stubs(:cached_onebox).with(url, anything).returns("<img src='#{url}'>")
|
||||
subject.revise!(post.user, { raw: "So, post them here!\n#{url}" })
|
||||
@ -312,7 +312,7 @@ describe PostRevisor do
|
||||
|
||||
context 'second poster posts again quickly' do
|
||||
before do
|
||||
SiteSetting.stubs(:editing_grace_period).returns(1.minute.to_i)
|
||||
SiteSetting.editing_grace_period = 1.minute
|
||||
subject.revise!(changed_by, { raw: 'yet another updated body' }, revised_at: post.updated_at + 10.seconds)
|
||||
post.reload
|
||||
end
|
||||
@ -326,7 +326,7 @@ describe PostRevisor do
|
||||
|
||||
context 'passing skip_revision as true' do
|
||||
before do
|
||||
SiteSetting.stubs(:editing_grace_period).returns(1.minute.to_i)
|
||||
SiteSetting.editing_grace_period = 1.minute
|
||||
subject.revise!(changed_by, { raw: 'yet another updated body' }, { revised_at: post.updated_at + 10.hours, skip_revision: true })
|
||||
post.reload
|
||||
end
|
||||
|
@ -94,8 +94,8 @@ HTML
|
||||
|
||||
describe "rel nofollow" do
|
||||
before do
|
||||
SiteSetting.stubs(:add_rel_nofollow_to_user_content).returns(true)
|
||||
SiteSetting.stubs(:exclude_rel_nofollow_domains).returns("foo.com|bar.com")
|
||||
SiteSetting.add_rel_nofollow_to_user_content = true
|
||||
SiteSetting.exclude_rel_nofollow_domains = "foo.com|bar.com"
|
||||
end
|
||||
|
||||
it "should inject nofollow in all user provided links" do
|
||||
|
@ -29,10 +29,10 @@ describe Rtl do
|
||||
end
|
||||
|
||||
context 'user locale is not allowed' do
|
||||
before { SiteSetting.stubs(:allow_user_locale).returns(false) }
|
||||
before { SiteSetting.allow_user_locale = false }
|
||||
|
||||
context 'site default locale is RTL' do
|
||||
before { SiteSetting.stubs(:default_locale).returns('he') }
|
||||
before { SiteSetting.default_locale = 'he' }
|
||||
|
||||
it 'returns rtl class' do
|
||||
expect(Rtl.new(user).css_class).to eq('rtl')
|
||||
@ -40,7 +40,7 @@ describe Rtl do
|
||||
end
|
||||
|
||||
context 'site default locale is LTR' do
|
||||
before { SiteSetting.stubs(:default_locale).returns('en') }
|
||||
before { SiteSetting.default_locale = 'en' }
|
||||
|
||||
context 'user locale is RTL' do
|
||||
before { user.stubs(:locale).returns('he') }
|
||||
|
@ -121,7 +121,7 @@ describe Search do
|
||||
end
|
||||
|
||||
context 'hiding user profiles' do
|
||||
before { SiteSetting.stubs(:hide_user_profiles_from_public).returns(true) }
|
||||
before { SiteSetting.hide_user_profiles_from_public = true }
|
||||
|
||||
it 'returns no result for anon' do
|
||||
expect(result.users.length).to eq(0)
|
||||
|
@ -7,13 +7,13 @@ describe SpamHandler do
|
||||
|
||||
it "works" do
|
||||
# max_new_accounts_per_registration_ip = 0 disables the check
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(0)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 0
|
||||
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[1])
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
|
||||
# only prevents registration for TL0
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(2)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 2
|
||||
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[1])
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
@ -24,36 +24,36 @@ describe SpamHandler do
|
||||
|
||||
it "doesn't limit registrations since there is a TL2+ user with that IP" do
|
||||
# setup
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(0)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 0
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[2])
|
||||
|
||||
# should not limit registration
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(1)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 1
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
end
|
||||
|
||||
it "doesn't limit registrations since there is a staff member with that IP" do
|
||||
# setup
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(0)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 0
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
Fabricate(:moderator, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
|
||||
Group.refresh_automatic_groups!(:staff)
|
||||
|
||||
# should not limit registration
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(1)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 1
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
end
|
||||
|
||||
it "doesn't limit registrations when the IP is whitelisted" do
|
||||
# setup
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(0)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 0
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
ScreenedIpAddress.stubs(:is_whitelisted?).with("42.42.42.42").returns(true)
|
||||
|
||||
# should not limit registration
|
||||
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(1)
|
||||
SiteSetting.max_new_accounts_per_registration_ip = 1
|
||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||
end
|
||||
|
||||
|
@ -7,7 +7,7 @@ describe SuggestedTopicsBuilder do
|
||||
let(:builder) { SuggestedTopicsBuilder.new(topic) }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:suggested_topics).returns(5)
|
||||
SiteSetting.suggested_topics = 5
|
||||
end
|
||||
|
||||
context "splicing category results" do
|
||||
|
@ -79,7 +79,7 @@ describe TextSentinel do
|
||||
end
|
||||
|
||||
it "allows all caps topics when loud posts are allowed" do
|
||||
SiteSetting.stubs(:allow_uppercase_posts).returns(true)
|
||||
SiteSetting.allow_uppercase_posts = true
|
||||
expect(TextSentinel.new(valid_string.upcase)).to be_valid
|
||||
end
|
||||
|
||||
@ -126,8 +126,8 @@ describe TextSentinel do
|
||||
context 'title_sentinel' do
|
||||
|
||||
it "uses a sensible min entropy value when min title length is less than title_min_entropy" do
|
||||
SiteSetting.stubs(:min_topic_title_length).returns(3)
|
||||
SiteSetting.stubs(:title_min_entropy).returns(10)
|
||||
SiteSetting.min_topic_title_length = 3
|
||||
SiteSetting.title_min_entropy = 10
|
||||
expect(TextSentinel.title_sentinel('Hey')).to be_valid
|
||||
end
|
||||
|
||||
@ -136,15 +136,15 @@ describe TextSentinel do
|
||||
context 'body_sentinel' do
|
||||
|
||||
it "uses a sensible min entropy value when min body length is less than min entropy" do
|
||||
SiteSetting.stubs(:min_post_length).returns(3)
|
||||
SiteSetting.stubs(:body_min_entropy).returns(7)
|
||||
SiteSetting.min_post_length = 3
|
||||
SiteSetting.body_min_entropy = 7
|
||||
expect(TextSentinel.body_sentinel('Yup')).to be_valid
|
||||
end
|
||||
|
||||
it "uses a sensible min entropy value when min pm body length is less than min entropy" do
|
||||
SiteSetting.stubs(:min_post_length).returns(5)
|
||||
SiteSetting.stubs(:min_private_message_post_length).returns(3)
|
||||
SiteSetting.stubs(:body_min_entropy).returns(7)
|
||||
SiteSetting.min_post_length = 5
|
||||
SiteSetting.min_private_message_post_length = 3
|
||||
SiteSetting.body_min_entropy = 7
|
||||
expect(TextSentinel.body_sentinel('Lol', private_message: true)).to be_valid
|
||||
end
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ describe TopicCreator do
|
||||
before do
|
||||
TopicCreator.any_instance.expects(:save_topic).returns(true)
|
||||
TopicCreator.any_instance.expects(:watch_topic).returns(true)
|
||||
SiteSetting.stubs(:allow_duplicate_topic_titles?).returns(true)
|
||||
SiteSetting.allow_duplicate_topic_titles = true
|
||||
end
|
||||
|
||||
it "should be possible for an admin to create a topic" do
|
||||
@ -26,7 +26,7 @@ describe TopicCreator do
|
||||
end
|
||||
|
||||
context 'regular user' do
|
||||
before { SiteSetting.stubs(:min_trust_to_create_topic).returns(TrustLevel[0]) }
|
||||
before { SiteSetting.min_trust_to_create_topic = TrustLevel[0] }
|
||||
|
||||
it "should be possible for a regular user to create a topic" do
|
||||
expect(TopicCreator.create(user, Guardian.new(user), valid_attrs)).to be_valid
|
||||
@ -57,7 +57,7 @@ describe TopicCreator do
|
||||
before do
|
||||
TopicCreator.any_instance.expects(:save_topic).returns(true)
|
||||
TopicCreator.any_instance.expects(:watch_topic).returns(true)
|
||||
SiteSetting.stubs(:allow_duplicate_topic_titles?).returns(true)
|
||||
SiteSetting.allow_duplicate_topic_titles = true
|
||||
end
|
||||
|
||||
it "should be possible for a regular user to send private message" do
|
||||
|
@ -19,7 +19,7 @@ describe PasswordValidator do
|
||||
end
|
||||
|
||||
context "min password length is 8" do
|
||||
before { SiteSetting.stubs(:min_password_length).returns(8) }
|
||||
before { SiteSetting.min_password_length = 8 }
|
||||
|
||||
it "doesn't add an error when password is good" do
|
||||
@password = "weron235alsfn234"
|
||||
@ -56,7 +56,7 @@ describe PasswordValidator do
|
||||
end
|
||||
|
||||
context "min password length is 12" do
|
||||
before { SiteSetting.stubs(:min_password_length).returns(12) }
|
||||
before { SiteSetting.min_password_length = 12 }
|
||||
|
||||
it "adds an error when password length is 11" do
|
||||
@password = "gt38sdt92bv"
|
||||
@ -68,19 +68,19 @@ describe PasswordValidator do
|
||||
|
||||
context "password is commonly used" do
|
||||
before do
|
||||
SiteSetting.stubs(:min_password_length).returns(8)
|
||||
SiteSetting.min_password_length = 8
|
||||
CommonPasswords.stubs(:common_password?).returns(true)
|
||||
end
|
||||
|
||||
it "adds an error when block_common_passwords is enabled" do
|
||||
SiteSetting.stubs(:block_common_passwords).returns(true)
|
||||
SiteSetting.block_common_passwords = true
|
||||
@password = "password"
|
||||
validate
|
||||
expect(record.errors[:password]).to include(password_error_message(:common))
|
||||
end
|
||||
|
||||
it "doesn't add an error when block_common_passwords is disabled" do
|
||||
SiteSetting.stubs(:block_common_passwords).returns(false)
|
||||
SiteSetting.block_common_passwords = false
|
||||
@password = "password"
|
||||
validate
|
||||
expect(record.errors[:password]).not_to be_present
|
||||
|
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
require_dependency 'validators/post_validator'
|
||||
|
||||
describe Validators::PostValidator do
|
||||
let(:post) { build(:post) }
|
||||
let(:post) { build(:post, topic: Fabricate(:topic)) }
|
||||
let(:validator) { Validators::PostValidator.new({}) }
|
||||
|
||||
context "#post_body_validator" do
|
||||
@ -144,7 +144,7 @@ describe Validators::PostValidator do
|
||||
|
||||
describe "unique_post_validator" do
|
||||
before do
|
||||
SiteSetting.stubs(:unique_posts_mins).returns(5)
|
||||
SiteSetting.unique_posts_mins = 5
|
||||
end
|
||||
|
||||
context "post is unique" do
|
||||
@ -193,7 +193,7 @@ describe Validators::PostValidator do
|
||||
context "admin editing a static page" do
|
||||
before do
|
||||
post.acting_user = build(:admin)
|
||||
SiteSetting.stubs(:tos_topic_id).returns(post.topic_id)
|
||||
SiteSetting.tos_topic_id = post.topic_id
|
||||
end
|
||||
|
||||
include_examples "almost no validations"
|
||||
|
@ -39,7 +39,7 @@ describe TopicTitleLengthValidator do
|
||||
validate
|
||||
expect(record.errors[:title]).to_not be_present
|
||||
|
||||
SiteSetting.stubs(:min_topic_title_length).returns(2)
|
||||
SiteSetting.min_topic_title_length = 2
|
||||
|
||||
record.title = 'aaa'
|
||||
validate
|
||||
|
@ -6,7 +6,7 @@ describe UserFullNameValidator do
|
||||
let(:record) { Fabricate.build(:user, name: @name) }
|
||||
|
||||
context "name not required" do
|
||||
before { SiteSetting.stubs(:full_name_required).returns(false) }
|
||||
before { SiteSetting.full_name_required = false }
|
||||
|
||||
it "allows no name" do
|
||||
@name = nil
|
||||
@ -22,7 +22,7 @@ describe UserFullNameValidator do
|
||||
end
|
||||
|
||||
context "name required" do
|
||||
before { SiteSetting.stubs(:full_name_required).returns(true) }
|
||||
before { SiteSetting.full_name_required = true }
|
||||
|
||||
it "adds error for nil name" do
|
||||
@name = nil
|
||||
|
Reference in New Issue
Block a user