Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sessions/new also responds to xml and json now

  • Loading branch information...
commit 4a4dcb30ef0d58ac01f581bbf5af7f299c2ca2d3 1 parent 2cfa58b
@josevalim josevalim authored
View
15 app/controllers/devise/sessions_controller.rb
@@ -4,8 +4,9 @@ class Devise::SessionsController < ApplicationController
# GET /resource/sign_in
def new
- clean_up_passwords(build_resource)
- render_with_scope :new
+ resource = build_resource
+ clean_up_passwords(resource)
+ respond_with_navigational(resource, stub_options(resource)){ render_with_scope :new }
end
# POST /resource/sign_in
@@ -33,4 +34,12 @@ def destroy
end
end
end
-end
+
+ protected
+
+ def stub_options(resource)
+ hash = { :only => resource_class.authentication_keys }
+ hash[:methods] = [:password] if resource.respond_to?(:password)
+ hash
+ end
+end
View
2  lib/devise/models/database_authenticatable.rb
@@ -41,7 +41,7 @@ def valid_password?(password)
# Set password and password confirmation to nil
def clean_up_passwords
- self.password = self.password_confirmation = nil
+ self.password = self.password_confirmation = ""
end
# Update record attributes when :current_password matches, otherwise returns
View
12 test/integration/authenticatable_test.rb
@@ -336,10 +336,14 @@ class AuthenticationOthersTest < ActionController::IntegrationTest
end
end
- test 'registration in xml format works when recognizing path' do
- assert_nothing_raised do
- post user_registration_path(:format => 'xml', :user => {:email => "test@example.com", :password => "invalid"} )
- end
+ test 'sign in stub in xml format' do
+ get new_user_session_path(:format => 'xml')
+ assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>\n <email></email>\n <password></password>\n</user>\n", response.body
+ end
+
+ test 'sign in stub in json format' do
+ get new_user_session_path(:format => 'json')
+ assert_equal "{\"user\":{\"password\":\"\",\"email\":\"\"}}", response.body
end
test 'uses the mapping from router' do

0 comments on commit 4a4dcb3

Please sign in to comment.
Something went wrong with that request. Please try again.