aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/help_controller_spec.rb
blob: f92323f506029b9c31aaea0dbf41a505158b0a90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe HelpController do
    render_views

    describe :about do

        it 'shows the about page' do
            get :about
            response.should be_success
            response.should render_template('help/about')
        end

    end

    describe 'GET contact' do

        it 'shows contact form' do
            get :contact
            response.should be_success
            response.should render_template('help/contact')
        end

        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