summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-28 11:44:12 +0200
committerAzul <azul@leap.se>2014-05-28 11:44:12 +0200
commit682b4060cb86c52ffda638f4f9a837f107540610 (patch)
tree5c5158707825d6461efa8404dfed73b237833c8b
parent5c8ab9298cc4705de508a3f3f9d9d6370a01ff5e (diff)
ensure identity is cleared on user.reload - fixes test
-rw-r--r--app/models/pgp_key.rb3
-rw-r--r--app/models/user.rb5
-rw-r--r--test/integration/browser/account_test.rb3
3 files changed, 9 insertions, 2 deletions
diff --git a/app/models/pgp_key.rb b/app/models/pgp_key.rb
index 66f8660..3384f4c 100644
--- a/app/models/pgp_key.rb
+++ b/app/models/pgp_key.rb
@@ -25,9 +25,10 @@ class PgpKey
# allow comparison with plain keyblock strings.
def ==(other)
+ return false if (self.present? != other.present?)
self.equal?(other) or
# relax the comparison on line ends.
- self.to_s.tr_s("\n\r", '') == other.tr_s("\r\n", '')
+ self.to_s.tr_s("\n\r", '') == other.tr_s("\n\r", '')
end
protected
diff --git a/app/models/user.rb b/app/models/user.rb
index 6b4d1a9..33508b5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -42,6 +42,11 @@ class User < CouchRest::Model::Base
view :by_created_at
end # end of design
+ def reload
+ super
+ @identity = nil
+ end
+
def to_json(options={})
{
:login => login,
diff --git a/test/integration/browser/account_test.rb b/test/integration/browser/account_test.rb
index 82bb043..8e6d433 100644
--- a/test/integration/browser/account_test.rb
+++ b/test/integration/browser/account_test.rb
@@ -109,7 +109,8 @@ class AccountTest < BrowserIntegrationTest
# at some point we're done:
page.assert_no_selector 'input[value="Saving..."]'
assert page.has_field? 'Public key', with: pgp_key.to_s
- assert_equal pgp_key, @user.reload.public_key
+ @user.reload
+ assert_equal pgp_key, @user.public_key
end
end