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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42692f5c51ab55c5852ca3dd7267a8c47318bd62
4
- data.tar.gz: d93268aa7873e9fe0aee0d0ee167d5dbeb41378c
3
+ metadata.gz: 8a2c377d43781cce09f5e65df49223fe39d73628
4
+ data.tar.gz: a5960f20c1a0fa13d0382e504494aae501e0d0c0
5
5
  SHA512:
6
- metadata.gz: dd08ada85e6210519c127847ea952bafcb2257a590055be66b954b7c48f42fa954ca85178420e17e8969df41cc45f101665d5ec4c455013adac6696416804b44
7
- data.tar.gz: 17437037fc4e76a80dd0424759565de99f324a53177355a7704b9437b63ade9263db5a8b928c773fb51f9498104505885a6db95bb2aefab4c55bed909699da06
6
+ metadata.gz: 3a6abd68e26f585cdd020a144bb9bfecff773f8b3f107cd799a787810832ba49cf1273f958a80cbda4e720d42d57902a67437711a1e298ca33d43496ce2f7778
7
+ data.tar.gz: ecc771f18dc1d434112b5f3774173f776cd95da834a16f8bea8f3ff789fc9df44e62c89508ffd2410c3bc5f324b591ef0cff118a51978cd8d5f0ce4343f5b476
@@ -170,4 +170,10 @@ class MessagesController < ApplicationController
170
170
  parent
171
171
  end
172
172
  end
173
+
174
+ def filtered_params
175
+ params.permit([:view, :format, :page, :mode, :sort_by, :per_page])
176
+ end
177
+
178
+ helper_method :filtered_params
173
179
  end
@@ -26,16 +26,13 @@ class MessageRequest < ActiveRecord::Base
26
26
  def send_message
27
27
  message = nil
28
28
  MessageRequest.transaction do
29
- if body
30
- message = Message.new
31
- message.sender = sender
32
- message.recipient = receiver.username
33
- message.subject = subject
34
- message.body = body
35
- message.save!
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
- self.update_attributes!({body: message_template.embed_body(options)})
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(params.merge(page: nil, mode: 'unread', only_path: true)) -%>
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(params.merge(page: nil, mode: 'read', only_path: true)) -%>
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(params.merge(mode: nil, page: nil, only_path: true)) -%></li>
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
 
@@ -1,3 +1,3 @@
1
1
  module EnjuMessage
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -5,269 +5,269 @@ describe MessageRequestsController do
5
5
  fixtures :all
6
6
  disconnect_sunspot
7
7
 
8
- describe "GET index" do
9
- describe "When logged in as Administrator" do
8
+ describe 'GET index' do
9
+ describe 'When logged in as Administrator' do
10
10
  login_fixture_admin
11
11
 
12
- it "assigns all message_requests as @message_requests" do
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 "When logged in as Librarian" do
18
+ describe 'When logged in as Librarian' do
19
19
  login_fixture_librarian
20
20
 
21
- it "assigns all message_requests as @message_requests" do
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 "When logged in as User" do
27
+ describe 'When logged in as User' do
28
28
  login_fixture_user
29
29
 
30
- it "assigns all message_requests as @message_requests" do
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 "When not logged in" do
37
- it "assigns all message_requests as @message_requests" do
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 "GET show" do
45
- describe "When logged in as Administrator" do
44
+ describe 'GET show' do
45
+ describe 'When logged in as Administrator' do
46
46
  login_fixture_admin
47
47
 
48
- it "assigns the requested message_request as @message_request" do
48
+ it 'assigns the requested message_request as @message_request' do
49
49
  message_request = FactoryGirl.create(:message_request)
50
- get :show, :id => message_request.id
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 "When logged in as Librarian" do
55
+ describe 'When logged in as Librarian' do
56
56
  login_fixture_librarian
57
57
 
58
- it "assigns the requested message_request as @message_request" do
58
+ it 'assigns the requested message_request as @message_request' do
59
59
  message_request = FactoryGirl.create(:message_request)
60
- get :show, :id => message_request.id
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 "When logged in as User" do
65
+ describe 'When logged in as User' do
66
66
  login_fixture_user
67
67
 
68
- it "assigns the requested message_request as @message_request" do
68
+ it 'assigns the requested message_request as @message_request' do
69
69
  message_request = FactoryGirl.create(:message_request)
70
- get :show, :id => message_request.id
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 "When not logged in" do
76
- it "assigns the requested message_request as @message_request" do
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, :id => message_request.id
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 "GET edit" do
85
- describe "When logged in as Administrator" do
84
+ describe 'GET edit' do
85
+ describe 'When logged in as Administrator' do
86
86
  login_fixture_admin
