aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/general_controller_spec.rb6
-rw-r--r--spec/controllers/public_body_controller_spec.rb5
-rw-r--r--spec/controllers/request_controller_spec.rb26
3 files changed, 26 insertions, 11 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index c4fd46c14..b067707de 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -115,9 +115,11 @@ describe GeneralController, "when searching" do
rebuild_xapian_index
end
- it 'should list the successful request first' do
+ it 'should list the newest successful request first' do
+ # Make sure the newest is listed first even if an older one has an even newer comment:
+ # https://github.com/sebbacon/alaveteli/issues/370
get :frontpage
- assigns[:request_events].first.info_request.should == info_requests(:boring_request)
+ assigns[:request_events].first.info_request.should == info_requests(:another_boring_request)
end
end
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 4b657849a..bd4e625ca 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -105,11 +105,14 @@ describe PublicBodyController, "when listing bodies" do
end
it "should list bodies in alphabetical order" do
+ # Note that they are alphabetised by localised name
get :list
response.should render_template('list')
- assigns[:public_bodies].should == PublicBody.all(:order => "name", :conditions => "id <> #{PublicBody.internal_admin_body.id}")
+ assigns[:public_bodies].should == PublicBody.all(
+ :conditions => "id <> #{PublicBody.internal_admin_body.id}",
+ :order => "(select name from public_body_translations where public_body_id=public_bodies.id and locale='en')")
assigns[:tag].should == "all"
assigns[:description].should == ""
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index a77d1ac27..bae1f32e7 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -39,6 +39,7 @@ describe RequestController, "when listing recent requests" do
from info_request_events later_events
where later_events.created_at > info_request_events.created_at
and later_events.info_request_id = info_request_events.info_request_id
+ and later_events.described_state is not null
)
and info_request_events.described_state in ('successful', 'partially_successful')
)")
@@ -219,9 +220,11 @@ describe RequestController, "when showing one request" do
get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
(assigns[:info_request_events].size - size_before).should == 1
ir.reload
+
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt']
response.content_type.should == "text/plain"
response.should have_text(/Second hello/)
+
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3, :file_name => ['hello.txt']
response.content_type.should == "text/plain"
response.should have_text(/First hello/)
@@ -350,12 +353,16 @@ describe RequestController, "when showing one request" do
censor_rule.last_edit_comment = "none"
ir.user.censor_rules << censor_rule
- receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
- ir.reload
+ begin
+ receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
+ ir.reload
- get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1
- response.content_type.should == "text/plain"
- response.should have_text(/xxxxxx hello/)
+ get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1
+ response.content_type.should == "text/plain"
+ response.should have_text(/xxxxxx hello/)
+ ensure
+ ir.user.censor_rules.clear
+ end
end
it "should censor attachment names" do
@@ -386,9 +393,12 @@ describe RequestController, "when showing one request" do
censor_rule.last_edit_editor = "unknown"
censor_rule.last_edit_comment = "none"
ir.censor_rules << censor_rule
-
- get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
- response.body.should have_tag("p.attachment strong", /goodbye.txt/m)
+ begin
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ response.body.should have_tag("p.attachment strong", /goodbye.txt/m)
+ ensure
+ ir.censor_rules.clear
+ end
end
it "should make a zipfile available, which has a different URL when it changes" do