aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin_censor_rule_controller_spec.rb3
-rw-r--r--spec/controllers/admin_comment_controller_spec.rb1
-rw-r--r--spec/controllers/admin_general_controller_spec.rb1
-rw-r--r--spec/controllers/admin_holiday_imports_controller_spec.rb1
-rw-r--r--spec/controllers/admin_holidays_controller_spec.rb1
-rw-r--r--spec/controllers/admin_incoming_message_controller_spec.rb1
-rw-r--r--spec/controllers/admin_info_request_event_controller_spec.rb2
-rw-r--r--spec/controllers/admin_outgoing_message_controller_spec.rb1
-rw-r--r--spec/controllers/admin_public_body_categories_controller_spec.rb3
-rw-r--r--spec/controllers/admin_public_body_change_requests_controller_spec.rb2
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb16
-rw-r--r--spec/controllers/admin_public_body_headings_controller_spec.rb1
-rw-r--r--spec/controllers/admin_raw_email_controller_spec.rb1
-rw-r--r--spec/controllers/admin_request_controller_spec.rb1
-rw-r--r--spec/controllers/admin_spam_addresses_controller_spec.rb1
-rw-r--r--spec/controllers/admin_track_controller_spec.rb1
-rw-r--r--spec/controllers/admin_user_controller_spec.rb1
-rw-r--r--spec/controllers/api_controller_spec.rb2
-rw-r--r--spec/controllers/comment_controller_spec.rb1
-rw-r--r--spec/controllers/general_controller_spec.rb5
-rw-r--r--spec/controllers/health_checks_controller_spec.rb1
-rw-r--r--spec/controllers/help_controller_spec.rb2
-rw-r--r--spec/controllers/info_request_batch_controller_spec.rb2
-rw-r--r--spec/controllers/public_body_change_requests_controller_spec.rb2
-rw-r--r--spec/controllers/public_body_controller_spec.rb4
-rw-r--r--spec/controllers/reports_controller_spec.rb1
-rw-r--r--spec/controllers/request_controller_spec.rb49
-rw-r--r--spec/controllers/request_game_controller_spec.rb1
-rw-r--r--spec/controllers/services_controller_spec.rb12
-rw-r--r--spec/controllers/track_controller_spec.rb1
-rw-r--r--spec/controllers/user_controller_spec.rb6
-rw-r--r--spec/controllers/widgets_controller_spec.rb181
32 files changed, 256 insertions, 52 deletions
diff --git a/spec/controllers/admin_censor_rule_controller_spec.rb b/spec/controllers/admin_censor_rule_controller_spec.rb
index 68eaecd6a..b9f936836 100644
--- a/spec/controllers/admin_censor_rule_controller_spec.rb
+++ b/spec/controllers/admin_censor_rule_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminCensorRuleController do
@@ -584,7 +585,7 @@ describe AdminCensorRuleController, "when making censor rules from the admin int
:replacement => "tofu",
:last_edit_comment => "none"
}
- PurgeRequest.all().first.model_id.should == ir.id
+ PurgeRequest.all.first.model_id.should == ir.id
end
end
diff --git a/spec/controllers/admin_comment_controller_spec.rb b/spec/controllers/admin_comment_controller_spec.rb
index f87231e3b..00b6e6cc9 100644
--- a/spec/controllers/admin_comment_controller_spec.rb
+++ b/spec/controllers/admin_comment_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminCommentController do
diff --git a/spec/controllers/admin_general_controller_spec.rb b/spec/controllers/admin_general_controller_spec.rb
index cc2ec41b4..b2e8b233f 100644
--- a/spec/controllers/admin_general_controller_spec.rb
+++ b/spec/controllers/admin_general_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminGeneralController do
diff --git a/spec/controllers/admin_holiday_imports_controller_spec.rb b/spec/controllers/admin_holiday_imports_controller_spec.rb
index dd23a022f..42dfadd47 100644
--- a/spec/controllers/admin_holiday_imports_controller_spec.rb
+++ b/spec/controllers/admin_holiday_imports_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require 'spec_helper'
describe AdminHolidayImportsController do
diff --git a/spec/controllers/admin_holidays_controller_spec.rb b/spec/controllers/admin_holidays_controller_spec.rb
index 21cb51d29..93f51707b 100644
--- a/spec/controllers/admin_holidays_controller_spec.rb
+++ b/spec/controllers/admin_holidays_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require 'spec_helper'
describe AdminHolidaysController do
diff --git a/spec/controllers/admin_incoming_message_controller_spec.rb b/spec/controllers/admin_incoming_message_controller_spec.rb
index 24a526ca4..39355c054 100644
--- a/spec/controllers/admin_incoming_message_controller_spec.rb
+++ b/spec/controllers/admin_incoming_message_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminIncomingMessageController, "when administering incoming messages" do
diff --git a/spec/controllers/admin_info_request_event_controller_spec.rb b/spec/controllers/admin_info_request_event_controller_spec.rb
index 23300a0b8..dfa425374 100644
--- a/spec/controllers/admin_info_request_event_controller_spec.rb
+++ b/spec/controllers/admin_info_request_event_controller_spec.rb
@@ -1,4 +1,4 @@
-# coding: utf-8
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminInfoRequestEventController do
diff --git a/spec/controllers/admin_outgoing_message_controller_spec.rb b/spec/controllers/admin_outgoing_message_controller_spec.rb
index a46a077da..f231311ae 100644
--- a/spec/controllers/admin_outgoing_message_controller_spec.rb
+++ b/spec/controllers/admin_outgoing_message_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminOutgoingMessageController do
diff --git a/spec/controllers/admin_public_body_categories_controller_spec.rb b/spec/controllers/admin_public_body_categories_controller_spec.rb
index 1131b3c0b..1aa8a145e 100644
--- a/spec/controllers/admin_public_body_categories_controller_spec.rb
+++ b/spec/controllers/admin_public_body_categories_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require 'spec_helper'
describe AdminPublicBodyCategoriesController do
@@ -310,7 +311,7 @@ describe AdminPublicBodyCategoriesController do
post :update, :id => category.id,
:public_body_category => category.serializable_hash.except(:title, :description)
- expect(assigns(:tagged_public_bodies)).to eq(expected_bodies)
+ expect(assigns(:tagged_public_bodies)).to match_array(expected_bodies)
end
it "saves edits to a public body category's heading associations" do
diff --git a/spec/controllers/admin_public_body_change_requests_controller_spec.rb b/spec/controllers/admin_public_body_change_requests_controller_spec.rb
index 003510e60..b0a9ebd79 100644
--- a/spec/controllers/admin_public_body_change_requests_controller_spec.rb
+++ b/spec/controllers/admin_public_body_change_requests_controller_spec.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminPublicBodyChangeRequestsController, "editing a change request" do
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index 50a373d9d..f7336a6c7 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminPublicBodyController, "when showing the index of public bodies" do
@@ -128,7 +129,8 @@ describe AdminPublicBodyController, "when creating a public body" do
:last_edit_comment => 'From test code',
:translations_attributes => {
'es' => { :locale => 'es',
- :name => 'Los Quango' }
+ :name => 'Los Quango',
+ :short_name => 'lq' }
} } }
end
@@ -159,6 +161,8 @@ describe AdminPublicBodyController, "when creating a public body" do
I18n.with_locale(:es) do
expect(body.name).to eq('Los Quango')
+ expect(body.url_name).to eq('lq')
+ expect(body.first_letter).to eq('L')
end
end
@@ -650,17 +654,17 @@ describe AdminPublicBodyController, "when administering public bodies and paying
render_views
before do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = false
basic_auth_login @request
end
after do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = true
end
def setup_emergency_credentials(username, password)
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = false
config['ADMIN_USERNAME'] = username
config['ADMIN_PASSWORD'] = password
@@ -677,7 +681,7 @@ describe AdminPublicBodyController, "when administering public bodies and paying
end
it "skips admin authorisation when SKIP_ADMIN_AUTH set" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = true
@request.env["HTTP_AUTHORIZATION"] = ""
n = PublicBody.count
@@ -757,7 +761,7 @@ describe AdminPublicBodyController, "when administering public bodies and paying
end
it 'returns the REMOTE_USER value from the request environment when skipping admin auth' do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['SKIP_ADMIN_AUTH'] = true
@request.env["HTTP_AUTHORIZATION"] = ""
@request.env["REMOTE_USER"] = "i_am_admin"
diff --git a/spec/controllers/admin_public_body_headings_controller_spec.rb b/spec/controllers/admin_public_body_headings_controller_spec.rb
index ccdfdecfb..0e0337e3e 100644
--- a/spec/controllers/admin_public_body_headings_controller_spec.rb
+++ b/spec/controllers/admin_public_body_headings_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require 'spec_helper'
describe AdminPublicBodyHeadingsController do
diff --git a/spec/controllers/admin_raw_email_controller_spec.rb b/spec/controllers/admin_raw_email_controller_spec.rb
index 77c57c38b..9039286bc 100644
--- a/spec/controllers/admin_raw_email_controller_spec.rb
+++ b/spec/controllers/admin_raw_email_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminRawEmailController do
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb
index 4eb463963..61827bfd1 100644
--- a/spec/controllers/admin_request_controller_spec.rb
+++ b/spec/controllers/admin_request_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminRequestController, "when administering requests" do
diff --git a/spec/controllers/admin_spam_addresses_controller_spec.rb b/spec/controllers/admin_spam_addresses_controller_spec.rb
index a1e434159..8f6d57b01 100644
--- a/spec/controllers/admin_spam_addresses_controller_spec.rb
+++ b/spec/controllers/admin_spam_addresses_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require 'spec_helper'
describe AdminSpamAddressesController do
diff --git a/spec/controllers/admin_track_controller_spec.rb b/spec/controllers/admin_track_controller_spec.rb
index d29db4966..b77570a27 100644
--- a/spec/controllers/admin_track_controller_spec.rb
+++ b/spec/controllers/admin_track_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminTrackController, "when administering tracks" do
diff --git a/spec/controllers/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb
index e979355cf..9341feec6 100644
--- a/spec/controllers/admin_user_controller_spec.rb
+++ b/spec/controllers/admin_user_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminUserController, "when administering users" do
diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb
index 323ef4cd4..d8af59ad8 100644
--- a/spec/controllers/api_controller_spec.rb
+++ b/spec/controllers/api_controller_spec.rb
@@ -1,4 +1,4 @@
-# coding: utf-8
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ApiController, "when using the API" do
diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb
index 480c85ad7..cfd7166f4 100644
--- a/spec/controllers/comment_controller_spec.rb
+++ b/spec/controllers/comment_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe CommentController, "when commenting on a request" do
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index 844fcd4e6..495624403 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'fakeweb'
@@ -111,7 +112,7 @@ describe GeneralController, "when showing the frontpage" do
it "should render the front page with default language and ignore the browser setting" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['USE_DEFAULT_BROWSER_LANGUAGE'] = false
accept_language = "en-GB,en-US;q=0.8,en;q=0.6"
request.env['HTTP_ACCEPT_LANGUAGE'] = accept_language
@@ -122,7 +123,7 @@ describe GeneralController, "when showing the frontpage" do
end
it "should render the front page with browser-selected language when there's no default set" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['USE_DEFAULT_BROWSER_LANGUAGE'] = true
accept_language = "es-ES,en-GB,en-US;q=0.8,en;q=0.6"
request.env['HTTP_ACCEPT_LANGUAGE'] = accept_language
diff --git a/spec/controllers/health_checks_controller_spec.rb b/spec/controllers/health_checks_controller_spec.rb
index f7ad6d6a4..2403fb3c8 100644
--- a/spec/controllers/health_checks_controller_spec.rb
+++ b/spec/controllers/health_checks_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe HealthChecksController do
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
index 9453c9461..338a86380 100644
--- a/spec/controllers/help_controller_spec.rb
+++ b/spec/controllers/help_controller_spec.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe HelpController do
diff --git a/spec/controllers/info_request_batch_controller_spec.rb b/spec/controllers/info_request_batch_controller_spec.rb
index d08f02e10..866a1d0dc 100644
--- a/spec/controllers/info_request_batch_controller_spec.rb
+++ b/spec/controllers/info_request_batch_controller_spec.rb
@@ -1,4 +1,4 @@
-# coding: utf-8
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe InfoRequestBatchController, "when showing a request" do
diff --git a/spec/controllers/public_body_change_requests_controller_spec.rb b/spec/controllers/public_body_change_requests_controller_spec.rb
index 4053b2f40..a8f149cc6 100644
--- a/spec/controllers/public_body_change_requests_controller_spec.rb
+++ b/spec/controllers/public_body_change_requests_controller_spec.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PublicBodyChangeRequestsController, "making a new change request" do
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index ff0a70a6f..c5c94a45c 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -1,4 +1,4 @@
-# coding: utf-8
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'nokogiri'
@@ -336,7 +336,7 @@ end
describe PublicBodyController, "when showing public body statistics" do
it "should render the right template with the right data" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['MINIMUM_REQUESTS_FOR_STATISTICS'] = 1
config['PUBLIC_BODY_STATISTICS_PAGE'] = true
get :statistics
diff --git a/spec/controllers/reports_controller_spec.rb b/spec/controllers/reports_controller_spec.rb
index fa8c72eaa..91be67fd8 100644
--- a/spec/controllers/reports_controller_spec.rb
+++ b/spec/controllers/reports_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require 'spec_helper'
describe ReportsController, "when reporting a request when not logged in" do
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 02237b29d..9e2e1bff7 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe RequestController, "when listing recent requests" do
@@ -40,41 +40,41 @@ describe RequestController, "when changing things that appear on the request pag
it "should purge the downstream cache when mail is received" do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('incoming-request-plain.email', ir.incoming_email)
- PurgeRequest.all().first.model_id.should == ir.id
+ PurgeRequest.all.first.model_id.should == ir.id
end
it "should purge the downstream cache when a comment is added" do
ir = info_requests(:fancy_dog_request)
new_comment = info_requests(:fancy_dog_request).add_comment('I also love making annotations.', users(:bob_smith_user))
- PurgeRequest.all().first.model_id.should == ir.id
+ PurgeRequest.all.first.model_id.should == ir.id
end
it "should purge the downstream cache when a followup is made" do
session[:user_id] = users(:bob_smith_user).id
ir = info_requests(:fancy_dog_request)
post :show_response, :outgoing_message => { :body => "What a useless response! You suck.", :what_doing => 'normal_sort' }, :id => ir.id, :submitted_followup => 1
- PurgeRequest.all().first.model_id.should == ir.id
+ PurgeRequest.all.first.model_id.should == ir.id
end
it "should purge the downstream cache when the request is categorised" do
ir = info_requests(:fancy_dog_request)
ir.set_described_state('waiting_clarification')
- PurgeRequest.all().first.model_id.should == ir.id
+ PurgeRequest.all.first.model_id.should == ir.id
end
it "should purge the downstream cache when the authority data is changed" do
ir = info_requests(:fancy_dog_request)
ir.public_body.name = "Something new"
ir.public_body.save!
- PurgeRequest.all().map{|x| x.model_id}.should =~ ir.public_body.info_requests.map{|x| x.id}
+ 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 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}
+ 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
+ PurgeRequest.all.count.should == 0
end
it "should purge the downstream cache when censor rules have changed" do
# TODO: really, CensorRules should execute expiry logic as part
@@ -86,17 +86,17 @@ describe RequestController, "when changing things that appear on the request pag
ir = info_requests(:fancy_dog_request)
ir.prominence = 'hidden'
ir.save!
- PurgeRequest.all().first.model_id.should == ir.id
+ PurgeRequest.all.first.model_id.should == ir.id
end
it "should not create more than one entry for any given resource" do
ir = info_requests(:fancy_dog_request)
ir.prominence = 'hidden'
ir.save!
- PurgeRequest.all().count.should == 1
+ PurgeRequest.all.count.should == 1
ir = info_requests(:fancy_dog_request)
ir.prominence = 'hidden'
ir.save!
- PurgeRequest.all().count.should == 1
+ PurgeRequest.all.count.should == 1
end
end
@@ -608,10 +608,10 @@ describe RequestController, "when showing one request" do
response.body.should match('dull')
end
- it "should censor attachments downloaded as binary" do
+ it "should censor attachments downloaded directly" do
ir = info_requests(:fancy_dog_request)
- censor_rule = CensorRule.new()
+ censor_rule = CensorRule.new
censor_rule.text = "Second"
censor_rule.replacement = "Mouse"
censor_rule.last_edit_editor = "unknown"
@@ -623,7 +623,7 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => 'hello world.txt', :skip_cache => 1
response.content_type.should == "text/plain"
- response.should contain "xxxxxx hello"
+ response.should contain "Mouse hello"
ensure
ir.censor_rules.clear
end
@@ -632,7 +632,7 @@ describe RequestController, "when showing one request" do
it "should censor with rules on the user (rather than the request)" do
ir = info_requests(:fancy_dog_request)
- censor_rule = CensorRule.new()
+ censor_rule = CensorRule.new
censor_rule.text = "Second"
censor_rule.replacement = "Mouse"
censor_rule.last_edit_editor = "unknown"
@@ -645,7 +645,7 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => 'hello world.txt', :skip_cache => 1
response.content_type.should == "text/plain"
- response.should contain "xxxxxx hello"
+ response.should contain "Mouse hello"
ensure
ir.user.censor_rules.clear
end
@@ -675,7 +675,7 @@ describe RequestController, "when showing one request" do
s.should contain /hello world.txt/m
end
- censor_rule = CensorRule.new()
+ censor_rule = CensorRule.new
# Note that the censor rule applies to the original filename,
# not the display_filename:
censor_rule.text = "hello-world.txt"
@@ -1471,7 +1471,7 @@ describe RequestController, "when classifying an information request" do
it 'should record a classification' do
event = mock_model(InfoRequestEvent)
- @dog_request.stub!(:log_event).with("status_update", anything()).and_return(event)
+ @dog_request.stub!(:log_event).with("status_update", anything).and_return(event)
RequestClassification.should_receive(:create!).with(:user_id => @admin_user.id,
:info_request_event_id => event.id)
post_status('rejected')
@@ -1915,7 +1915,7 @@ describe RequestController, "sending overdue request alerts" do
it "should send an overdue alert mail to creators of overdue requests" do
chicken_request = info_requests(:naughty_chicken_request)
- chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 30.days
+ chicken_request.outgoing_messages[0].last_sent_at = Time.now - 30.days
chicken_request.outgoing_messages[0].save!
RequestMailer.alert_overdue_requests
@@ -1941,7 +1941,7 @@ describe RequestController, "sending overdue request alerts" do
it "should include clause for schools when sending an overdue alert mail to creators of overdue requests" do
chicken_request = info_requests(:naughty_chicken_request)
- chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 30.days
+ chicken_request.outgoing_messages[0].last_sent_at = Time.now - 30.days
chicken_request.outgoing_messages[0].save!
chicken_request.public_body.tag_string = "school"
@@ -1972,7 +1972,7 @@ describe RequestController, "sending overdue request alerts" do
it "should send a very overdue alert mail to creators of very overdue requests" do
chicken_request = info_requests(:naughty_chicken_request)
- chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 60.days
+ chicken_request.outgoing_messages[0].last_sent_at = Time.now - 60.days
chicken_request.outgoing_messages[0].save!
RequestMailer.alert_overdue_requests
@@ -1998,7 +1998,7 @@ describe RequestController, "sending overdue request alerts" do
it "should not resend alerts to people who've already received them" do
chicken_request = info_requests(:naughty_chicken_request)
- chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 60.days
+ chicken_request.outgoing_messages[0].last_sent_at = Time.now - 60.days
chicken_request.outgoing_messages[0].save!
RequestMailer.alert_overdue_requests
chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/}
@@ -2011,7 +2011,7 @@ describe RequestController, "sending overdue request alerts" do
it 'should send alerts for requests where the last event forming the initial request is a followup
being sent following a request for clarification' do
chicken_request = info_requests(:naughty_chicken_request)
- chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 60.days
+ chicken_request.outgoing_messages[0].last_sent_at = Time.now - 60.days
chicken_request.outgoing_messages[0].save!
RequestMailer.alert_overdue_requests
chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/}
@@ -2048,7 +2048,7 @@ describe RequestController, "sending overdue request alerts" do
chicken_mails.size.should == 1
# Make the followup older
- outgoing_message.last_sent_at = Time.now() - 60.days
+ outgoing_message.last_sent_at = Time.now - 60.days
outgoing_message.save!
# Now it should be alerted on
@@ -2764,4 +2764,3 @@ describe RequestController, "#select_authorities" do
end
end
-
diff --git a/spec/controllers/request_game_controller_spec.rb b/spec/controllers/request_game_controller_spec.rb
index 7247cd388..c3f00d58d 100644
--- a/spec/controllers/request_game_controller_spec.rb
+++ b/spec/controllers/request_game_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe RequestGameController, "when playing the game" do
diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb
index 621dbaaac..6ab527bc9 100644
--- a/spec/controllers/services_controller_spec.rb
+++ b/spec/controllers/services_controller_spec.rb
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'fakeweb'
@@ -9,7 +9,7 @@ describe ServicesController, "when returning a message for people in other count
# store and restore the locale in the context of the test suite to isolate
# changes made in these tests
before do
- @old_locale = FastGettext.locale()
+ @old_locale = FastGettext.locale
end
it 'keeps the flash' do
@@ -21,7 +21,7 @@ describe ServicesController, "when returning a message for people in other count
end
it "should show no alaveteli message when in the deployed country" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['ISO_COUNTRY_CODE'] = "DE"
controller.stub!(:country_from_ip).and_return('DE')
get :other_country_message
@@ -29,7 +29,7 @@ describe ServicesController, "when returning a message for people in other count
end
it "should show an alaveteli message when not in the deployed country and in a country with no FOI website" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['ISO_COUNTRY_CODE'] = "DE"
controller.stub!(:country_from_ip).and_return('ZZ')
get :other_country_message
@@ -37,7 +37,7 @@ describe ServicesController, "when returning a message for people in other count
end
it "should show link to other FOI website when not in the deployed country" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['ISO_COUNTRY_CODE'] = "ZZ"
controller.stub!(:country_from_ip).and_return('ES')
request.env['HTTP_ACCEPT_LANGUAGE'] = "es"
@@ -60,7 +60,7 @@ describe ServicesController, "when returning a message for people in other count
end
it "should return the 'another country' message if the service responds OK" do
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
config['ISO_COUNTRY_CODE'] = "DE"
AlaveteliConfiguration.stub!(:gaze_url).and_return('http://denmark.com')
FakeWeb.register_uri(:get, %r|denmark.com|, :body => "DK")
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 29f5c7fe1..b453fde8c 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -1,3 +1,4 @@
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe TrackController, "when making a new track on a request" do
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 443856cf3..fb03615f8 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -1,4 +1,4 @@
-# coding: utf-8
+# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe UserController do
@@ -76,11 +76,11 @@ describe UserController, "when redirecting a show request to a canonical url" do
end
it 'should not redirect a long canonical name that has a numerical suffix' do
- User.stub!(:find).with(:first, anything()).and_return(mock_model(User,
+ User.stub!(:find).with(:first, anything).and_return(mock_model(User,
:url_name => 'bob_smithbob_smithbob_smithbob_s_2',
:name => 'Bob Smith Bob Smith Bob Smith Bob Smith',
:info_requests => []))
- User.stub!(:find).with(:all, anything()).and_return([])
+ User.stub!(:find).with(:all, anything).and_return([])
get :show, :url_name => 'bob_smithbob_smithbob_smithbob_s_2'
response.should be_success
end
diff --git a/spec/controllers/widgets_controller_spec.rb b/spec/controllers/widgets_controller_spec.rb
new file mode 100644
index 000000000..95396671b
--- /dev/null
+++ b/spec/controllers/widgets_controller_spec.rb
@@ -0,0 +1,181 @@
+# -*- encoding : utf-8 -*-
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe WidgetsController do
+
+ include LinkToHelper
+
+ describe "#show" do
+
+ before do
+ @info_request = FactoryGirl.create(:info_request)
+ AlaveteliConfiguration.stub!(:enable_widgets).and_return(true)
+ end
+
+ it 'should render the widget template' do
+ get :show, :request_id => @info_request.id
+ expect(response).to render_template('show')
+ end
+
+ it 'should find the info request' do
+ get :show, :request_id => @info_request.id
+ assigns[:info_request].should == @info_request
+ end
+
+ it 'should create a track thing for the request' do
+ get :show, :request_id => @info_request.id
+ assigns[:track_thing].info_request.should == @info_request
+ end
+
+ it 'should assign the request status' do
+ get :show, :request_id => @info_request.id
+ assigns[:status].should == @info_request.calculate_status
+ end
+
+ it 'should not send an x-frame-options header' do
+ get :show, :request_id => @info_request.id
+ response.headers["X-Frame-Options"].should be_nil
+ end
+
+ context 'for a non-logged-in user' do
+
+ context 'if no widget-vote cookie is set' do
+
+ it 'should set a widget-vote cookie' do
+ cookies[:widget_vote].should be_nil
+ get :show, :request_id => @info_request.id
+ cookies[:widget_vote].should_not be_nil
+ end
+
+ end
+
+ end
+
+ context 'when widgets are not enabled' do
+
+ it 'should return a 404' do
+ AlaveteliConfiguration.stub!(:enable_widgets).and_return(false)
+ lambda{ get :show, :request_id => @info_request.id }.should
+ raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ end
+
+ context "when the request's prominence is not 'normal'" do
+
+ it 'should return a 403' do
+ @info_request.prominence = 'hidden'
+ @info_request.save!
+ get :show, :request_id => @info_request.id
+ response.code.should == "403"
+ end
+
+ end
+
+ end
+
+ describe "#new" do
+
+ before do
+ @info_request = FactoryGirl.create(:info_request)
+ AlaveteliConfiguration.stub!(:enable_widgets).and_return(true)
+ end
+
+ it 'should render the create widget template' do
+ get :new, :request_id => @info_request.id
+ expect(response).to render_template('new')
+ end
+
+ it 'should find the info request' do
+ get :new, :request_id => @info_request.id
+ assigns[:info_request].should == @info_request
+ end
+
+ context 'when widgets are not enabled' do
+
+ it 'should return a 404' do
+ AlaveteliConfiguration.stub!(:enable_widgets).and_return(false)
+ lambda{ get :new, :request_id => @info_request.id }.should
+ raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ end
+
+ context "when the request's prominence is not 'normal'" do
+
+ it 'should return a 403' do
+ @info_request.prominence = 'hidden'
+ @info_request.save!
+ get :show, :request_id => @info_request.id
+ response.code.should == "403"
+ end
+
+ end
+
+ end
+
+ describe :update do
+
+ before do
+ @info_request = FactoryGirl.create(:info_request)
+ AlaveteliConfiguration.stub!(:enable_widgets).and_return(true)
+ end
+
+ it 'should find the info request' do
+ get :update, :request_id => @info_request.id
+ assigns[:info_request].should == @info_request
+ end
+
+ it 'should redirect to the track path for the info request' do
+ get :update, :request_id => @info_request.id
+ track_thing = TrackThing.create_track_for_request(@info_request)
+ expect(response).to redirect_to(do_track_path(track_thing))
+ end
+
+ context 'when there is no logged-in user and a widget vote cookie' do
+
+ before do
+ @cookie_value = 'x' * 20
+ end
+
+ it 'should create a widget vote if none exists for the info request and cookie' do
+ @info_request.widget_votes.where(:cookie => @cookie_value).size.should == 0
+ request.cookies['widget_vote'] = @cookie_value
+ get :update, :request_id => @info_request.id
+ @info_request.widget_votes.where(:cookie => @cookie_value).size.should == 1
+ end
+
+ it 'should not create a widget vote if one exists for the info request and cookie' do
+ @info_request.widget_votes.create(:cookie => @cookie_value)
+ request.cookies['widget_vote'] = @cookie_value
+ get :update, :request_id => @info_request.id
+ @info_request.widget_votes.where(:cookie => @cookie_value).size.should == 1
+ end
+
+ end
+
+ context 'when widgets are not enabled' do
+
+ it 'should raise ActiveRecord::RecordNotFound' do
+ AlaveteliConfiguration.stub!(:enable_widgets).and_return(false)
+ lambda{ get :update, :request_id => @info_request.id }.should
+ raise_error(ActiveRecord::RecordNotFound)
+ end
+
+ end
+
+ context "when the request's prominence is not 'normal'" do
+
+ it 'should return a 403' do
+ @info_request.prominence = 'hidden'
+ @info_request.save!
+ get :show, :request_id => @info_request.id
+ response.code.should == "403"
+ end
+
+ end
+
+ end
+
+end
+