1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Add update_attribute method to Mongoid Shim for devise tests, to fix failing test

Mongoid does not have this method in the current beta version (2.0.0.beta.20).
This commit is contained in:
Carlos Antonio da Silva 2010-11-26 01:14:26 -02:00
parent eb7760b4b2
commit 268eae1013
2 changed files with 9 additions and 4 deletions

View file

@ -56,7 +56,7 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
assert_match "<email>user@test.com</email>", response.body
assert warden.authenticated?(:user)
end
private
def sign_in_as_new_user_with_http(username="user@test.com", password="123456")
@ -64,11 +64,11 @@ class HttpAuthenticationTest < ActionController::IntegrationTest
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
user
end
# Sign in with oauth2 token. This is just to test that it isn't misinterpreted as basic authentication
def add_oauth2_header
user = create_user
get users_path(:format => :xml), {}, "HTTP_AUTHORIZATION" => "OAuth #{ActiveSupport::Base64.encode64("#{user.email}:123456")}"
end
end
end

View file

@ -17,8 +17,13 @@ module Shim
end
end
# overwrite equality (because some devise tests use this for asserting model equality)
# overwrite equality (because some devise tests use this for asserting model equality)
def ==(other)
other.is_a?(self.class) && _id == other._id
end
# Mongoid does not have this method in the current beta version (2.0.0.beta.20)
def update_attribute(attribute, value)
update_attributes(attribute => value)
end
end