aboutsummaryrefslogtreecommitdiffstats
path: root/spec/views/request/_after_actions.html.erb_spec.rb
blob: 833323d685e587e72130caa704bef1905555eb2b (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
require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)

describe 'when displaying actions that can be taken with regard to a request' do

    before do
        @mock_body = mock_model(PublicBody, :name => 'test public body',
                                            :url_name => 'test_public_body')
        @mock_user = mock_model(User, :name => 'test user',
                                      :url_name => 'test_user')
        @mock_request = mock_model(InfoRequest, :title => 'test request',
                                                :user => @mock_user,
                                                :user_name => @mock_user.name,
                                                :is_external? => false,
                                                :public_body => @mock_body,
                                                :comments_allowed? => true,
                                                :url_title => 'test_request',
                                                :all_can_view? => true)
        assign :info_request, @mock_request
    end

    describe 'if the request is old and unclassified' do

        before do
            assign :old_unclassified, true
        end

        it 'should not display a link for the request owner to update the status of the request' do
            render :partial => 'request/after_actions'
            response.should have_selector('div#owner_actions') do |div|
                div.should_not have_selector('a', :content => 'Update the status of this request')
            end
        end

        it 'should display a link for anyone to update the status of the request' do
            render :partial => 'request/after_actions'
            response.should have_selector('div#anyone_actions') do |div|
                div.should have_selector('a', :content => 'Update the status of this request')
            end
        end

    end

    describe 'if the request is not old and unclassified' do

        before do
            assign :old_unclassified, false
        end

        it 'should display a link for the request owner to update the status of the request' do
            render :partial => 'request/after_actions'
            response.should have_selector('div#owner_actions') do |div|
                div.should have_selector('a', :content => 'Update the status of this request')
            end
        end

        it 'should not display a link for anyone to update the status of the request' do
            render :partial => 'request/after_actions'
            response.should have_selector('div#anyone_actions') do |div|
                div.should_not have_selector('a', :content => 'Update the status of this request')
            end
        end

    end

    it 'should display a link for the request owner to request a review' do
        render :partial => 'request/after_actions'
        response.should have_selector('div#owner_actions') do |div|
            div.should have_selector('a', :content => 'Request an internal review')
        end
    end


    it 'should display the link to download the entire request' do
        render :partial => 'request/after_actions'
        response.should have_selector('div#anyone_actions') do |div|
            div.should have_selector('a', :content => 'Download a zip file of all correspondence')
        end
    end

end