Reset dynamic configuration after each example in the testsuite
This commit is contained in:
parent
7d656d32de
commit
eac3f042a4
11 changed files with 28 additions and 62 deletions
3
Gemfile
3
Gemfile
|
|
@ -38,7 +38,7 @@ gem 'uglifier', '2.5.3'
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
gem 'configurate', '0.1.0'
|
gem 'configurate', '0.2.0'
|
||||||
|
|
||||||
# Cross-origin resource sharing
|
# Cross-origin resource sharing
|
||||||
|
|
||||||
|
|
@ -193,6 +193,7 @@ group :development do
|
||||||
# Debugging
|
# Debugging
|
||||||
gem 'pry'
|
gem 'pry'
|
||||||
gem 'pry-debundle'
|
gem 'pry-debundle'
|
||||||
|
gem 'pry-byebug'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|
|
||||||
14
Gemfile.lock
14
Gemfile.lock
|
|
@ -63,6 +63,10 @@ GEM
|
||||||
bootstrap-sass (2.3.2.2)
|
bootstrap-sass (2.3.2.2)
|
||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
|
byebug (3.5.1)
|
||||||
|
columnize (~> 0.8)
|
||||||
|
debugger-linecache (~> 1.2)
|
||||||
|
slop (~> 3.6)
|
||||||
capybara (2.4.1)
|
capybara (2.4.1)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
|
|
@ -87,13 +91,14 @@ GEM
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.8.0)
|
coffee-script-source (1.8.0)
|
||||||
|
columnize (0.8.9)
|
||||||
compass (0.12.7)
|
compass (0.12.7)
|
||||||
chunky_png (~> 1.2)
|
chunky_png (~> 1.2)
|
||||||
fssm (>= 0.2.7)
|
fssm (>= 0.2.7)
|
||||||
sass (~> 3.2.19)
|
sass (~> 3.2.19)
|
||||||
compass-rails (2.0.0)
|
compass-rails (2.0.0)
|
||||||
compass (>= 0.12.2)
|
compass (>= 0.12.2)
|
||||||
configurate (0.1.0)
|
configurate (0.2.0)
|
||||||
connection_pool (2.0.0)
|
connection_pool (2.0.0)
|
||||||
crack (0.4.2)
|
crack (0.4.2)
|
||||||
safe_yaml (~> 1.0.0)
|
safe_yaml (~> 1.0.0)
|
||||||
|
|
@ -110,6 +115,7 @@ GEM
|
||||||
nokogiri (~> 1.5)
|
nokogiri (~> 1.5)
|
||||||
rails (>= 3, < 5)
|
rails (>= 3, < 5)
|
||||||
database_cleaner (1.3.0)
|
database_cleaner (1.3.0)
|
||||||
|
debugger-linecache (1.2.0)
|
||||||
devise (3.3.0)
|
devise (3.3.0)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
|
|
@ -317,6 +323,9 @@ GEM
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
method_source (~> 0.8.1)
|
method_source (~> 0.8.1)
|
||||||
slop (~> 3.4)
|
slop (~> 3.4)
|
||||||
|
pry-byebug (2.0.0)
|
||||||
|
byebug (~> 3.4)
|
||||||
|
pry (~> 0.10)
|
||||||
pry-debundle (0.8)
|
pry-debundle (0.8)
|
||||||
pry
|
pry
|
||||||
rack (1.5.2)
|
rack (1.5.2)
|
||||||
|
|
@ -514,7 +523,7 @@ DEPENDENCIES
|
||||||
capybara (= 2.4.1)
|
capybara (= 2.4.1)
|
||||||
carrierwave (= 0.10.0)
|
carrierwave (= 0.10.0)
|
||||||
compass-rails (= 2.0.0)
|
compass-rails (= 2.0.0)
|
||||||
configurate (= 0.1.0)
|
configurate (= 0.2.0)
|
||||||
cucumber-rails (= 1.4.1)
|
cucumber-rails (= 1.4.1)
|
||||||
database_cleaner (= 1.3.0)
|
database_cleaner (= 1.3.0)
|
||||||
devise (= 3.3.0)
|
devise (= 3.3.0)
|
||||||
|
|
@ -555,6 +564,7 @@ DEPENDENCIES
|
||||||
omniauth-wordpress (= 0.2.1)
|
omniauth-wordpress (= 0.2.1)
|
||||||
opengraph_parser (= 0.2.3)
|
opengraph_parser (= 0.2.3)
|
||||||
pry
|
pry
|
||||||
|
pry-byebug
|
||||||
pry-debundle
|
pry-debundle
|
||||||
rack-cors (= 0.2.9)
|
rack-cors (= 0.2.9)
|
||||||
rack-google-analytics (= 1.2.0)
|
rack-google-analytics (= 1.2.0)
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,4 @@ SimpleCaptcha.setup do |sc|
|
||||||
sc.length = [1, [AppConfig.settings.captcha_length.to_i, 12].min].max
|
sc.length = [1, [AppConfig.settings.captcha_length.to_i, 12].min].max
|
||||||
sc.image_style = AppConfig.settings.captcha.image_style
|
sc.image_style = AppConfig.settings.captcha.image_style
|
||||||
sc.distortion = AppConfig.settings.captcha.distortion
|
sc.distortion = AppConfig.settings.captcha.distortion
|
||||||
p AppConfig.settings.captcha
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -119,12 +119,10 @@ describe InvitationsController, :type => :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects if invitations are closed' do
|
it 'redirects if invitations are closed' do
|
||||||
open_bit = AppConfig.settings.invitations.open?
|
|
||||||
AppConfig.settings.invitations.open = false
|
AppConfig.settings.invitations.open = false
|
||||||
|
|
||||||
post :create, @invite
|
post :create, @invite
|
||||||
expect(response).to be_redirect
|
expect(response).to be_redirect
|
||||||
AppConfig.settings.invitations.open = open_bit
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,6 @@ describe RegistrationsController, :type => :controller do
|
||||||
AppConfig.settings.enable_registrations = false
|
AppConfig.settings.enable_registrations = false
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
AppConfig.settings.enable_registrations = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects #new to the login page' do
|
it 'redirects #new to the login page' do
|
||||||
get :new
|
get :new
|
||||||
expect(flash[:error]).to eq(I18n.t('registrations.closed'))
|
expect(flash[:error]).to eq(I18n.t('registrations.closed'))
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ describe ApplicationHelper, :type => :helper do
|
||||||
|
|
||||||
describe "#all_services_connected?" do
|
describe "#all_services_connected?" do
|
||||||
before do
|
before do
|
||||||
@old_configured_services = AppConfig.configured_services
|
|
||||||
AppConfig.configured_services = [1, 2, 3]
|
AppConfig.configured_services = [1, 2, 3]
|
||||||
|
|
||||||
def current_user
|
def current_user
|
||||||
|
|
@ -40,7 +39,7 @@ describe ApplicationHelper, :type => :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
AppConfig.configured_services = @old_configured_services
|
AppConfig.configured_services = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns true if all networks are connected' do
|
it 'returns true if all networks are connected' do
|
||||||
|
|
@ -91,17 +90,13 @@ describe ApplicationHelper, :type => :helper do
|
||||||
|
|
||||||
describe '#changelog_url' do
|
describe '#changelog_url' do
|
||||||
it 'defaults to master branch changleog' do
|
it 'defaults to master branch changleog' do
|
||||||
old_revision = AppConfig.git_revision
|
|
||||||
AppConfig.git_revision = nil
|
AppConfig.git_revision = nil
|
||||||
expect(changelog_url).to eq('https://github.com/diaspora/diaspora/blob/master/Changelog.md')
|
expect(changelog_url).to eq('https://github.com/diaspora/diaspora/blob/master/Changelog.md')
|
||||||
AppConfig.git_revision = old_revision
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays the changelog for the current git revision if set' do
|
it 'displays the changelog for the current git revision if set' do
|
||||||
old_revision = AppConfig.git_revision
|
|
||||||
AppConfig.git_revision = '123'
|
AppConfig.git_revision = '123'
|
||||||
expect(changelog_url).to eq('https://github.com/diaspora/diaspora/blob/123/Changelog.md')
|
expect(changelog_url).to eq('https://github.com/diaspora/diaspora/blob/123/Changelog.md')
|
||||||
AppConfig.git_revision = old_revision
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -112,20 +107,16 @@ describe ApplicationHelper, :type => :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays the supplied pod_name if it is set' do
|
it 'displays the supplied pod_name if it is set' do
|
||||||
old_name = AppConfig.settings.pod_name.get
|
|
||||||
AppConfig.settings.pod_name = "Catspora"
|
AppConfig.settings.pod_name = "Catspora"
|
||||||
|
# require 'pry'; binding.pry
|
||||||
expect(pod_name).to match "Catspora"
|
expect(pod_name).to match "Catspora"
|
||||||
AppConfig.settings.pod_name = old_name
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#pod_version' do
|
describe '#pod_version' do
|
||||||
|
|
||||||
it 'displays the supplied pod_version if it is set' do
|
it 'displays the supplied pod_version if it is set' do
|
||||||
old_version = AppConfig.version.number.get
|
|
||||||
AppConfig.version.number = "0.0.1.0"
|
AppConfig.version.number = "0.0.1.0"
|
||||||
expect(pod_version).to match "0.0.1.0"
|
expect(pod_version).to match "0.0.1.0"
|
||||||
AppConfig.version.number = old_version
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,14 @@ describe RakeHelpers do
|
||||||
before do
|
before do
|
||||||
@csv = Rails.root.join('spec', 'fixtures', 'test.csv')
|
@csv = Rails.root.join('spec', 'fixtures', 'test.csv')
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#process_emails' do
|
describe '#process_emails' do
|
||||||
before do
|
before do
|
||||||
Devise.mailer.deliveries = []
|
Devise.mailer.deliveries = []
|
||||||
@old_admin = AppConfig.admins.account.get
|
|
||||||
AppConfig.admins.account = FactoryGirl.create(:user).username
|
AppConfig.admins.account = FactoryGirl.create(:user).username
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
AppConfig.admins.account = @old_admin
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should send emails to each email' do
|
it 'should send emails to each email' do
|
||||||
|
|
||||||
expect(EmailInviter).to receive(:new).exactly(3).times.and_return(double.as_null_object)
|
expect(EmailInviter).to receive(:new).exactly(3).times.and_return(double.as_null_object)
|
||||||
process_emails(@csv, 100, 1, false)
|
process_emails(@csv, 100, 1, false)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,8 @@ describe InvitationCode, :type => :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.default_inviter_or' do
|
describe '.default_inviter_or' do
|
||||||
before do
|
|
||||||
@old_account = AppConfig.admins.account.get
|
|
||||||
AppConfig.admins.account = 'bob'
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
AppConfig.admins.account = @old_account
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'grabs the set admin account for the pod...' do
|
it 'grabs the set admin account for the pod...' do
|
||||||
|
AppConfig.admins.account = 'bob'
|
||||||
expect(InvitationCode.default_inviter_or(alice).username).to eq('bob')
|
expect(InvitationCode.default_inviter_or(alice).username).to eq('bob')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -896,16 +896,6 @@ describe User, :type => :model do
|
||||||
FactoryGirl.create(:user)
|
FactoryGirl.create(:user)
|
||||||
}
|
}
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
@old_autofollow_value = AppConfig.settings.autofollow_on_join?
|
|
||||||
@old_autofollow_user = AppConfig.settings.autofollow_on_join_user
|
|
||||||
end
|
|
||||||
|
|
||||||
after(:each) do
|
|
||||||
AppConfig.settings.autofollow_on_join = @old_followhq_value
|
|
||||||
AppConfig.settings.autofollow_on_join_user = @old_autofollow_user
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with autofollow sharing enabled" do
|
context "with autofollow sharing enabled" do
|
||||||
it "should start sharing with autofollow account" do
|
it "should start sharing with autofollow account" do
|
||||||
AppConfig.settings.autofollow_on_join = true
|
AppConfig.settings.autofollow_on_join = true
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,6 @@ describe StatisticsPresenter do
|
||||||
AppConfig.privacy.statistics.comment_counts = false
|
AppConfig.privacy.statistics.comment_counts = false
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
AppConfig.privacy = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'provides generic pod data in json' do
|
it 'provides generic pod data in json' do
|
||||||
expect(@presenter.as_json).to eq({
|
expect(@presenter.as_json).to eq({
|
||||||
"name" => AppConfig.settings.pod_name,
|
"name" => AppConfig.settings.pod_name,
|
||||||
|
|
@ -48,11 +44,6 @@ describe StatisticsPresenter do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
AppConfig.services = nil
|
|
||||||
AppConfig.privacy = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'provides generic pod data and counts in json' do
|
it 'provides generic pod data and counts in json' do
|
||||||
expect(@presenter.as_json).to eq({
|
expect(@presenter.as_json).to eq({
|
||||||
"name" => AppConfig.settings.pod_name,
|
"name" => AppConfig.settings.pod_name,
|
||||||
|
|
@ -70,7 +61,5 @@ describe StatisticsPresenter do
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,11 @@ prefork = proc do
|
||||||
config.after(:all) do
|
config.after(:all) do
|
||||||
`rm -rf #{Rails.root}/tmp/uploads/*`
|
`rm -rf #{Rails.root}/tmp/uploads/*`
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Reset overridden settings
|
||||||
|
config.after(:each) do
|
||||||
|
AppConfig.reset_dynamic!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue