message_train 0.6.17 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +16 -13
  3. data/.rubocop_todo.yml +12 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +1 -1
  6. data/Gemfile +28 -30
  7. data/README.md +284 -0
  8. data/Rakefile +6 -7
  9. data/VERSION +1 -1
  10. data/app/assets/javascripts/ckeditor/{config.js.coffee → config.js} +7 -6
  11. data/app/assets/stylesheets/message_train.scss +0 -8
  12. data/app/controllers/concerns/message_train_authorization.rb +37 -0
  13. data/app/controllers/concerns/message_train_support.rb +41 -69
  14. data/app/controllers/message_train/application_controller.rb +1 -0
  15. data/app/controllers/message_train/boxes_controller.rb +5 -4
  16. data/app/controllers/message_train/conversations_controller.rb +7 -5
  17. data/app/controllers/message_train/messages_controller.rb +43 -27
  18. data/app/controllers/message_train/participants_controller.rb +14 -25
  19. data/app/controllers/message_train/unsubscribes_controller.rb +96 -61
  20. data/app/helpers/message_train/application_helper.rb +13 -7
  21. data/app/helpers/message_train/attachments_helper.rb +4 -12
  22. data/app/helpers/message_train/boxes_helper.rb +4 -14
  23. data/app/helpers/message_train/collectives_helper.rb +23 -29
  24. data/app/helpers/message_train/conversations_helper.rb +52 -30
  25. data/app/helpers/message_train/messages_helper.rb +33 -20
  26. data/app/mailers/message_train/receipt_mailer.rb +22 -12
  27. data/app/models/message_train/attachment.rb +2 -2
  28. data/app/models/message_train/box.rb +182 -228
  29. data/app/models/message_train/conversation.rb +100 -103
  30. data/app/models/message_train/ignore.rb +83 -4
  31. data/app/models/message_train/message.rb +66 -117
  32. data/app/models/message_train/receipt.rb +73 -49
  33. data/app/views/message_train/boxes/show.html.haml +11 -7
  34. data/config/locales/en.yml +1 -0
  35. data/config/routes.rb +6 -12
  36. data/lib/message_train.rb +3 -1
  37. data/lib/message_train/class_methods.rb +51 -0
  38. data/lib/message_train/configuration.rb +28 -3
  39. data/lib/message_train/instance_methods.rb +209 -0
  40. data/lib/message_train/mixin.rb +25 -320
  41. data/message_train.gemspec +83 -83
  42. data/spec/controllers/message_train/boxes_controller_spec.rb +37 -19
  43. data/spec/controllers/message_train/concerns_spec.rb +21 -3
  44. data/spec/controllers/message_train/conversations_controller_spec.rb +41 -18
  45. data/spec/controllers/message_train/messages_controller_spec.rb +112 -31
  46. data/spec/controllers/message_train/participants_controller_spec.rb +33 -7
  47. data/spec/controllers/message_train/unsubscribes_controller_spec.rb +10 -8
  48. data/spec/dummy/app/assets/stylesheets/{application.css.scss → application.scss} +2 -1
  49. data/spec/dummy/app/assets/stylesheets/bootstrap-everything.scss +54 -0
  50. data/spec/dummy/app/models/group.rb +1 -1
  51. data/spec/dummy/app/views/layouts/application.html.haml +9 -8
  52. data/spec/dummy/bin/setup +8 -8
  53. data/spec/dummy/config/application.rb +0 -3
  54. data/spec/dummy/config/environments/test.rb +4 -2
  55. data/spec/dummy/db/schema.rb +94 -103
  56. data/spec/dummy/db/test.sqlite3 +0 -0
  57. data/spec/factories/attachment.rb +3 -1
  58. data/spec/factories/message.rb +2 -3
  59. data/spec/features/boxes_spec.rb +0 -3
  60. data/spec/helpers/message_train/application_helper_spec.rb +3 -2
  61. data/spec/helpers/message_train/attachment_helper_spec.rb +4 -0
  62. data/spec/helpers/message_train/boxes_helper_spec.rb +1 -0
  63. data/spec/helpers/message_train/collectives_helper_spec.rb +1 -0
  64. data/spec/helpers/message_train/conversations_helper_spec.rb +3 -2
  65. data/spec/helpers/message_train/messages_helper_spec.rb +2 -1
  66. data/spec/models/group_spec.rb +6 -4
  67. data/spec/models/message_train/box_spec.rb +0 -88
  68. data/spec/models/message_train/ignore_spec.rb +65 -0
  69. data/spec/models/message_train/message_spec.rb +6 -5
  70. data/spec/models/message_train/receipt_spec.rb +6 -8
  71. data/spec/models/role_spec.rb +2 -2
  72. data/spec/models/user_spec.rb +29 -101
  73. data/spec/rails_helper.rb +16 -30
  74. data/spec/support/feature_behaviors.rb +2 -1
  75. data/spec/support/shared_connection.rb +5 -0
  76. data/spec/support/utilities.rb +7 -8
  77. metadata +145 -120
  78. data/README.rdoc +0 -175
  79. data/spec/dummy/app/models/.keep +0 -0
  80. data/spec/dummy/log/.keep +0 -0
