aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/general_controller_spec.rb2
-rw-r--r--spec/controllers/public_body_controller_spec.rb6
-rw-r--r--spec/controllers/request_controller_spec.rb1
-rw-r--r--spec/controllers/track_controller_spec.rb15
-rw-r--r--spec/controllers/user_controller_spec.rb20
-rw-r--r--spec/fixtures/users.yml3
-rw-r--r--spec/integration/search_request_spec.rb11
-rw-r--r--spec/models/track_mailer_spec.rb3
-rw-r--r--spec/models/track_thing_spec.rb10
9 files changed, 62 insertions, 9 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index 4d7f1831d..1ffbda90d 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -64,7 +64,7 @@ describe GeneralController, "when searching" do
it "should redirect from search query URL to pretty URL" do
post :search_redirect, :query => "mouse" # query hidden in POST parameters
- response.should redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all
+ response.should redirect_to(:action => 'search', :combined => "mouse", :view => "requests") # URL /search/:query/all
end
describe "when using different locale settings" do
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 8e35b4a8d..c5c9d60e1 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -75,7 +75,7 @@ describe PublicBodyController, "when listing bodies" do
assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), public_bodies(:geraldine_public_body) ]
assigns[:tag].should == "all"
- assigns[:description].should == "all"
+ assigns[:description].should == ""
end
it "should support simple searching of bodies by title" do
@@ -94,7 +94,7 @@ describe PublicBodyController, "when listing bodies" do
response.should render_template('list')
assigns[:public_bodies].should == [ public_bodies(:geraldine_public_body), public_bodies(:humpadink_public_body) ]
assigns[:tag].should == "all"
- assigns[:description].should == "all"
+ assigns[:description].should == ""
I18n.default_locale = :en
end
@@ -113,7 +113,7 @@ describe PublicBodyController, "when listing bodies" do
get :list
response.should render_template('list')
- assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), public_bodies(:geraldine_public_body) ]
+ assigns[:public_bodies].count.should == 2
end
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index d8fe6cc1d..63e86b525 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -451,6 +451,7 @@ describe RequestController, "when making a new request" do
@user.stub!(:get_undescribed_requests).and_return([])
@user.stub!(:can_leave_requests_undescribed?).and_return(false)
@user.stub!(:can_file_requests?).and_return(true)
+ @user.stub!(:locale).and_return("en")
User.stub!(:find).and_return(@user)
@body = mock_model(PublicBody, :id => 314, :eir_only? => false, :is_requestable? => true, :name => "Test Quango")
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 2f3f903f9..c3dc98a67 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -16,6 +16,7 @@ describe TrackController, "when making a new track on a request" do
@user = mock_model(User)
User.stub!(:find).and_return(@user)
+ @user.stub!(:locale).and_return("en")
end
it "should require login when making new track" do
@@ -69,7 +70,6 @@ describe TrackController, "when sending alerts for a track" do
mail.body.should include('added an annotation') # comment included
mail.body.should =~ /This a the daftest comment the world has ever seen/ # comment text included
-
# Check subscription managing link
# XXX We can't do this, as it is redirecting to another controller. I'm
# apparently meant to be writing controller unit tests here, not functional
@@ -93,6 +93,19 @@ describe TrackController, "when sending alerts for a track" do
deliveries.size.should == 0
end
+ it "should send localised alerts" do
+ # set the time the comment event happened at to within the last week
+ ire = info_request_events(:silly_comment_event)
+ ire.created_at = Time.now - 3.days
+ ire.save!
+ user = users(:silly_name_user)
+ user.locale = "es"
+ user.save!
+ TrackMailer.alert_tracks
+ deliveries = ActionMailer::Base.deliveries
+ mail = deliveries[0]
+ mail.body.should include('el equipo de Alaveteli')
+ end
end
describe TrackController, "when viewing RSS feed for a track" do
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 438fb8c0c..0ba542630 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -32,6 +32,13 @@ describe UserController, "when showing a user" do
assigns[:display_user].should == users(:bob_smith_user)
end
+ it "should search the user's contributions" do
+ get :show, :url_name => "bob_smith"
+ assigns[:xapian_requests].results.count.should == 2
+ get :show, :url_name => "bob_smith", :user_query => "money"
+ assigns[:xapian_requests].results.count.should == 1
+ end
+
# Error handling not quite good enough for this yet
# it "should not show unconfirmed users" do
# get :show, :url_name => "silly_emnameem"
@@ -171,6 +178,19 @@ describe UserController, "when signing up" do
deliveries[0].body.should include("not reveal your email")
end
+ it "should send confirmation mail in other languages or different locales" do
+ session[:locale] = "es"
+ post :signup, {:user_signup => { :email => 'new@localhost', :name => 'New Person',
+ :password => 'sillypassword', :password_confirmation => 'sillypassword',
+ }
+ }
+ response.should render_template('confirm')
+
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ deliveries[0].body.should include("No revelaremos su dirección de correo")
+ end
+
it "should send special 'already signed up' mail if you fill the form in with existing registered email " do
post :signup, { :user_signup => { :email => 'silly@localhost', :name => 'New Person',
:password => 'sillypassword', :password_confirmation => 'sillypassword' }
diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml
index 2485c95a0..c54ac0985 100644
--- a/spec/fixtures/users.yml
+++ b/spec/fixtures/users.yml
@@ -10,6 +10,7 @@ bob_smith_user:
email_confirmed: true
admin_level: 'none'
ban_text: ''
+ locale: 'en'
about_me: 'I like making requests about fancy dogs and naughty chickens and stuff.'
silly_name_user:
id: "2"
@@ -23,6 +24,7 @@ silly_name_user:
email_confirmed: false
admin_level: 'none'
ban_text: ''
+ locale: 'en'
about_me: ''
admin_user:
id: "3"
@@ -36,4 +38,5 @@ admin_user:
email_confirmed: false
admin_level: 'super'
ban_text: ''
+ locale: ''
about_me: ''
diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb
index 84239f7a3..25c091111 100644
--- a/spec/integration/search_request_spec.rb
+++ b/spec/integration/search_request_spec.rb
@@ -25,14 +25,19 @@ describe "When searching" do
request_via_redirect("post", "/search",
:query => 'bob'
)
- response.body.should include("One person matching")
+ response.body.should include("FOI requests")
end
it "should correctly filter searches for requests" do
request_via_redirect("post", "/search/bob/requests")
- response.body.should_not include("One person matching")
+ response.body.should_not include("One person found")
response.body.should include("FOI requests 1 to 2 of 2")
end
+ it "should correctly filter searches for users" do
+ request_via_redirect("post", "/search/bob/users")
+ response.body.should include("One person found")
+ response.body.should_not include("FOI requests 1 to 2 of 2")
+ end
it "should correctly filter searches for successful requests" do
request_via_redirect("post", "/search",
@@ -45,7 +50,7 @@ describe "When searching" do
request_via_redirect("post", "/search",
:query => "daftest",
:request_variety => ['comments'])
- response.body.should include("One FOI request matching your search")
+ response.body.should include("One FOI request found")
request_via_redirect("post", "/search",
:query => "daftest",
diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb
index 828904d02..b90ca7e52 100644
--- a/spec/models/track_mailer_spec.rb
+++ b/spec/models/track_mailer_spec.rb
@@ -21,7 +21,8 @@ describe TrackMailer do
@user = mock_model(User, :no_xapian_reindex= => false,
:last_daily_track_email= => true,
:save! => true,
- :url_name => 'test-name')
+ :url_name => 'test-name',
+ :get_locale => 'en')
User.stub!(:find).and_return([@user])
@user.stub!(:no_xapian_reindex=)
end
diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb
index 6b9cd6d4a..1a0324a78 100644
--- a/spec/models/track_thing_spec.rb
+++ b/spec/models/track_thing_spec.rb
@@ -28,5 +28,15 @@ describe TrackThing, "when tracking changes" do
found_track.should == @track_thing
end
+ it "will make some sane descriptions of search-based tracks" do
+ tests = [['bob variety:user', "users matching text 'bob'"],
+ ['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "requests which are successful or unsuccessful or comments matching text 'bob'"],
+ ['(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)', 'requests which are awaiting a response']]
+ for query, description in tests
+ track_thing = TrackThing.create_track_for_search_query(query)
+ track_thing.track_query_description.should == description
+ end
+ end
+
end