diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 24 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 44 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 2 |
3 files changed, 53 insertions, 17 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 8a08ab7d0..df2c139bd 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -77,12 +77,34 @@ describe GeneralController, "when searching" do end describe "when using different locale settings" do - home_link_regex = /href=".*\/en"/ + home_link_regex = /href=".*\/en\// it "should generate URLs with a locale prepended when there's more than one locale set" do get :frontpage response.should have_text(home_link_regex) end + it "should use our test PO files rather than the application one" do + I18n.default_locale = :es + get :frontpage + response.should have_text(/XOXO/) + I18n.default_locale = :en + end + + it "should generate URLs that include the locale when using one that includes an underscore" do + I18n.default_locale = :"en_GB" + get :frontpage + response.should have_text(/href="\/en_GB\//) + I18n.default_locale = :en + end + + it "should fall back to the language if the territory is unknown" do + I18n.default_locale = :"en_US" + get :frontpage + response.should have_text(/href="\/en\//) + response.should_not have_text(/href="\/en_US\//) + I18n.default_locale = :en + end + it "should generate URLs without a locale prepended when there's only one locale set" do old_fgt_available_locales = FastGettext.default_available_locales old_i18n_available_locales = I18n.available_locales diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index c70284748..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 @@ -290,6 +296,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.txt'], :skip_cache => 1 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'], :skip_cache => 1 response.content_type.should == "text/plain" response.should have_text(/First hello/) @@ -418,15 +425,6 @@ describe RequestController, "when showing one request" do response.should have_text(/an unusual sort of file/) end - it "should apply a content-disposition header" do - ir = info_requests(:fancy_dog_request) - receive_incoming_mail('incoming-request-attachment-unknown-extension.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.qwglhm'], :skip_cache => 1 - response.headers.should include("Content-Disposition") - response.headers["Content-Disposition"].should include('hello.qwglhm') - end - it "should not download attachments with wrong file name" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) @@ -1848,12 +1846,17 @@ end describe RequestController, "when reporting a request" do integrate_views + before do + @user = users(:robin_user) + session[:user_id] = @user.id + end + it "should mark a request as having been reported" do ir = info_requests(:badger_request) title = ir.url_title get :show, :url_title => title assigns[:info_request].attention_requested.should == false - get :report_request, :url_title => title + post :report_request, :url_title => title get :show, :url_title => title assigns[:info_request].attention_requested.should == true assigns[:info_request].described_state.should == "attention_requested" @@ -1861,10 +1864,10 @@ describe RequestController, "when reporting a request" do it "should not allow a request to be reported twice" do title = info_requests(:badger_request).url_title - get :report_request, :url_title => title + post :report_request, :url_title => title get :show, :url_title => title response.body.should include("has been reported") - get :report_request, :url_title => title + post :report_request, :url_title => title get :show, :url_title => title response.body.should include("has already been reported") end @@ -1873,16 +1876,27 @@ describe RequestController, "when reporting a request" do title = info_requests(:badger_request).url_title get :show, :url_title => title response.body.should include("Offensive?") - get :report_request, :url_title => title + post :report_request, :url_title => title get :show, :url_title => title response.body.should_not include("Offensive?") response.body.should include("This request has been reported") info_requests(:badger_request).set_described_state("successful") get :show, :url_title => title response.body.should_not include("This request has been reported") - response.body.should include("The site administrators have reviewed this request") + response.body.should =~ (/the site administrators.*have not hidden it/) end + it "should send an email from the reporter to admins" do + ir = info_requests(:badger_request) + title = ir.url_title + post :report_request, :url_title => title + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + mail = deliveries[0] + mail.subject.should =~ /attention_requested/ + mail.from.should include(@user.email) + mail.body.should include(@user.name) + end end diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 7a6c9ac0d..32398c053 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -265,7 +265,7 @@ describe UserController, "when signing up" do deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 - deliveries[0].body.should include("No revelaremos su dirección de correo") + deliveries[0].body.should include("No revelaremos") end it "should send special 'already signed up' mail if you fill the form in with existing registered email" do |