@@ -29,7 +29,7 @@ describe MessageTrain::BoxesController do
29
29
 
30
30
  describe 'GET #show' do
31
31
  before do
32
- get :show, division: 'in'
32
+ get :show, params: { division: 'in' }
33
33
  end
34
34
  it_should_behave_like 'a successful page', which_renders: 'show'
35
35
 
@@ -50,9 +50,11 @@ describe MessageTrain::BoxesController do
50
50
  before do
51
51
  put(
52
52
  :update,
53
- division: 'in',
54
- mark_to_set: 'read',
55
- objects: invalid_params
53
+ params: {
54
+ division: 'in',
55
+ mark_to_set: 'read',
56
+ objects: invalid_params
57
+ }
56
58
  )
57
59
  end
58
60
  it_should_behave_like 'a 404 Not Found error'
@@ -61,9 +63,11 @@ describe MessageTrain::BoxesController do
61
63
  before do
62
64
  put(
63
65
  :update,
64
- division: 'in',
65
- mark_to_set: 'read',
66
- objects: disallowed_params
66
+ params: {
67
+ division: 'in',
68
+ mark_to_set: 'read',
69
+ objects: disallowed_params
70
+ }
67
71
  )
68
72
  end
69
73
  it_should_behave_like(
@@ -73,15 +77,23 @@ describe MessageTrain::BoxesController do
73
77
  end
74
78
  describe 'without params' do
75
79
  before do
76
- put :update, division: 'in'
80
+ put :update, params: { division: 'in' }
77
81
  end
78
82
  it_should_behave_like 'a page with an alert message', 'Nothing to do'
79
83
  end
80
84
  describe 'with valid params' do
81
85
  before do
82
- put :update, division: 'in', mark_to_set: 'read', objects: valid_params
86
+ put(
87
+ :update,
88
+ params: {
89
+ division: 'in',
90
+ mark_to_set: 'read',
91
+ objects: valid_params
92
+ }
93
+ )
83
94
  end
84
95
  it_should_behave_like 'a page with a notice message', 'Update successful'
96
+ it_should_behave_like 'a response without error'
85
97
  end
86
98
  end
87
99
 
@@ -90,16 +102,18 @@ describe MessageTrain::BoxesController do
90
102
  before do
91
103
  delete(
92
104
  :destroy,
93
- division: 'in',
94
- mark_to_set: 'ignore',
95
- objects: invalid_params
105
+ params: {
106
+ division: 'in',
107
+ mark_to_set: 'ignore',
108
+ objects: invalid_params
109
+ }
96
110
  )
97
111
  end
98
112
  it_should_behave_like 'a 404 Not Found error'
99
113
  end
100
114
  describe 'without params' do
101
115
  before do
102
- delete :destroy, division: 'in'
116
+ delete :destroy, params: { division: 'in' }
103
117
  end
104
118
  it_should_behave_like 'a page with an alert message', 'Nothing to do'
105
119
  end
@@ -108,9 +122,11 @@ describe MessageTrain::BoxesController do
108
122
  before do
109
123
  delete(
110
124
  :destroy,
111
- division: 'in',
112
- mark_to_set: 'ignore',
113
- objects: valid_params
125
+ params: {
126
+ division: 'in',
127
+ mark_to_set: 'ignore',
128
+ objects: valid_params
129
+ }
114
130
  )
115
131
  end
116
132
  it_should_behave_like(
@@ -122,9 +138,11 @@ describe MessageTrain::BoxesController do
122
138
  before do
123
139
  delete(
124
140
  :destroy,
125
- division: 'in',
126
- mark_to_set: 'unignore',
127
- objects: valid_params
141
+ params: {
142
+ division: 'in',
143
+ mark_to_set: 'unignore',
144
+ objects: valid_params
145
+ }
128
146
  )
129
147
  end
130
148
  it_should_behave_like(
@@ -9,7 +9,13 @@ describe MessageTrain::BoxesController do
9
9
  describe 'when neither sending nor receiving is allowed' do
10
10
  before do
11
11
  login_user third_user
12
- get :show, division: 'in', collective_id: 'groups:first-group'
12
+ get(
13
+ :show,
14
+ params: {
15
+ division: 'in',
16
+ collective_id: 'groups:first-group'
17
+ }
18
+ )
13
19
  end
14
20
  it_should_behave_like(
15
21
  'a redirect with error',
@@ -21,7 +27,13 @@ describe MessageTrain::BoxesController do
21
27
  describe 'when only sending is allowed' do
22
28
  before do
23
29
  login_user first_user
24
- get :show, division: 'in', collective_id: 'groups:first-group'
30
+ get(
31
+ :show,
32
+ params: {
33
+ division: 'in',
34
+ collective_id: 'groups:first-group'
35
+ }
36
+ )
25
37
  end
26
38
  it_should_behave_like(
27
39
  'a redirect with error',
@@ -33,7 +45,13 @@ describe MessageTrain::BoxesController do
33
45
  describe 'when only receiving is allowed' do
34
46
  before do
35
47
  login_user first_user
36
- get :show, division: 'sent', collective_id: 'groups:membered-group'
48
+ get(
49
+ :show,
50
+ params: {
51
+ division: 'sent',
52
+ collective_id: 'groups:membered-group'
53
+ }
54
+ )
37
55
  end
38
56
  it_should_behave_like(
39
57
  'a redirect with error',
@@ -18,7 +18,7 @@ describe MessageTrain::ConversationsController do
18
18
 
19
19
  describe 'GET #show' do
20
20
  before do
21
- get :show, box_division: 'in', id: unread_conversation.id
21
+ get :show, params: { box_division: 'in', id: unread_conversation.id }
22
22
  end
23
23
  it_should_behave_like 'a successful page', which_renders: 'show'
24
24
 
@@ -43,17 +43,19 @@ describe MessageTrain::ConversationsController do
43
43
  before do
44
44
  put(
45
45
  :update,
46
- box_division: 'in',
47
- id: unread_conversation.id,
48
- mark_to_set: 'read',
49
- objects: invalid_params
46
+ params: {
47
+ box_division: 'in',
48
+ id: unread_conversation.id,
49
+ mark_to_set: 'read',
50
+ objects: invalid_params
51
+ }
50
52
  )
51
53
  end
52
54
  it_should_behave_like 'a 404 Not Found error'
53
55
  end
54
56
  describe 'without params' do
55
57
  before do
56
- put :update, box_division: 'in', id: unread_conversation.id
58
+ put :update, params: { box_division: 'in', id: unread_conversation.id }
57
59
  end
58
60
  it_should_behave_like 'a page with an alert message', 'Nothing to do'
59
61
  end
@@ -61,10 +63,12 @@ describe MessageTrain::ConversationsController do
61
63
  before do
62
64
  put(
63
65
  :update,
64
- box_division: 'in',
65
- id: unread_conversation.id,
66
- mark_to_set: 'read',
67
- objects: valid_params
66
+ params: {
67
+ box_division: 'in',
68
+ id: unread_conversation.id,
69
+ mark_to_set: 'read',
70
+ objects: valid_params
71
+ }
68
72
  )
69
73
  end
70
74
  it_should_behave_like 'a page with a notice message', 'Update successful'
@@ -74,13 +78,28 @@ describe MessageTrain::ConversationsController do
74
78
  describe 'DELETE #destroy' do
75
79
  describe 'with invalid params' do
76
80
  before do
77
- delete :destroy, box_division: 'in', id: 999, mark_to_set: 'ignore'
81
+ delete(
82
+ :destroy,
83
+ params:
84
+ {
85
+ box_division: 'in',
86
+ id: 999,
87
+ mark_to_set: 'ignore'
88
+ }
89
+ )
78
90
  end
79
91
  it_should_behave_like 'a 404 Not Found error'
80
92
  end
81
93
  describe 'without params' do
82
94
  before do
83
- delete :destroy, box_division: 'in', id: unread_conversation.id
95
+ delete(
96
+ :destroy,
97
+ params:
98
+ {
99
+ box_division: 'in',
100
+ id: unread_conversation.id
101
+ }
102
+ )
84
103
  end
85
104
  it_should_behave_like 'a page with an alert message', 'Nothing to do'
86
105
  end
@@ -89,9 +108,11 @@ describe MessageTrain::ConversationsController do
89
108
  before do
90
109
  delete(
91
110
  :destroy,
92
- box_division: 'in',
93
- id: unread_conversation.id,
94
- mark_to_set: 'ignore'
111
+ params: {
112
+ box_division: 'in',
113
+ id: unread_conversation.id,
114
+ mark_to_set: 'ignore'
115
+ }
95
116
  )
96
117
  end
97
118
  it_should_behave_like(
@@ -103,9 +124,11 @@ describe MessageTrain::ConversationsController do
103
124
  before do
104
125
  delete(
105
126
  :destroy,
106
- box_division: 'in',
107
- id: unread_conversation.id,
108
- mark_to_set: 'unignore'
127
+ params: {
128
+ box_division: 'in',
129
+ id: unread_conversation.id,
130
+ mark_to_set: 'unignore'
131
+ }
109
132
  )
110
133
  end
111
134
  it_should_behave_like(
@@ -21,7 +21,7 @@ describe MessageTrain::MessagesController do
21
21
  end
22
22
 
23
23
  let(:invalid_attributes) do
24
- { subject: nil }
24
+ { subject: '' }
25
25
  end
26
26
 
27
27
  before do
@@ -30,7 +30,14 @@ describe MessageTrain::MessagesController do
30
30
 
31
31
  describe 'GET #show' do
32
32
  before do
33
- get :show, box_division: 'in', id: unread_message.id, format: :json
33
+ get(
34
+ :show,
35
+ params: {
36
+ box_division: 'in',
37
+ id: unread_message.id
38
+ },
39
+ format: :json
40
+ )
34
41
  end
35
42
  it_should_behave_like 'a successful page', which_renders: 'show'
36
43
 
@@ -49,8 +56,10 @@ describe MessageTrain::MessagesController do
49
56
  before do
50
57
  get(
51
58
  :new,
52
- box_division: 'in',
53
- conversation_id: unread_message.message_train_conversation_id
59
+ params: {
60
+ box_division: 'in',
61
+ conversation_id: unread_message.message_train_conversation_id
62
+ }
54
63
  )
55
64
  end
56
65
  it_should_behave_like 'a successful page', which_renders: 'new'
@@ -70,20 +79,36 @@ describe MessageTrain::MessagesController do
70
79
  describe 'GET #edit' do
71
80
  describe 'as someone other than the owner' do
72
81
  before do
73
- get :edit, box_division: 'in', id: someone_elses_message.id
82
+ get(
83
+ :edit,
84
+ params: {
85
+ box_division: 'in',
86
+ id: someone_elses_message.id
87
+ }
88
+ )
74
89
  end
75
90
  it_should_behave_like 'a 404 Not Found error'
76
91
  end
77
92
  describe 'as the owner' do
78
93
  describe 'when message is a not a draft' do
79
94
  before do
80
- get :edit, box_division: 'in', id: unread_message.id
95
+ get(
96
+ :edit, params: {
97
+ box_division: 'in',
98
+ id: unread_message.id
99
+ }
100
+ )
81
101
  end
82
102
  it_should_behave_like 'a 404 Not Found error'
83
103
  end
84
104
  describe 'when message is a draft' do
85
105
  before do
86
- get :edit, box_division: 'in', id: draft_message.id
106
+ get(
107
+ :edit, params: {
108
+ box_division: 'in',
109
+ id: draft_message.id
110
+ }
111
+ )
87
112
  end
88
113
  it_should_behave_like 'a successful page', which_renders: 'edit'
89
114
 
@@ -99,7 +124,13 @@ describe MessageTrain::MessagesController do
99
124
  describe 'with valid attributes' do
100
125
  describe 'when draft' do
101
126
  before do
102
- post :create, box_division: 'in', message: draft_attributes
127
+ post(
128
+ :create,
129
+ params: {
130
+ box_division: 'in',
131
+ message: draft_attributes
132
+ }
133
+ )
103
134
  end
104
135
  it_should_behave_like 'a redirect to', '/box/drafts'
105
136
  it_should_behave_like 'a response without error'
@@ -111,7 +142,13 @@ describe MessageTrain::MessagesController do
111
142
  end
112
143
  describe 'when not draft' do
113
144
  before do
114
- post :create, box_division: 'in', message: valid_attributes
145
+ post(
146
+ :create,
147
+ params: {
148
+ box_division: 'in',
149
+ message: valid_attributes
150
+ }
151
+ )
115
152
  end
116
153
  it_should_behave_like 'a redirect to', '/box/sent'
117
154
  it_should_behave_like 'a response without error'
@@ -125,34 +162,62 @@ describe MessageTrain::MessagesController do
125
162
  describe 'with valid attributes, counting' do
126
163
  it 'results in a new conversation' do
127
164
  expect do
128
- post(:create, box_division: 'in', message: valid_attributes)
165
+ post(
166
+ :create,
167
+ params: {
168
+ box_division: 'in', message: valid_attributes
169
+ }
170
+ )
129
171
  end.to change { MessageTrain::Conversation.count }.by(1)
130
172
  end
131
173
  it 'results in a new message' do
132
174
  expect do
133
- post(:create, box_division: 'in', message: valid_attributes)
175
+ post(
176
+ :create,
177
+ params: {
178
+ box_division: 'in', message: valid_attributes
179
+ }
180
+ )
134
181
  end.to change { MessageTrain::Message.count }.by(1)
135
182
  end
136
183
  it 'results in new receipts' do
137
184
  expect do
138
- post(:create, box_division: 'in', message: valid_attributes)
185
+ post(
186
+ :create,
187
+ params: {
188
+ box_division: 'in', message: valid_attributes
189
+ }
190
+ )
139
191
  end.to change { MessageTrain::Receipt.count }.by(3)
140
192
  end
141
193
  it 'results in email notifications' do
142
194
  expect do
143
- post(:create, box_division: 'in', message: valid_attributes)
195
+ post(
196
+ :create,
197
+ params: {
198
+ box_division: 'in', message: valid_attributes
199
+ }
200
+ )
144
201
  end.to change { ActionMailer::Base.deliveries.count }.by(2)
145
202
  end
146
203
  end
147
204
  describe 'with invalid params' do
148
205
  before do
149
- post :create, box_division: 'in', message: invalid_attributes
206
+ post(
207
+ :create,
208
+ params: {
209
+ box_division: 'in',
210
+ message: invalid_attributes
211
+ }
212
+ )
150
213
  end
151
214
  it_should_behave_like 'a successful page', which_renders: 'new'
152
215
 
153
216
  context 'loads the given message into @message' do
154
217
  subject { assigns(:message) }
155
- it { should be_a_new(MessageTrain::Message).with(invalid_attributes) }
218
+ it do
219
+ should be_a_new(MessageTrain::Message).with(invalid_attributes)
220
+ end
156
221
  end
157
222
 
158
223
  context "sets the flash with the message's errors" do
@@ -164,7 +229,13 @@ describe MessageTrain::MessagesController do
164
229
  describe 'with invalid params, counting' do
165
230
  it 'does not result in a new message' do
166
231
  expect do
167
- post :create, box_division: 'in', message: invalid_attributes
232
+ post(
233
+ :create,
234
+ params: {
235
+ box_division: 'in',
236
+ message: invalid_attributes
237
+ }
238
+ )
168
239
  end.to_not change { MessageTrain::Message.count }
169
240
  end
170
241
  end
@@ -175,9 +246,11 @@ describe MessageTrain::MessagesController do
175
246
  before do
176
247
  put(
177
248
  :update,
178
- box_division: 'in',
179
- id: someone_elses_message.id,
180
- message: valid_attributes
249
+ params: {
250
+ box_division: 'in',
251
+ id: someone_elses_message.id,
252
+ message: valid_attributes
253
+ }
181
254
  )
182
255
  end
183
256
  it_should_behave_like 'a 404 Not Found error'
@@ -187,9 +260,11 @@ describe MessageTrain::MessagesController do
187
260
  before do
188
261
  put(
189
262
  :update,
190
- box_division: 'in',
191
- id: draft_message.id,
192
- message: invalid_attributes
263
+ params: {
264
+ box_division: 'in',
265
+ id: draft_message.id,
266
+ message: invalid_attributes
267
+ }
193
268
  )
194
269
  end
195
270
  it_should_behave_like 'a successful page', which_renders: 'edit'
@@ -211,9 +286,11 @@ describe MessageTrain::MessagesController do
211
286
  before do
212
287
  put(
213
288
  :update,
214
- box_division: 'in',
215
- id: sent_message.id,
216
- message: valid_attributes
289
+ params: {
290
+ box_division: 'in',
291
+ id: sent_message.id,
292
+ message: valid_attributes
293
+ }
217
294
  )
218
295
  end
219
296
  it_should_behave_like 'a 404 Not Found error'
@@ -223,9 +300,11 @@ describe MessageTrain::MessagesController do
223
300
  before do
224
301
  put(
225
302
  :update,
226
- box_division: 'in',
227
- id: draft_message.id,
228
- message: valid_attributes
303
+ params: {
304
+ box_division: 'in',
305
+ id: draft_message.id,
306
+ message: valid_attributes
307
+ }
229
308
  )
230
309
  end
231
310
  it_should_behave_like 'a redirect to', '/box/sent'
@@ -257,9 +336,11 @@ describe MessageTrain::MessagesController do
257
336
  before do
258
337
  put(
259
338
  :update,
260
- box_division: 'in',
261
- id: draft_message.id,
262
- message: edited_draft_message
339
+ params: {
340
+ box_division: 'in',
341
+ id: draft_message.id,
342
+ message: edited_draft_message
343
+ }
263
344
  )
264
345
  end
265
346
  it_should_behave_like(