Commit f252867ce9f43718acaa7e3ede1b37e19d3f871b
1 parent
20018afb
Exists in
multi_env_on_remote_user
Adding tests for multi env remote user
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
1 changed file
with
26 additions
and
0 deletions
Show diff stats
plugins/remote_user/test/functional/remote_user_plugin_test.rb
| @@ -6,6 +6,10 @@ class AccountControllerTest < ActionController::TestCase | @@ -6,6 +6,10 @@ class AccountControllerTest < ActionController::TestCase | ||
| 6 | @environment.enabled_plugins = ['RemoteUserPlugin'] | 6 | @environment.enabled_plugins = ['RemoteUserPlugin'] |
| 7 | @environment.save | 7 | @environment.save |
| 8 | 8 | ||
| 9 | + @another_environment = Environment.new(name: "AnotherEnvironment") | ||
| 10 | + @another_environment.enabled_plugins = ['RemoteUserPlugin'] | ||
| 11 | + @another_environment.save | ||
| 12 | + | ||
| 9 | @controller = AccountController.new | 13 | @controller = AccountController.new |
| 10 | @request = ActionController::TestRequest.new | 14 | @request = ActionController::TestRequest.new |
| 11 | @response = ActionController::TestResponse.new | 15 | @response = ActionController::TestResponse.new |
| @@ -136,4 +140,26 @@ class AccountControllerTest < ActionController::TestCase | @@ -136,4 +140,26 @@ class AccountControllerTest < ActionController::TestCase | ||
| 136 | assert session[:user].blank? | 140 | assert session[:user].blank? |
| 137 | assert_response 404 | 141 | assert_response 404 |
| 138 | end | 142 | end |
| 143 | + | ||
| 144 | + should "create an user in the correct environment" do | ||
| 145 | + @controller.stubs(:environment).returns(@another_environment) | ||
| 146 | + @request.env["HTTP_REMOTE_USER"] = "testuser" | ||
| 147 | + | ||
| 148 | + get :index | ||
| 149 | + user = User.last | ||
| 150 | + assert_equal user.environment, @another_environment | ||
| 151 | + end | ||
| 152 | + | ||
| 153 | + should "create an user in both environments" do | ||
| 154 | + user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test') | ||
| 155 | + @controller.stubs(:environment).returns(@another_environment) | ||
| 156 | + @request.env["HTTP_REMOTE_USER"] = "testuser" | ||
| 157 | + | ||
| 158 | + users = User.where(:login => 'testuser') | ||
| 159 | + assert_equal users.count, 1 | ||
| 160 | + | ||
| 161 | + get :index | ||
| 162 | + users = User.where(:login => 'testuser') | ||
| 163 | + assert_equal users.count, 2 | ||
| 164 | + end | ||
| 139 | end | 165 | end |