enju_message 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/messages_controller.rb +6 -0
- data/app/models/message_request.rb +8 -11
- data/app/views/messages/index.html.erb +3 -3
- data/lib/enju_message/version.rb +1 -1
- data/spec/controllers/message_requests_controller_spec.rb +97 -97
- data/spec/controllers/message_templates_controller_spec.rb +152 -152
- data/spec/controllers/messages_controller_spec.rb +206 -206
- data/spec/dummy/db/schema.rb +106 -153
- data/spec/fixtures/message_request_transitions.yml +20 -0
- data/spec/models/message_request_spec.rb +1 -2
- data/spec/models/message_spec.rb +9 -9
- data/spec/models/message_template_spec.rb +1 -2
- data/spec/views/messages/index.html.erb_spec.rb +25 -0
- metadata +189 -199
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a2c377d43781cce09f5e65df49223fe39d73628
|
4
|
+
data.tar.gz: a5960f20c1a0fa13d0382e504494aae501e0d0c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a6abd68e26f585cdd020a144bb9bfecff773f8b3f107cd799a787810832ba49cf1273f958a80cbda4e720d42d57902a67437711a1e298ca33d43496ce2f7778
|
7
|
+
data.tar.gz: ecc771f18dc1d434112b5f3774173f776cd95da834a16f8bea8f3ff789fc9df44e62c89508ffd2410c3bc5f324b591ef0cff118a51978cd8d5f0ce4343f5b476
|
@@ -26,16 +26,13 @@ class MessageRequest < ActiveRecord::Base
|
|
26
26
|
def send_message
|
27
27
|
message = nil
|
28
28
|
MessageRequest.transaction do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
else
|
37
|
-
raise 'body is empty!'
|
38
|
-
end
|
29
|
+
message = Message.new
|
30
|
+
message.sender = sender
|
31
|
+
message.recipient = receiver.username
|
32
|
+
message.subject = subject
|
33
|
+
message.body = body
|
34
|
+
message.body = 'test'
|
35
|
+
message.save!
|
39
36
|
self.sent_at = Time.zone.now
|
40
37
|
save(validate: false)
|
41
38
|
if ['reservation_expired_for_patron', 'reservation_expired_for_patron'].include?(message_template.status)
|
@@ -57,7 +54,7 @@ class MessageRequest < ActiveRecord::Base
|
|
57
54
|
receiver: receiver,
|
58
55
|
locale: receiver.profile.locale
|
59
56
|
}.merge(options)
|
60
|
-
|
57
|
+
update_attributes!({body: message_template.embed_body(options)})
|
61
58
|
end
|
62
59
|
|
63
60
|
def self.send_messages
|
@@ -48,18 +48,18 @@
|
|
48
48
|
<% mode = params[:mode].to_s %>
|
49
49
|
<li>
|
50
50
|
<%- if mode == 'unread' -%><strong><%- end -%>
|
51
|
-
<%= link_to t('message.unread'), url_for(
|
51
|
+
<%= link_to t('message.unread'), url_for(filtered_params.merge(page: nil, mode: 'unread', only_path: true)) -%>
|
52
52
|
(<%= @message_facet['false'].to_i -%>)
|
53
53
|
<%- if mode == 'unread' -%></strong><%- end -%>
|
54
54
|
</li>
|
55
55
|
<li>
|
56
56
|
<%- if mode == 'read' -%><strong><%- end -%>
|
57
|
-
<%= link_to t('message.read'), url_for(
|
57
|
+
<%= link_to t('message.read'), url_for(filtered_params.merge(page: nil, mode: 'read', only_path: true)) -%>
|
58
58
|
(<%= @message_facet['true'].to_i -%>)
|
59
59
|
<%- if mode == 'read' -%></strong><%- end -%>
|
60
60
|
</li>
|
61
61
|
<% if mode.present? %>
|
62
|
-
<li><%= link_to t('page.remove_this_facet'), url_for(
|
62
|
+
<li><%= link_to t('page.remove_this_facet'), url_for(filtered_params.merge(mode: nil, page: nil, only_path: true)) -%></li>
|
63
63
|
<% end %>
|
64
64
|
</ul>
|
65
65
|
|
data/lib/enju_message/version.rb
CHANGED
@@ -5,269 +5,269 @@ describe MessageRequestsController do
|
|
5
5
|
fixtures :all
|
6
6
|
disconnect_sunspot
|
7
7
|
|
8
|
-
describe
|
9
|
-
describe
|
8
|
+
describe 'GET index' do
|
9
|
+
describe 'When logged in as Administrator' do
|
10
10
|
login_fixture_admin
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'assigns all message_requests as @message_requests' do
|
13
13
|
get :index
|
14
14
|
assigns(:message_requests).should eq(MessageRequest.not_sent.order('created_at DESC').page(1))
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
18
|
+
describe 'When logged in as Librarian' do
|
19
19
|
login_fixture_librarian
|
20
20
|
|
21
|
-
it
|
21
|
+
it 'assigns all message_requests as @message_requests' do
|
22
22
|
get :index
|
23
23
|
assigns(:message_requests).should eq(MessageRequest.not_sent.order('created_at DESC').page(1))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
27
|
+
describe 'When logged in as User' do
|
28
28
|
login_fixture_user
|
29
29
|
|
30
|
-
it
|
30
|
+
it 'assigns all message_requests as @message_requests' do
|
31
31
|
get :index
|
32
32
|
assigns(:message_requests).should be_nil
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
it
|
36
|
+
describe 'When not logged in' do
|
37
|
+
it 'assigns all message_requests as @message_requests' do
|
38
38
|
get :index
|
39
39
|
assigns(:message_requests).should be_nil
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
45
|
-
describe
|
44
|
+
describe 'GET show' do
|
45
|
+
describe 'When logged in as Administrator' do
|
46
46
|
login_fixture_admin
|
47
47
|
|
48
|
-
it
|
48
|
+
it 'assigns the requested message_request as @message_request' do
|
49
49
|
message_request = FactoryGirl.create(:message_request)
|
50
|
-
get :show, :
|
50
|
+
get :show, id: message_request.id
|
51
51
|
assigns(:message_request).should eq(message_request)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe
|
55
|
+
describe 'When logged in as Librarian' do
|
56
56
|
login_fixture_librarian
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'assigns the requested message_request as @message_request' do
|
59
59
|
message_request = FactoryGirl.create(:message_request)
|
60
|
-
get :show, :
|
60
|
+
get :show, id: message_request.id
|
61
61
|
assigns(:message_request).should eq(message_request)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
describe
|
65
|
+
describe 'When logged in as User' do
|
66
66
|
login_fixture_user
|
67
67
|
|
68
|
-
it
|
68
|
+
it 'assigns the requested message_request as @message_request' do
|
69
69
|
message_request = FactoryGirl.create(:message_request)
|
70
|
-
get :show, :
|
70
|
+
get :show, id: message_request.id
|
71
71
|
assigns(:message_request).should eq(message_request)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
76
|
-
it
|
75
|
+
describe 'When not logged in' do
|
76
|
+
it 'assigns the requested message_request as @message_request' do
|
77
77
|
message_request = FactoryGirl.create(:message_request)
|
78
|
-
get :show, :
|
78
|
+
get :show, id: message_request.id
|
79
79
|
assigns(:message_request).should eq(message_request)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
describe
|
85
|
-
describe
|
84
|
+
describe 'GET edit' do
|
85
|
+
describe 'When logged in as Administrator' do
|
86
86
|
login_fixture_admin
|
87
87
|
|
88
|
-
it
|
88
|
+
it 'assigns the requested message_request as @message_request' do
|
89
89
|
message_request = FactoryGirl.create(:message_request)
|
90
|
-
get :edit, :
|
90
|
+
get :edit, id: message_request.id
|
91
91
|
assigns(:message_request).should eq(message_request)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
describe
|
95
|
+
describe 'When logged in as Librarian' do
|
96
96
|
login_fixture_librarian
|
97
97
|
|
98
|
-
it
|
98
|
+
it 'assigns the requested message_request as @message_request' do
|
99
99
|
message_request = FactoryGirl.create(:message_request)
|
100
|
-
get :edit, :
|
100
|
+
get :edit, id: message_request.id
|
101
101
|
assigns(:message_request).should eq(message_request)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
describe
|
105
|
+
describe 'When logged in as User' do
|
106
106
|
login_fixture_user
|
107
107
|
|
108
|
-
it
|
108
|
+
it 'assigns the requested message_request as @message_request' do
|
109
109
|
message_request = FactoryGirl.create(:message_request)
|
110
|
-
get :edit, :
|
110
|
+
get :edit, id: message_request.id
|
111
111
|
response.should be_forbidden
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
describe
|
116
|
-
it
|
115
|
+
describe 'When not logged in' do
|
116
|
+
it 'should not assign the requested message_request as @message_request' do
|
117
117
|
message_request = FactoryGirl.create(:message_request)
|
118
|
-
get :edit, :
|
118
|
+
get :edit, id: message_request.id
|
119
119
|
response.should redirect_to(new_user_session_url)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe
|
124
|
+
describe 'PUT update' do
|
125
125
|
before(:each) do
|
126
126
|
@message_request = FactoryGirl.create(:message_request)
|
127
|
-
@attrs = FactoryGirl.attributes_for(:message_request).merge(:
|
128
|
-
@invalid_attrs = {:
|
127
|
+
@attrs = FactoryGirl.attributes_for(:message_request).merge(body: 'test')
|
128
|
+
@invalid_attrs = { body: '' }
|
129
129
|
end
|
130
130
|
|
131
|
-
describe
|
131
|
+
describe 'When logged in as Administrator' do
|
132
132
|
login_fixture_admin
|
133
133
|
|
134
|
-
describe
|
135
|
-
it
|
136
|
-
put :update, :
|
134
|
+
describe 'with valid params' do
|
135
|
+
it 'updates the requested message_request' do
|
136
|
+
put :update, id: @message_request.id, message_request: @attrs
|
137
137
|
end
|
138
138
|
|
139
|
-
it
|
140
|
-
put :update, :
|
139
|
+
it 'assigns the requested message_request as @message_request' do
|
140
|
+
put :update, id: @message_request.id, message_request: @attrs
|
141
141
|
assigns(:message_request).should eq(@message_request)
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
describe
|
146
|
-
it
|
147
|
-
put :update, :
|
148
|
-
response.should render_template(
|
145
|
+
describe 'with invalid params' do
|
146
|
+
it 'assigns the requested message_request as @message_request' do
|
147
|
+
put :update, id: @message_request.id, message_request: @invalid_attrs
|
148
|
+
response.should render_template('edit')
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
describe
|
153
|
+
describe 'When logged in as Librarian' do
|
154
154
|
login_fixture_librarian
|
155
155
|
|
156
|
-
describe
|
157
|
-
it
|
158
|
-
put :update, :
|
156
|
+
describe 'with valid params' do
|
157
|
+
it 'updates the requested message_request' do
|
158
|
+
put :update, id: @message_request.id, message_request: @attrs
|
159
159
|
end
|
160
160
|
|
161
|
-
it
|
162
|
-
put :update, :
|
161
|
+
it 'assigns the requested message_request as @message_request' do
|
162
|
+
put :update, id: @message_request.id, message_request: @attrs
|
163
163
|
assigns(:message_request).should eq(@message_request)
|
164
164
|
response.should redirect_to(@message_request)
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
describe
|
169
|
-
it
|
170
|
-
put :update, :
|
171
|
-
response.should render_template(
|
168
|
+
describe 'with invalid params' do
|
169
|
+
it 'assigns the requested message_request as @message_request' do
|
170
|
+
put :update, id: @message_request.id, message_request: @invalid_attrs
|
171
|
+
response.should render_template('edit')
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
-
describe
|
176
|
+
describe 'When logged in as User' do
|
177
177
|
login_fixture_user
|
178
178
|
|
179
|
-
describe
|
180
|
-
it
|
181
|
-
put :update, :
|
179
|
+
describe 'with valid params' do
|
180
|
+
it 'updates the requested message_request' do
|
181
|
+
put :update, id: @message_request.id, message_request: @attrs
|
182
182
|
end
|
183
183
|
|
184
|
-
it
|
185
|
-
put :update, :
|
184
|
+
it 'assigns the requested message_request as @message_request' do
|
185
|
+
put :update, id: @message_request.id, message_request: @attrs
|
186
186
|
assigns(:message_request).should eq(@message_request)
|
187
187
|
response.should be_forbidden
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
describe
|
192
|
-
it
|
193
|
-
put :update, :
|
191
|
+
describe 'with invalid params' do
|
192
|
+
it 'assigns the requested message_request as @message_request' do
|
193
|
+
put :update, id: @message_request.id, message_request: @invalid_attrs
|
194
194
|
response.should be_forbidden
|
195
195
|
end
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
describe
|
200
|
-
describe
|
201
|
-
it
|
202
|
-
put :update, :
|
199
|
+
describe 'When not logged in' do
|
200
|
+
describe 'with valid params' do
|
201
|
+
it 'updates the requested message_request' do
|
202
|
+
put :update, id: @message_request.id, message_request: @attrs
|
203
203
|
end
|
204
204
|
|
205
|
-
it
|
206
|
-
put :update, :
|
205
|
+
it 'should be forbidden' do
|
206
|
+
put :update, id: @message_request.id, message_request: @attrs
|
207
207
|
response.should redirect_to(new_user_session_url)
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
-
describe
|
212
|
-
it
|
213
|
-
put :update, :
|
211
|
+
describe 'with invalid params' do
|
212
|
+
it 'assigns the requested message_request as @message_request' do
|
213
|
+
put :update, id: @message_request.id, message_request: @invalid_attrs
|
214
214
|
response.should redirect_to(new_user_session_url)
|
215
215
|
end
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
|
-
describe
|
220
|
+
describe 'DELETE destroy' do
|
221
221
|
before(:each) do
|
222
222
|
@message_request = FactoryGirl.create(:message_request)
|
223
223
|
end
|
224
224
|
|
225
|
-
describe
|
225
|
+
describe 'When logged in as Administrator' do
|
226
226
|
login_fixture_admin
|
227
227
|
|
228
|
-
it
|
229
|
-
delete :destroy, :
|
228
|
+
it 'destroys the requested message_request' do
|
229
|
+
delete :destroy, id: @message_request.id
|
230
230
|
end
|
231
231
|
|
232
|
-
it
|
233
|
-
delete :destroy, :
|
232
|
+
it 'redirects to the harvesting_requests list' do
|
233
|
+
delete :destroy, id: @message_request.id
|
234
234
|
response.should redirect_to(message_requests_url)
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
-
describe
|
238
|
+
describe 'When logged in as Librarian' do
|
239
239
|
login_fixture_librarian
|
240
240
|
|
241
|
-
it
|
242
|
-
delete :destroy, :
|
241
|
+
it 'destroys the requested message_request' do
|
242
|
+
delete :destroy, id: @message_request.id
|
243
243
|
end
|
244
244
|
|
245
|
-
it
|
246
|
-
delete :destroy, :
|
245
|
+
it 'redirects to the harvesting_requests list' do
|
246
|
+
delete :destroy, id: @message_request.id
|
247
247
|
response.should redirect_to(message_requests_url)
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
|
-
describe
|
251
|
+
describe 'When logged in as User' do
|
252
252
|
login_fixture_user
|
253
253
|
|
254
|
-
it
|
255
|
-
delete :destroy, :
|
254
|
+
it 'destroys the requested message_request' do
|
255
|
+
delete :destroy, id: @message_request.id
|
256
256
|
end
|
257
257
|
|
258
|
-
it
|
259
|
-
delete :destroy, :
|
258
|
+
it 'should be forbidden' do
|
259
|
+
delete :destroy, id: @message_request.id
|
260
260
|
response.should be_forbidden
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
|
-
describe
|
265
|
-
it
|
266
|
-
delete :destroy, :
|
264
|
+
describe 'When not logged in' do
|
265
|
+
it 'destroys the requested message_request' do
|
266
|
+
delete :destroy, id: @message_request.id
|
267
267
|
end
|
268
268
|
|
269
|
-
it
|
270
|
-
delete :destroy, :
|
269
|
+
it 'should be forbidden' do
|
270
|
+
delete :destroy, id: @message_request.id
|
271
271
|
response.should redirect_to(new_user_session_url)
|
272
272
|
end
|
273
273
|
end
|