Isolate SITE_CONFIG in tests using minitest-stub-const

This commit is contained in:
Dan Rice 2016-05-22 16:21:00 -04:00
parent 3de582f436
commit 58e2b82315
6 changed files with 130 additions and 96 deletions

View file

@ -1,6 +1,8 @@
require 'test_helper'
require 'support/stub_site_config_helper'
class StoriesTest < ActionDispatch::IntegrationTest
include StubSiteConfigHelper
# ####################################################
# Testing login and signup by different kinds of users
@ -14,23 +16,27 @@ class StoriesTest < ActionDispatch::IntegrationTest
end
def test_signup_new_user_by_nonadmin
SITE_CONFIG['open_signups'] = false
other_user = new_session_as(:other_user,"sesame")
other_user.goes_to_signup_as_nonadmin
stub_site_config do
SITE_CONFIG['open_signups'] = false
other_user = new_session_as(:other_user,"sesame")
other_user.goes_to_signup_as_nonadmin
end
end
def test_open_signup_new_user
SITE_CONFIG['open_signups'] = true
get "/signup"
assert_response :success
assert_template "users/new"
post "/users", :user => {:login => "newbie",
:password => "newbiepass",
:password_confirmation => "newbiepass"}
assert_response :redirect
follow_redirect!
assert_response :success
assert_template "todos/index"
stub_site_config do
SITE_CONFIG['open_signups'] = true
get "/signup"
assert_response :success
assert_template "users/new"
post "/users", :user => {:login => "newbie",
:password => "newbiepass",
:password_confirmation => "newbiepass"}
assert_response :redirect
follow_redirect!
assert_response :success
assert_template "todos/index"
end
end
private