Remove site setting stubbing (Round 1)

This commit is contained in:
Arpit Jalan 2015-06-03 15:44:00 +05:30
parent 11619247b4
commit b33654ac31
6 changed files with 25 additions and 26 deletions

View File

@ -5,13 +5,13 @@ describe RobotsTxtController do
context '.index' do
it "returns index when indexing is allowed" do
SiteSetting.stubs(:allow_index_in_robots_txt).returns(true)
SiteSetting.allow_index_in_robots_txt = true
get :index
expect(response).to render_template :index
end
it "returns noindex when indexing is disallowed" do
SiteSetting.stubs(:allow_index_in_robots_txt).returns(false)
SiteSetting.allow_index_in_robots_txt = false
get :index
expect(response).to render_template :no_index
end

View File

@ -9,22 +9,22 @@ describe Jobs::PollFeed do
let(:embed_by_username) { "eviltrout" }
it "requires feed_polling_enabled?" do
SiteSetting.stubs(:feed_polling_enabled?).returns(true)
SiteSetting.stubs(:feed_polling_url).returns(nil)
SiteSetting.feed_polling_enabled = true
SiteSetting.feed_polling_url = nil
poller.expects(:poll_feed).never
poller.execute({})
end
it "requires feed_polling_url" do
SiteSetting.stubs(:feed_polling_enabled?).returns(false)
SiteSetting.stubs(:feed_polling_url).returns(nil)
SiteSetting.feed_polling_enabled = false
SiteSetting.feed_polling_url = nil
poller.expects(:poll_feed).never
poller.execute({})
end
it "delegates to poll_feed" do
SiteSetting.stubs(:feed_polling_enabled?).returns(true)
SiteSetting.stubs(:feed_polling_url).returns(url)
SiteSetting.feed_polling_enabled = true
SiteSetting.feed_polling_url = url
poller.expects(:poll_feed).once
poller.execute({})
end

View File

@ -4,7 +4,7 @@ describe VersionMailer do
subject { VersionMailer.send_notice }
context 'contact_email is blank' do
before { SiteSetting.stubs(:contact_email).returns('') }
before { SiteSetting.contact_email = '' }
it "doesn't send the email" do
expect(subject.to).to be_blank
@ -12,7 +12,7 @@ describe VersionMailer do
end
context 'contact_email is set' do
before { SiteSetting.stubs(:contact_email).returns('me@example.com') }
before { SiteSetting.contact_email = 'me@example.com' }
it "works" do
expect(subject.to).to eq(['me@example.com'])

View File

@ -135,8 +135,8 @@ describe AdminDashboardData do
describe 'favicon_url check' do
before do
SiteSetting.stubs(:logo_url).returns('/assets/my-logo.jpg')
SiteSetting.stubs(:logo_small_url).returns('/assets/my-small-logo.jpg')
SiteSetting.logo_url = '/assets/my-logo.jpg'
SiteSetting.logo_small_url = '/assets/my-small-logo.jpg'
end
it 'returns a string when favicon_url is default' do
@ -144,20 +144,20 @@ describe AdminDashboardData do
end
it 'returns a string when favicon_url contains default filename' do
SiteSetting.stubs(:favicon_url).returns("/prefix#{SiteSetting.defaults[:favicon_url]}")
SiteSetting.favicon_url = "/prefix#{SiteSetting.defaults[:favicon_url]}"
expect(subject).not_to be_nil
end
it 'returns nil when favicon_url does not match default-favicon.png' do
SiteSetting.stubs(:favicon_url).returns('/assets/my-favicon.png')
SiteSetting.favicon_url = '/assets/my-favicon.png'
expect(subject).to be_nil
end
end
describe 'logo_url check' do
before do
SiteSetting.stubs(:favicon_url).returns('/assets/my-favicon.png')
SiteSetting.stubs(:logo_small_url).returns('/assets/my-small-logo.jpg')
SiteSetting.favicon_url = '/assets/my-favicon.png'
SiteSetting.logo_small_url = '/assets/my-small-logo.jpg'
end
it 'returns a string when logo_url is default' do
@ -165,12 +165,12 @@ describe AdminDashboardData do
end
it 'returns a string when logo_url contains default filename' do
SiteSetting.stubs(:logo_url).returns("/prefix#{SiteSetting.defaults[:logo_url]}")
SiteSetting.logo_url = "/prefix#{SiteSetting.defaults[:logo_url]}"
expect(subject).not_to be_nil
end
it 'returns nil when logo_url does not match d-logo-sketch.png' do
SiteSetting.stubs(:logo_url).returns('/assets/my-logo.png')
SiteSetting.logo_url = '/assets/my-logo.png'
expect(subject).to be_nil
end
end

View File

@ -14,13 +14,13 @@ describe Backup do
context '#remove_old' do
it "does nothing if there aren't more backups than the setting" do
SiteSetting.stubs(:maximum_backups).returns(3)
SiteSetting.maximum_backups = 3
Backup.any_instance.expects(:remove).never
Backup.remove_old
end
it "calls remove on the backups over our limit" do
SiteSetting.stubs(:maximum_backups).returns(1)
SiteSetting.maximum_backups = 1
b1.expects(:remove).never
b2.expects(:remove).once
b3.expects(:remove).once
@ -30,13 +30,13 @@ describe Backup do
context ".after_create_hook" do
it "calls upload_to_s3 if the SiteSetting is true" do
SiteSetting.stubs(:enable_s3_backups?).returns(true)
SiteSetting.enable_s3_backups = true
b1.expects(:upload_to_s3).once
b1.after_create_hook
end
it "calls upload_to_s3 if the SiteSetting is false" do
SiteSetting.stubs(:enable_s3_backups?).returns(false)
SiteSetting.enable_s3_backups = false
b1.expects(:upload_to_s3).never
b1.after_create_hook
end
@ -44,17 +44,16 @@ describe Backup do
context ".after_remove_hook" do
it "calls remove_from_s3 if the SiteSetting is true" do
SiteSetting.stubs(:enable_s3_backups?).returns(true)
SiteSetting.enable_s3_backups = true
b1.expects(:remove_from_s3).once
b1.after_remove_hook
end
it "calls remove_from_s3 if the SiteSetting is false" do
SiteSetting.stubs(:enable_s3_backups?).returns(false)
SiteSetting.enable_s3_backups = false
b1.expects(:remove_from_s3).never
b1.after_remove_hook
end
end
end

View File

@ -57,7 +57,7 @@ describe Draft do
expect(Draft.count).to eq 1
# should cleanup drafts more than 180 days old
SiteSetting.stubs(:delete_drafts_older_than_n_days).returns(180)
SiteSetting.delete_drafts_older_than_n_days = 180
Draft.last.update_columns(updated_at: 200.days.ago)
Draft.cleanup!