aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/general_controller_spec.rb24
-rw-r--r--spec/controllers/request_controller_spec.rb23
-rw-r--r--spec/controllers/user_controller_spec.rb2
3 files changed, 43 insertions, 6 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..705d96316 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1848,12 +1848,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 +1866,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,7 +1878,7 @@ 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")
@@ -1883,6 +1888,16 @@ describe RequestController, "when reporting a request" do
response.body.should include("The site administrators have reviewed this request")
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)
+ 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