aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/track_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/track_controller_spec.rb')
-rw-r--r--spec/controllers/track_controller_spec.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 5d299caa5..1d38b3055 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -1,9 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-require 'json'
-
describe TrackController, "when making a new track on a request" do
- before do
+ before(:each) do
@ir = mock_model(InfoRequest, :url_title => 'myrequest',
:title => 'My request')
@track_thing = mock_model(TrackThing, :save! => true,
@@ -11,12 +9,15 @@ describe TrackController, "when making a new track on a request" do
:track_medium= => nil,
:tracking_user_id= => nil)
TrackThing.stub!(:create_track_for_request).and_return(@track_thing)
+ TrackThing.stub!(:create_track_for_search_query).and_return(@track_thing)
TrackThing.stub!(:find_by_existing_track).and_return(nil)
InfoRequest.stub!(:find_by_url_title).and_return(@ir)
@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
@@ -25,13 +26,20 @@ describe TrackController, "when making a new track on a request" do
response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
end
- it "should save the track and redirect if you are logged in" do
+ it "should save a request track and redirect if you are logged in" do
session[:user_id] = @user.id
@track_thing.should_receive(:save!)
get :track_request, :url_title => @ir.url_title, :feed => 'track'
response.should redirect_to(:controller => 'request', :action => 'show', :url_title => @ir.url_title)
end
+ it "should save a search track and redirect to the right place" do
+ session[:user_id] = @user.id
+ @track_thing.should_receive(:save!)
+ get :track_search_query, :query_array => ["bob variety:sent"], :feed => 'track'
+ response.should redirect_to(:controller => 'general', :action => 'search', :combined => ["bob", "requests"])
+ end
+
end
describe TrackController, "when sending alerts for a track" do