aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-06-20 10:11:31 +0100
committerSeb Bacon <seb.bacon@gmail.com>2012-06-20 10:11:31 +0100
commit312d52b90edb94befceac92a8b75f42b912b4132 (patch)
treef2c656648d7f8eecee5e28e217720b95e26e1a6b
parent6911d79f14386c0d30c5e4512746def39a6712be (diff)
parent08dac0261325cd757b7146f9626f3c7b48cc672c (diff)
Merge branch 'release/0.6' into wdtk
-rw-r--r--app/models/user.rb5
-rw-r--r--lib/quiet_opener.rb2
-rw-r--r--spec/controllers/request_controller_spec.rb8
3 files changed, 11 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 573649b8f..a21676f68 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -438,8 +438,9 @@ class User < ActiveRecord::Base
after_save(:purge_in_cache)
def purge_in_cache
- # XXX should only be if specific attributes have changed
- self.info_requests.each {|x| x.purge_in_cache}
+ if self.name_changed?
+ self.info_requests.each {|x| x.purge_in_cache}
+ end
end
end
diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb
index f313b303c..cb8cf0619 100644
--- a/lib/quiet_opener.rb
+++ b/lib/quiet_opener.rb
@@ -27,7 +27,7 @@ def quietly_try_to_purge(host, url)
Rails.logger.warn("PURGE: Unable to reach host #{host}")
end
if result == "200"
- Rails.logger.info("PURGE: Purged URL #{url} at #{host}: #{result}")
+ Rails.logger.debug("PURGE: Purged URL #{url} at #{host}: #{result}")
else
Rails.logger.warn("PURGE: Unable to purge URL #{url} at #{host}: status #{result}")
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 99ab4cc71..01a663bf8 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -156,12 +156,18 @@ describe RequestController, "when changing things that appear on the request pag
ir.public_body.save!
PurgeRequest.all().map{|x| x.model_id}.should =~ ir.public_body.info_requests.map{|x| x.id}
end
- it "should purge the downstream cache when the user details are changed" do
+ it "should purge the downstream cache when the user name is changed" do
ir = info_requests(:fancy_dog_request)
ir.user.name = "Something new"
ir.user.save!
PurgeRequest.all().map{|x| x.model_id}.should =~ ir.user.info_requests.map{|x| x.id}
end
+ it "should not purge the downstream cache when non-visible user details are changed" do
+ ir = info_requests(:fancy_dog_request)
+ ir.user.hashed_password = "some old hash"
+ ir.user.save!
+ PurgeRequest.all().count.should == 0
+ end
it "should purge the downstream cache when censor rules have changed" do
# XXX really, CensorRules should execute expiry logic as part
# of the after_save of the model. Currently this is part of