Permalink
Browse files

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).
  • Loading branch information...
1 parent eb7760b commit 268eae1013229fde1928eb3bdd9719253515e45e @carlosantoniodasilva carlosantoniodasilva committed Nov 26, 2010
Showing with 9 additions and 4 deletions.
  1. +3 −3 test/integration/http_authenticatable_test.rb
  2. +6 −1 test/rails_app/app/mongoid/shim.rb
@@ -56,19 +56,19 @@ 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")
user = create_user
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
@@ -17,8 +17,13 @@ def find_by_email(email)
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

0 comments on commit 268eae1

Please sign in to comment.