87
87
 
88
- it "assigns the requested message_request as @message_request" do
88
+ it 'assigns the requested message_request as @message_request' do
89
89
  message_request = FactoryGirl.create(:message_request)
90
- get :edit, :id => message_request.id
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 "When logged in as Librarian" do
95
+ describe 'When logged in as Librarian' do
96
96
  login_fixture_librarian
97
97
 
98
- it "assigns the requested message_request as @message_request" do
98
+ it 'assigns the requested message_request as @message_request' do
99
99
  message_request = FactoryGirl.create(:message_request)
100
- get :edit, :id => message_request.id
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 "When logged in as User" do
105
+ describe 'When logged in as User' do
106
106
  login_fixture_user
107
107
 
108
- it "assigns the requested message_request as @message_request" do
108
+ it 'assigns the requested message_request as @message_request' do
109
109
  message_request = FactoryGirl.create(:message_request)
110
- get :edit, :id => message_request.id
110
+ get :edit, id: message_request.id
111
111
  response.should be_forbidden
112
112
  end
113
113
  end
114
114
 
115
- describe "When not logged in" do
116
- it "should not assign the requested message_request as @message_request" do
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, :id => message_request.id
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 "PUT update" do
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(:body => 'test')
128
- @invalid_attrs = {:body => ''}
127
+ @attrs = FactoryGirl.attributes_for(:message_request).merge(body: 'test')
128
+ @invalid_attrs = { body: '' }
129
129
  end
130
130
 
131
- describe "When logged in as Administrator" do
131
+ describe 'When logged in as Administrator' do
132
132
  login_fixture_admin
133
133
 
134
- describe "with valid params" do
135
- it "updates the requested message_request" do
136
- put :update, :id => @message_request.id, :message_request => @attrs
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 "assigns the requested message_request as @message_request" do
140
- put :update, :id => @message_request.id, :message_request => @attrs
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 "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")
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 "When logged in as Librarian" do
153
+ describe 'When logged in as Librarian' do
154
154
  login_fixture_librarian
155
155
 
156
- describe "with valid params" do
157
- it "updates the requested message_request" do
158
- put :update, :id => @message_request.id, :message_request => @attrs
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 "assigns the requested message_request as @message_request" do
162
- put :update, :id => @message_request.id, :message_request => @attrs
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 "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")
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 "When logged in as User" do
176
+ describe 'When logged in as User' do
177
177
  login_fixture_user
178
178
 
179
- describe "with valid params" do
180
- it "updates the requested message_request" do
181
- put :update, :id => @message_request.id, :message_request => @attrs
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 "assigns the requested message_request as @message_request" do
185
- put :update, :id => @message_request.id, :message_request => @attrs
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 "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
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 "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
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 "should be forbidden" do
206
- put :update, :id => @message_request.id, :message_request => @attrs
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 "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
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 "DELETE destroy" do
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 "When logged in as Administrator" do
225
+ describe 'When logged in as Administrator' do
226
226
  login_fixture_admin
227
227
 
228
- it "destroys the requested message_request" do
229
- delete :destroy, :id => @message_request.id
228
+ it 'destroys the requested message_request' do
229
+ delete :destroy, id: @message_request.id
230
230
  end
231
231
 
232
- it "redirects to the harvesting_requests list" do
233
- delete :destroy, :id => @message_request.id
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 "When logged in as Librarian" do
238
+ describe 'When logged in as Librarian' do
239
239
  login_fixture_librarian
240
240
 
241
- it "destroys the requested message_request" do
242
- delete :destroy, :id => @message_request.id
241
+ it 'destroys the requested message_request' do
242
+ delete :destroy, id: @message_request.id
243
243
  end
244
244
 
245
- it "redirects to the harvesting_requests list" do
246
- delete :destroy, :id => @message_request.id
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 "When logged in as User" do
251
+ describe 'When logged in as User' do
252
252
  login_fixture_user
253
253
 
254
- it "destroys the requested message_request" do
255
- delete :destroy, :id => @message_request.id
254
+ it 'destroys the requested message_request' do
255
+ delete :destroy, id: @message_request.id
256
256
  end
257
257
 
258
- it "should be forbidden" do
259
- delete :destroy, :id => @message_request.id
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 "When not logged in" do
265
- it "destroys the requested message_request" do
266
- delete :destroy, :id => @message_request.id
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 "should be forbidden" do
270
- delete :destroy, :id => @message_request.id
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