aboutsummaryrefslogtreecommitdiffstats
path: root/spec/helpers/application_helper_spec.rb
blob: 6407eaf3a17b1e694e17309fc1de46e06b93beb3 (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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ApplicationHelper do

    include ApplicationHelper
    include LinkToHelper

    describe 'when creating an event description' do

        it 'should generate a description for a request' do
            @info_request = FactoryGirl.create(:info_request)
            @sent_event = @info_request.get_last_event
            expected = "Request sent to #{public_body_link_absolute(@info_request.public_body)} by #{request_user_link_absolute(@info_request)}"
            event_description(@sent_event).should match(expected)

        end

        it 'should generate a description for a response' do
            @info_request_with_incoming = FactoryGirl.create(:info_request_with_incoming)
            @response_event = @info_request_with_incoming.get_last_event
            expected = "Response by #{public_body_link_absolute(@info_request_with_incoming.public_body)} to #{request_user_link_absolute(@info_request_with_incoming)}"
            event_description(@response_event).should match(expected)
        end

        it 'should generate a description for a request where an internal review has been requested' do
            @info_request_with_internal_review_request = FactoryGirl.create(:info_request_with_internal_review_request)
            @response_event = @info_request_with_internal_review_request.get_last_event
            expected = "Internal review request sent to #{public_body_link_absolute(@info_request_with_internal_review_request.public_body)} by #{request_user_link_absolute(@info_request_with_internal_review_request)}"
            event_description(@response_event).should match(expected)
        end

    end

end