aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/help_controller_spec.rb91
-rw-r--r--spec/controllers/track_controller_spec.rb6
2 files changed, 65 insertions, 32 deletions
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
index cc024f840..f92323f50 100644
--- a/spec/controllers/help_controller_spec.rb
+++ b/spec/controllers/help_controller_spec.rb
@@ -1,48 +1,81 @@
# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-describe HelpController, "when using help" do
+describe HelpController do
render_views
- it "shows the about page" do
- get :about
- end
+ describe :about do
- it "shows contact form" do
- get :contact
- end
+ it 'shows the about page' do
+ get :about
+ response.should be_success
+ response.should render_template('help/about')
+ end
- it "sends a contact message" do
- post :contact, { :contact => {
- :name => "Vinny Vanilli",
- :email => "vinny@localhost",
- :subject => "Why do I have such an ace name?",
- :message => "You really should know!!!\n\nVinny",
- }, :submitted_contact_form => 1
- }
- response.should redirect_to(:controller => 'general', :action => 'frontpage')
-
- deliveries = ActionMailer::Base.deliveries
- deliveries.size.should == 1
- deliveries[0].body.should include("really should know")
- deliveries.clear
end
- describe 'when requesting a page in a supported locale ' do
+ describe 'GET contact' do
- before do
- # Prepend our fixture templates
- fixture_theme_path = File.join(Rails.root, 'spec', 'fixtures', 'theme_views', 'theme_one')
- controller.prepend_view_path fixture_theme_path
+ it 'shows contact form' do
+ get :contact
+ response.should be_success
+ response.should render_template('help/contact')
end
- it 'should render the locale-specific template if available' do
- get :contact, {:locale => 'es'}
- response.body.should match('contáctenos theme one')
+ describe 'when requesting a page in a supported locale' do
+
+ before do
+ # Prepend our fixture templates
+ fixture_theme_path = File.join(Rails.root, 'spec', 'fixtures', 'theme_views', 'theme_one')
+ controller.prepend_view_path fixture_theme_path
+ end
+
+ it 'should render the locale-specific template if available' do
+ get :contact, {:locale => 'es'}
+ response.body.should match('contáctenos theme one')
+ end
+
end
end
+ describe 'POST contact' do
+
+ it 'sends a contact message' do
+ post :contact, { :contact => {
+ :name => 'Vinny Vanilli',
+ :email => 'vinny@localhost',
+ :subject => 'Why do I have such an ace name?',
+ :comment => '',
+ :message => "You really should know!!!\n\nVinny",
+ }, :submitted_contact_form => 1
+ }
+ response.should redirect_to(frontpage_path)
+
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 1
+ deliveries[0].body.should include('really should know')
+ deliveries.clear
+ end
+
+ it 'has rudimentary spam protection' do
+ post :contact, { :contact => {
+ :name => 'Vinny Vanilli',
+ :email => 'vinny@localhost',
+ :subject => 'Why do I have such an ace name?',
+ :comment => 'I AM A SPAMBOT',
+ :message => "You really should know!!!\n\nVinny",
+ }, :submitted_contact_form => 1
+ }
+
+ response.should redirect_to(frontpage_path)
+
+ deliveries = ActionMailer::Base.deliveries
+ deliveries.size.should == 0
+ deliveries.clear
+ end
+
+ end
end
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 40865d2b9..d2b45b6bf 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -5,7 +5,7 @@ describe TrackController, "when making a new track on a request" do
@ir = mock_model(InfoRequest, :url_title => 'myrequest',
:title => 'My request')
@track_thing = mock_model(TrackThing, :save! => true,
- :params => {:list_description => 'list description'},
+ :params => {},
:track_medium= => nil,
:tracking_user_id= => nil)
TrackThing.stub!(:create_track_for_request).and_return(@track_thing)
@@ -58,7 +58,7 @@ end
describe TrackController, "when unsubscribing from a track" do
before do
- @track_thing = FactoryGirl.create(:track_thing)
+ @track_thing = FactoryGirl.create(:search_track)
end
it 'should destroy the track thing' do
@@ -78,7 +78,7 @@ describe TrackController, "when unsubscribing from a track" do
end
it 'should not redirect to a url on another site' do
- track_thing = FactoryGirl.create(:track_thing)
+ track_thing = FactoryGirl.create(:search_track)
get :update, {:track_id => @track_thing.id,
:track_medium => 'delete',
:r => 'http://example.com/'},