Commit eac3f042 authored by Jonne Haß's avatar Jonne Haß
Browse files

Reset dynamic configuration after each example in the testsuite

parent 7d656d32
......@@ -38,7 +38,7 @@ gem 'uglifier', '2.5.3'
# Configuration
gem 'configurate', '0.1.0'
gem 'configurate', '0.2.0'
# Cross-origin resource sharing
......@@ -193,6 +193,7 @@ group :development do
# Debugging
gem 'pry'
gem 'pry-debundle'
gem 'pry-byebug'
end
group :test do
......
......@@ -63,6 +63,10 @@ GEM
bootstrap-sass (2.3.2.2)
sass (~> 3.2)
builder (3.2.2)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
capybara (2.4.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
......@@ -87,13 +91,14 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.8.0)
columnize (0.8.9)
compass (0.12.7)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.2.19)
compass-rails (2.0.0)
compass (>= 0.12.2)
configurate (0.1.0)
configurate (0.2.0)
connection_pool (2.0.0)
crack (0.4.2)
safe_yaml (~> 1.0.0)
......@@ -110,6 +115,7 @@ GEM
nokogiri (~> 1.5)
rails (>= 3, < 5)
database_cleaner (1.3.0)
debugger-linecache (1.2.0)
devise (3.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
......@@ -317,6 +323,9 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (2.0.0)
byebug (~> 3.4)
pry (~> 0.10)
pry-debundle (0.8)
pry
rack (1.5.2)
......@@ -514,7 +523,7 @@ DEPENDENCIES
capybara (= 2.4.1)
carrierwave (= 0.10.0)
compass-rails (= 2.0.0)
configurate (= 0.1.0)
configurate (= 0.2.0)
cucumber-rails (= 1.4.1)
database_cleaner (= 1.3.0)
devise (= 3.3.0)
......@@ -555,6 +564,7 @@ DEPENDENCIES
omniauth-wordpress (= 0.2.1)
opengraph_parser (= 0.2.3)
pry
pry-byebug
pry-debundle
rack-cors (= 0.2.9)
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.image_style = AppConfig.settings.captcha.image_style
sc.distortion = AppConfig.settings.captcha.distortion
p AppConfig.settings.captcha
end
......@@ -119,12 +119,10 @@ describe InvitationsController, :type => :controller do
end
it 'redirects if invitations are closed' do
open_bit = AppConfig.settings.invitations.open?
AppConfig.settings.invitations.open = false
post :create, @invite
expect(response).to be_redirect
AppConfig.settings.invitations.open = open_bit
end
end
......
......@@ -24,10 +24,6 @@ describe RegistrationsController, :type => :controller do
AppConfig.settings.enable_registrations = false
end
after do
AppConfig.settings.enable_registrations = true
end
it 'redirects #new to the login page' do
get :new
expect(flash[:error]).to eq(I18n.t('registrations.closed'))
......@@ -54,7 +50,7 @@ describe RegistrationsController, :type => :controller do
describe "#create" do
render_views
context "with valid parameters" do
before do
AppConfig.settings.enable_registrations = true
......@@ -113,7 +109,7 @@ describe RegistrationsController, :type => :controller do
get :create, @invalid_params
expect(response).to render_template("registrations/new")
end
it "keeps invalid params in form" do
get :create, @invalid_params
expect(response.body).to match /jdoe@example.com/m
......
......@@ -30,7 +30,6 @@ describe ApplicationHelper, :type => :helper do
describe "#all_services_connected?" do
before do
@old_configured_services = AppConfig.configured_services
AppConfig.configured_services = [1, 2, 3]
def current_user
......@@ -40,7 +39,7 @@ describe ApplicationHelper, :type => :helper do
end
after do
AppConfig.configured_services = @old_configured_services
AppConfig.configured_services = nil
end
it 'returns true if all networks are connected' do
......@@ -91,17 +90,13 @@ describe ApplicationHelper, :type => :helper do
describe '#changelog_url' do
it 'defaults to master branch changleog' do
old_revision = AppConfig.git_revision
AppConfig.git_revision = nil
expect(changelog_url).to eq('https://github.com/diaspora/diaspora/blob/master/Changelog.md')
AppConfig.git_revision = old_revision
end
it 'displays the changelog for the current git revision if set' do
old_revision = AppConfig.git_revision
AppConfig.git_revision = '123'
expect(changelog_url).to eq('https://github.com/diaspora/diaspora/blob/123/Changelog.md')
AppConfig.git_revision = old_revision
end
end
......@@ -112,20 +107,16 @@ describe ApplicationHelper, :type => :helper do
end
it 'displays the supplied pod_name if it is set' do
old_name = AppConfig.settings.pod_name.get
AppConfig.settings.pod_name = "Catspora"
# require 'pry'; binding.pry
expect(pod_name).to match "Catspora"
AppConfig.settings.pod_name = old_name
end
end
describe '#pod_version' 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"
expect(pod_version).to match "0.0.1.0"
AppConfig.version.number = old_version
end
end
end
......@@ -10,19 +10,14 @@ describe RakeHelpers do
before do
@csv = Rails.root.join('spec', 'fixtures', 'test.csv')
end
describe '#process_emails' do
before do
Devise.mailer.deliveries = []
@old_admin = AppConfig.admins.account.get
AppConfig.admins.account = FactoryGirl.create(:user).username
end
after do
AppConfig.admins.account = @old_admin
end
it 'should send emails to each email' do
expect(EmailInviter).to receive(:new).exactly(3).times.and_return(double.as_null_object)
process_emails(@csv, 100, 1, false)
end
......
......@@ -7,7 +7,7 @@ describe InvitationCode, :type => :model do
it 'sets the count to a default value' do
code = FactoryGirl.create(:invitation_code)
expect(code.count).to be > 0
expect(code.count).to be > 0
end
describe '#use!' do
......@@ -21,16 +21,8 @@ describe InvitationCode, :type => :model do
end
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
AppConfig.admins.account = 'bob'
expect(InvitationCode.default_inviter_or(alice).username).to eq('bob')
end
......
......@@ -896,16 +896,6 @@ describe User, :type => :model do
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
it "should start sharing with autofollow account" do
AppConfig.settings.autofollow_on_join = true
......@@ -1005,7 +995,7 @@ describe User, :type => :model do
end
end
end
describe "sign up" do
before do
params = {:username => "ohai",
......@@ -1013,7 +1003,7 @@ describe User, :type => :model do
:password => "password",
:password_confirmation => "password",
:captcha => "12345",
:person =>
{:profile =>
{:first_name => "O",
......
......@@ -19,10 +19,6 @@ describe StatisticsPresenter do
AppConfig.privacy.statistics.comment_counts = false
end
after do
AppConfig.privacy = nil
end
it 'provides generic pod data in json' do
expect(@presenter.as_json).to eq({
"name" => AppConfig.settings.pod_name,
......@@ -48,11 +44,6 @@ describe StatisticsPresenter do
}
end
after do
AppConfig.services = nil
AppConfig.privacy = nil
end
it 'provides generic pod data and counts in json' do
expect(@presenter.as_json).to eq({
"name" => AppConfig.settings.pod_name,
......@@ -70,7 +61,5 @@ describe StatisticsPresenter do
})
end
end
end
end
......@@ -94,6 +94,11 @@ prefork = proc do
config.after(:all) do
`rm -rf #{Rails.root}/tmp/uploads/*`
end
# Reset overridden settings
config.after(:each) do
AppConfig.reset_dynamic!
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment