aboutsummaryrefslogtreecommitdiffstats
path: root/spec/helpers/track_helper_spec.rb
blob: b6252ab39eeea3416c058a0f16e91dedd2a2d179 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe TrackHelper do

    include TrackHelper
    include LinkToHelper

    describe 'when displaying notices for a search track' do

        before do
            @track_thing = FactoryGirl.build(:search_track)
        end

        it 'should create an already subscribed_notice' do
            expected = %Q(You are already subscribed to <a href="/search/Example%20Query/newest/advanced">this search</a>.)
            already_subscribed_notice(@track_thing).should == expected
        end

        it 'should create an email subscription notice' do
            expected = %Q(You will now be emailed updates about <a href="/search/Example%20Query/newest/advanced">this search</a>.)
            subscribe_email_notice(@track_thing).should == expected
        end

        it 'should create a following subscription notice' do
            expected = %Q(You are now <a href="#{show_user_wall_path(:url_name => @track_thing.tracking_user.url_name)}">following</a> updates about <a href="/search/Example%20Query/newest/advanced">this search</a>.)
            subscribe_follow_notice(@track_thing).should == expected
        end

        it 'should create an unsubscribe notice' do
            expected = %Q(You are no longer following <a href="/search/Example%20Query/newest/advanced">this search</a>.)
            unsubscribe_notice(@track_thing).should == expected
        end

        it 'should create a description of the track' do
            expected = %Q(<a href="/search/Example%20Query/newest/advanced">anything matching text 'Example Query'</a>)
            track_description(@track_thing).should == expected
        end

    end

    describe 'when displaying notices for a user track' do

        before do
            @track_thing = FactoryGirl.build(:user_track)
        end

        it 'should create an already subscribed_notice' do
            expected = %Q(You are already subscribed to '#{user_link(@track_thing.tracked_user)}', a person.)
            already_subscribed_notice(@track_thing).should == expected
        end

        it 'should create an email subscription notice' do
            expected = %Q(You will now be emailed updates about '#{user_link(@track_thing.tracked_user)}', a person.)
            subscribe_email_notice(@track_thing).should == expected
        end

        it 'should create a following subscription notice' do
            expected = %Q(You are now <a href="#{show_user_wall_path(:url_name => @track_thing.tracking_user.url_name)}">following</a> updates about '#{user_link(@track_thing.tracked_user)}', a person.)
            subscribe_follow_notice(@track_thing).should == expected
        end

        it 'should create an unsubscribe notice' do
            expected = %Q(You are no longer following '#{user_link(@track_thing.tracked_user)}', a person.)
            unsubscribe_notice(@track_thing).should == expected
        end

        it 'should create a description of the track' do
            expected = %Q('#{user_link(@track_thing.tracked_user)}', a person)
            track_description(@track_thing).should == expected
        end

    end

    describe 'when displaying notices for a public body track' do

        before do
            @track_thing = FactoryGirl.build(:public_body_track)
        end

        it 'should create an already subscribed_notice' do
            expected = %Q(You are already subscribed to '#{public_body_link(@track_thing.public_body)}', a public authority.)
            already_subscribed_notice(@track_thing).should == expected
        end

        it 'should create an email subscription notice' do
            expected = %Q(You will now be emailed updates about '#{public_body_link(@track_thing.public_body)}', a public authority.)
            subscribe_email_notice(@track_thing).should == expected
        end

        it 'should create a following subscription notice' do
            expected = %Q(You are now <a href="#{show_user_wall_path(:url_name => @track_thing.tracking_user.url_name)}">following</a> updates about '#{public_body_link(@track_thing.public_body)}', a public authority.)
            subscribe_follow_notice(@track_thing).should == expected
        end

        it 'should create an unsubscribe notice' do
            expected = %Q(You are no longer following '#{public_body_link(@track_thing.public_body)}', a public authority.)
            unsubscribe_notice(@track_thing).should == expected
        end

        it 'should create a description of the track' do
            expected = %Q('#{public_body_link(@track_thing.public_body)}', a public authority)
            track_description(@track_thing).should == expected
        end
    end

    describe 'when displaying notices for a successful request track' do

        before do
            @track_thing = FactoryGirl.build(:successful_request_track)
        end

        it 'should create an already subscribed_notice' do
            expected = %Q(You are already subscribed to any <a href="/list/successful">successful requests</a>.)
            already_subscribed_notice(@track_thing).should == expected
        end

        it 'should create an email subscription notice' do
            expected = %Q(You will now be emailed updates about <a href="/list/successful">successful requests</a>.)
            subscribe_email_notice(@track_thing).should == expected
        end

        it 'should create a following subscription notice' do
            expected = %Q(You are now <a href="#{show_user_wall_path(:url_name => @track_thing.tracking_user.url_name)}">following</a> updates about <a href="/list/successful">successful requests</a>.)
            subscribe_follow_notice(@track_thing).should == expected
        end

        it 'should create an unsubscribe notice' do
            expected = %Q(You are no longer following <a href="/list/successful">successful requests</a>.)
            unsubscribe_notice(@track_thing).should == expected
        end

        it 'should create a description of the track' do
            expected = %Q(<a href="/list/successful">successful requests</a>)
            track_description(@track_thing).should == expected
        end
    end

    describe 'when displaying notices for a new request track' do

        before do
            @track_thing = FactoryGirl.build(:new_request_track)
        end

        it 'should create an already subscribed_notice' do
            expected = %Q(You are already subscribed to any <a href="/list">new requests</a>.)
            already_subscribed_notice(@track_thing).should == expected
        end

        it 'should create an email subscription notice' do
            expected = %Q(You will now be emailed updates about any <a href="/list">new requests</a>.)
            subscribe_email_notice(@track_thing).should == expected
        end

        it 'should create a following subscription notice' do
            expected = %Q(You are now <a href="#{show_user_wall_path(:url_name => @track_thing.tracking_user.url_name)}">following</a> updates about <a href="/list">new requests</a>.)
            subscribe_follow_notice(@track_thing).should == expected
        end

        it 'should create an unsubscribe notice' do
            expected = %Q(You are no longer following <a href="/list">new requests</a>.)
            unsubscribe_notice(@track_thing).should == expected
        end

        it 'should create a description of the track' do
            expected = %Q(<a href="/list">new requests</a>)
            track_description(@track_thing).should == expected
        end

    end

    describe 'when displaying notices for a request update track' do

        before do
            @track_thing = FactoryGirl.build(:request_update_track)
        end

        it 'should create an already subscribed_notice' do
            expected = %Q(You are already subscribed to '#{request_link(@track_thing.info_request)}', a request.)
            already_subscribed_notice(@track_thing).should == expected
        end

        it 'should create an email subscription notice' do
            expected = %Q(You will now be emailed updates about '#{request_link(@track_thing.info_request)}', a request.)
            subscribe_email_notice(@track_thing).should == expected
        end

        it 'should create a following subscription notice' do
            expected = %Q(You are now <a href="#{show_user_wall_path(:url_name => @track_thing.tracking_user.url_name)}">following</a> updates about '#{request_link(@track_thing.info_request)}', a request.)
            subscribe_follow_notice(@track_thing).should == expected
        end

        it 'should create an unsubscribe notice' do
            expected = %Q(You are no longer following '#{request_link(@track_thing.info_request)}', a request.)
            unsubscribe_notice(@track_thing).should == expected
        end

        it 'should create a description of the track' do
            expected = %Q('#{request_link(@track_thing.info_request)}', a request)
            track_description(@track_thing).should == expected
        end

    end

end