diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 35 | ||||
-rw-r--r-- | spec/fixtures/users.yml | 5 | ||||
-rw-r--r-- | spec/models/track_mailer_spec.rb | 9 |
4 files changed, 51 insertions, 0 deletions
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index bc7cfce64..1d38b3055 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -16,6 +16,8 @@ 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") + @user.stub!(:receive_email_alerts).and_return(true) + @user.stub!(:url_name).and_return("bob") end it "should require login when making new track" do diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 0d7b19e1e..7a6c9ac0d 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -630,6 +630,41 @@ describe UserController, "when showing JSON version for API" do end +describe UserController, "when viewing the wall" do + integrate_views + + before(:each) do + rebuild_xapian_index + end + it "should show users stuff on their wall, most recent first" do + user = users(:silly_name_user) + ire = info_request_events(:useless_incoming_message_event) + ire.created_at = DateTime.new(2001,1,1) + session[:user_id] = user.id + get :wall, :url_name => user.url_name + assigns[:feed_results][0].should_not == ire + ire.created_at = Time.now + ire.save! + get :wall, :url_name => user.url_name + assigns[:feed_results][0].should == ire + end + it "should show other users' activities on their walls" do + user = users(:silly_name_user) + ire = info_request_events(:useless_incoming_message_event) + get :wall, :url_name => user.url_name + assigns[:feed_results][0].should_not == ire + end + + it "should allow users to turn their own email alerts on and off" do + user = users(:silly_name_user) + session[:user_id] = user.id + user.receive_email_alerts.should == true + get :set_receive_email_alerts, :receive_email_alerts => 'false', :came_from => "/" + user.reload + user.receive_email_alerts.should_not == true + end + +end diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 8620fb3de..d6391c5e8 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -12,6 +12,7 @@ bob_smith_user: ban_text: '' locale: 'en' about_me: 'I like making requests about fancy dogs and naughty chickens and stuff.' + receive_email_alerts: true silly_name_user: id: "2" name: "Silly <em>Name</em>" @@ -26,6 +27,7 @@ silly_name_user: ban_text: '' locale: 'en' about_me: '' + receive_email_alerts: true admin_user: id: "3" name: Joe Admin @@ -40,6 +42,7 @@ admin_user: ban_text: '' locale: '' about_me: '' + receive_email_alerts: true unconfirmed_user: id: "4" name: "Unconfirmed" @@ -53,6 +56,7 @@ unconfirmed_user: admin_level: 'none' ban_text: '' about_me: '' + receive_email_alerts: true robin_user: id: 5 name: Robin Houston @@ -66,3 +70,4 @@ robin_user: admin_level: 'none' ban_text: '' about_me: 'I am the best' + receive_email_alerts: true diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb index 4f5499a90..1bf77dab5 100644 --- a/spec/models/track_mailer_spec.rb +++ b/spec/models/track_mailer_spec.rb @@ -25,6 +25,7 @@ describe TrackMailer do :get_locale => 'en', :should_be_emailed? => true) User.stub!(:find).and_return([@user]) + @user.stub!(:receive_email_alerts).and_return(true) @user.stub!(:no_xapian_reindex=) end @@ -122,6 +123,7 @@ describe TrackMailer do :url_name => 'test-name', :should_be_emailed? => false) User.stub!(:find).and_return([@user]) + @user.stub!(:receive_email_alerts).and_return(true) @user.stub!(:no_xapian_reindex=) end @@ -131,6 +133,13 @@ describe TrackMailer do TrackMailer.alert_tracks end + it 'should not ask for any daily track things for the user if they have receive_email_alerts off but could otherwise be emailed' do + @user.stub(:should_be_emailed?).and_return(true) + @user.stub(:receive_email_alerts).and_return(false) + expected_conditions = [ "tracking_user_id = ? and track_medium = ?", @user.id, 'email_daily' ] + TrackThing.should_not_receive(:find).with(:all, :conditions => expected_conditions).and_return([]) + TrackMailer.alert_tracks + end it 'should not set the no_xapian_reindex flag on the user' do @user.should_not_receive(:no_xapian_reindex=).with(true) |