summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-12-17 10:36:13 +0100
committerAzul <azul@leap.se>2012-12-17 10:36:13 +0100
commitd64ab283b7bce0d296bb743f030c5361af663456 (patch)
treed3979c63f555e7076799f9fd0277c72ca5a8d01e /users
parent842845abffda2cf9abe38bac48d5c4b7cf3714b5 (diff)
parentff9d29df260b29a1c20441e25e2fc3fdf9ee1fb3 (diff)
Merge branch 'master' into develop
Diffstat (limited to 'users')
-rw-r--r--users/app/controllers/sessions_controller.rb1
-rw-r--r--users/app/controllers/v1/sessions_controller.rb1
-rw-r--r--users/test/functional/users_controller_test.rb14
-rw-r--r--users/test/integration/api/account_flow_test.rb8
-rw-r--r--users/test/support/auth_test_helper.rb3
-rw-r--r--users/test/support/stub_record_helper.rb4
6 files changed, 25 insertions, 6 deletions
diff --git a/users/app/controllers/sessions_controller.rb b/users/app/controllers/sessions_controller.rb
index bc910b5..0345fbd 100644
--- a/users/app/controllers/sessions_controller.rb
+++ b/users/app/controllers/sessions_controller.rb
@@ -11,6 +11,7 @@ class SessionsController < ApplicationController
end
def create
+ logout if logged_in?
authenticate!
end
diff --git a/users/app/controllers/v1/sessions_controller.rb b/users/app/controllers/v1/sessions_controller.rb
index 5b4a13b..27d10fb 100644
--- a/users/app/controllers/v1/sessions_controller.rb
+++ b/users/app/controllers/v1/sessions_controller.rb
@@ -12,6 +12,7 @@ module V1
end
def create
+ logout if logged_in?
authenticate!
end
diff --git a/users/test/functional/users_controller_test.rb b/users/test/functional/users_controller_test.rb
index 1840a72..ce17500 100644
--- a/users/test/functional/users_controller_test.rb
+++ b/users/test/functional/users_controller_test.rb
@@ -1,7 +1,6 @@
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
- include StubRecordHelper
test "should get new" do
get :new
@@ -35,7 +34,10 @@ class UsersControllerTest < ActionController::TestCase
end
test "should get edit view" do
- user = find_record User, :email => nil, :email_forward => nil
+ user = find_record User,
+ :email => nil,
+ :email_forward => nil,
+ :email_aliases => []
login user
get :edit, :id => user.id
@@ -45,7 +47,9 @@ class UsersControllerTest < ActionController::TestCase
test "should process updated params" do
user = find_record User
- user.expects(:update_attributes).with(user.params).returns(true)
+ user.expects(:attributes=).with(user.params)
+ user.expects(:changed?).returns(true)
+ user.expects(:save).returns(true)
login user
put :update, :user => user.params, :id => user.id, :format => :json
@@ -57,7 +61,9 @@ class UsersControllerTest < ActionController::TestCase
test "admin can update user" do
user = find_record User
- user.expects(:update_attributes).with(user.params).returns(true)
+ user.expects(:attributes=).with(user.params)
+ user.expects(:changed?).returns(true)
+ user.expects(:save).returns(true)
login :is_admin? => true
put :update, :user => user.params, :id => user.id, :format => :json
diff --git a/users/test/integration/api/account_flow_test.rb b/users/test/integration/api/account_flow_test.rb
index e425c35..7636f2b 100644
--- a/users/test/integration/api/account_flow_test.rb
+++ b/users/test/integration/api/account_flow_test.rb
@@ -62,6 +62,14 @@ class AccountFlowTest < ActiveSupport::TestCase
assert server_auth["M2"]
end
+ test "duplicate login does not break things" do
+ server_auth = @srp.authenticate(self)
+ server_auth = @srp.authenticate(self)
+ assert last_response.successful?
+ assert_nil server_auth["errors"]
+ assert server_auth["M2"]
+ end
+
test "signup and wrong password login attempt" do
srp = SRP::Client.new(@login, "wrong password")
server_auth = srp.authenticate(self)
diff --git a/users/test/support/auth_test_helper.rb b/users/test/support/auth_test_helper.rb
index 6a82f24..c9f5612 100644
--- a/users/test/support/auth_test_helper.rb
+++ b/users/test/support/auth_test_helper.rb
@@ -1,5 +1,4 @@
module AuthTestHelper
- include StubRecordHelper
extend ActiveSupport::Concern
# Controller will fetch current user from warden.
@@ -24,7 +23,7 @@ module AuthTestHelper
assert_equal({:alert => "Not authorized"}, flash.to_hash)
# todo: eventually probably eliminate separate conditions
assert_redirected_to login_path if !logged_in
- assert_redirected_to root_path if logged_in
+ assert_redirected_to root_path if logged_in
else
assert flash[:alert].blank?
end
diff --git a/users/test/support/stub_record_helper.rb b/users/test/support/stub_record_helper.rb
index 2e1a533..1be419a 100644
--- a/users/test/support/stub_record_helper.rb
+++ b/users/test/support/stub_record_helper.rb
@@ -39,3 +39,7 @@ module StubRecordHelper
end
end
+
+class ActionController::TestCase
+ include StubRecordHelper
+end