message_train 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -0
  3. data/.ruby-gemset +1 -1
  4. data/.scss-lint.yml +7 -0
  5. data/.simplecov +1 -1
  6. data/.travis.yml +1 -1
  7. data/Gemfile +6 -2
  8. data/LICENSE.txt +2 -2
  9. data/README.rdoc +5 -5
  10. data/Rakefile +22 -21
  11. data/VERSION +1 -1
  12. data/app/assets/javascripts/message_train.js +1 -1
  13. data/app/assets/stylesheets/message_train.scss +29 -19
  14. data/app/controllers/concerns/message_train_support.rb +41 -37
  15. data/app/controllers/message_train/application_controller.rb +1 -0
  16. data/app/controllers/message_train/boxes_controller.rb +5 -4
  17. data/app/controllers/message_train/conversations_controller.rb +8 -7
  18. data/app/controllers/message_train/messages_controller.rb +25 -22
  19. data/app/controllers/message_train/participants_controller.rb +27 -23
  20. data/app/controllers/message_train/unsubscribes_controller.rb +37 -23
  21. data/app/helpers/message_train/application_helper.rb +6 -8
  22. data/app/helpers/message_train/attachments_helper.rb +12 -4
  23. data/app/helpers/message_train/boxes_helper.rb +38 -11
  24. data/app/helpers/message_train/collectives_helper.rb +38 -12
  25. data/app/helpers/message_train/conversations_helper.rb +43 -35
  26. data/app/helpers/message_train/messages_helper.rb +32 -25
  27. data/app/mailers/message_train/application_mailer.rb +7 -4
  28. data/app/mailers/message_train/previews/receipt_mailer_preview.rb +2 -3
  29. data/app/mailers/message_train/receipt_mailer.rb +14 -4
  30. data/app/models/message_train/attachment.rb +41 -25
  31. data/app/models/message_train/box.rb +159 -122
  32. data/app/models/message_train/conversation.rb +84 -41
  33. data/app/models/message_train/ignore.rb +8 -2
  34. data/app/models/message_train/message.rb +72 -42
  35. data/app/models/message_train/receipt.rb +30 -17
  36. data/app/models/message_train/unsubscribe.rb +1 -0
  37. data/app/views/application/404.html.haml +1 -1
  38. data/app/views/layouts/mailer.html.haml +2 -2
  39. data/app/views/layouts/mailer.text.haml +1 -1
  40. data/app/views/message_train/application/_attachment_fields.html.haml +1 -1
  41. data/app/views/message_train/application/_widget.html.haml +1 -1
  42. data/app/views/message_train/application/results.json.jbuilder +1 -1
  43. data/app/views/message_train/boxes/_dropdown_list.html.haml +1 -1
  44. data/app/views/message_train/boxes/_list_item.html.haml +1 -1
  45. data/app/views/message_train/boxes/show.html.haml +1 -1
  46. data/app/views/message_train/collectives/_dropdown_list.html.haml +1 -1
  47. data/app/views/message_train/collectives/_list_item.html.haml +1 -1
  48. data/app/views/message_train/conversations/_deleted_toggle.html.haml +1 -1
  49. data/app/views/message_train/conversations/_ignored_toggle.html.haml +2 -2
  50. data/app/views/message_train/conversations/_read_toggle.html.haml +1 -1
  51. data/app/views/message_train/conversations/_toggle.html.haml +1 -1
  52. data/app/views/message_train/conversations/_trashed_toggle.html.haml +1 -1
  53. data/app/views/message_train/conversations/show.html.haml +2 -2
  54. data/app/views/message_train/conversations/show.json.jbuilder +5 -1
  55. data/app/views/message_train/messages/_form.html.haml +1 -1
  56. data/app/views/message_train/messages/_message.html.haml +6 -6
  57. data/app/views/message_train/messages/_toggle.html.haml +1 -1
  58. data/app/views/message_train/messages/show.json.jbuilder +5 -1
  59. data/app/views/message_train/participants/_participant.json.jbuilder +1 -1
  60. data/app/views/message_train/participants/index.json.jbuilder +1 -1
  61. data/app/views/message_train/participants/show.json.jbuilder +1 -1
  62. data/app/views/message_train/receipt_mailer/notification_email.html.haml +1 -1
  63. data/app/views/message_train/receipt_mailer/notification_email.text.haml +1 -1
  64. data/app/views/message_train/unsubscribes/index.html.haml +1 -1
  65. data/config/environment.rb +1 -1
  66. data/config/initializers/date_time.rb +2 -2
  67. data/config/locales/en.yml +1 -1
  68. data/config/routes.rb +37 -15
  69. data/lib/generators/message_train/install/install_generator.rb +26 -11
  70. data/lib/generators/message_train/install/templates/initializer.rb +0 -2
  71. data/lib/generators/message_train/utils.rb +11 -4
  72. data/lib/message_train/configuration.rb +4 -5
  73. data/lib/message_train/engine.rb +1 -7
  74. data/lib/message_train/localization.rb +14 -18
  75. data/lib/message_train/mixin.rb +211 -150
  76. data/lib/message_train/version.rb +1 -0
  77. data/lib/message_train.rb +7 -6
  78. data/message_train.gemspec +24 -11
  79. data/spec/controllers/message_train/boxes_controller_spec.rb +63 -15
  80. data/spec/controllers/message_train/concerns_spec.rb +17 -13
  81. data/spec/controllers/message_train/conversations_controller_spec.rb +44 -12
  82. data/spec/controllers/message_train/messages_controller_spec.rb +87 -40
  83. data/spec/controllers/message_train/participants_controller_spec.rb +10 -4
  84. data/spec/controllers/message_train/unsubscribes_controller_spec.rb +43 -13
  85. data/spec/dummy/Rakefile +2 -1
  86. data/spec/dummy/app/assets/stylesheets/application.css.scss +7 -23
  87. data/spec/dummy/app/controllers/application_controller.rb +7 -7
  88. data/spec/dummy/app/models/group.rb +1 -1
  89. data/spec/dummy/app/models/role.rb +11 -7
  90. data/spec/dummy/app/models/user.rb +6 -5
  91. data/spec/dummy/app/views/layouts/_top_navigation.html.haml +1 -1
  92. data/spec/dummy/app/views/layouts/application.html.haml +1 -1
  93. data/spec/dummy/app/views/pages/index.html.haml +1 -1
  94. data/spec/dummy/config/application.rb +23 -17
  95. data/spec/dummy/config/environments/development.rb +5 -4
  96. data/spec/dummy/config/environments/production.rb +10 -6
  97. data/spec/dummy/config/environments/test.rb +4 -3
  98. data/spec/dummy/config/initializers/assets.rb +2 -1
  99. data/spec/dummy/config/initializers/backtrace_silencers.rb +4 -2
  100. data/spec/dummy/config/initializers/bootstrap_leather.rb +1 -1
  101. data/spec/dummy/config/initializers/devise.rb +63 -44
  102. data/spec/dummy/config/initializers/high_voltage.rb +1 -1
  103. data/spec/dummy/config/initializers/message_train.rb +5 -2
  104. data/spec/dummy/config/initializers/mime_types.rb +1 -1
  105. data/spec/dummy/config/initializers/paperclip.rb +5 -2
  106. data/spec/dummy/config/initializers/rolify.rb +3 -2
  107. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -1
  108. data/spec/dummy/config/routes.rb +1 -3
  109. data/spec/dummy/config/settings.yml +1 -1
  110. data/spec/dummy/db/schema.rb +98 -98
  111. data/spec/dummy/db/seeds/conversations.seeds.rb +160 -160
  112. data/spec/dummy/db/seeds/development/conversations.seeds.rb +6 -2
  113. data/spec/dummy/db/seeds/groups.seeds.rb +11 -12
  114. data/spec/dummy/db/seeds/test/attachments.seeds.rb +13 -3
  115. data/spec/dummy/db/seeds/test/conversations.seeds.rb +6 -2
  116. data/spec/dummy/db/seeds/unsubscribes.seeds.rb +1 -1
  117. data/spec/dummy/db/seeds/users.seeds.rb +47 -42
  118. data/spec/dummy/db/test.sqlite3 +0 -0
  119. data/spec/factories/attachment.rb +6 -2
  120. data/spec/factories/group.rb +1 -4
  121. data/spec/factories/message.rb +29 -23
  122. data/spec/factories/user.rb +6 -4
  123. data/spec/features/boxes_spec.rb +76 -24
  124. data/spec/features/conversations_spec.rb +19 -7
  125. data/spec/features/messages_spec.rb +24 -5
  126. data/spec/features/unsubscribes_spec.rb +36 -9
  127. data/spec/helpers/message_train/application_helper_spec.rb +1 -1
  128. data/spec/helpers/message_train/attachment_helper_spec.rb +27 -12
  129. data/spec/helpers/message_train/boxes_helper_spec.rb +1 -1
  130. data/spec/helpers/message_train/collectives_helper_spec.rb +25 -9
  131. data/spec/helpers/message_train/conversations_helper_spec.rb +239 -120
  132. data/spec/helpers/message_train/messages_helper_spec.rb +137 -81
  133. data/spec/message_train_spec.rb +3 -2
  134. data/spec/models/group_spec.rb +12 -9
  135. data/spec/models/message_train/attachment_spec.rb +33 -30
  136. data/spec/models/message_train/box_spec.rb +243 -60
  137. data/spec/models/message_train/conversation_spec.rb +16 -12
  138. data/spec/models/message_train/ignore_spec.rb +3 -1
  139. data/spec/models/message_train/message_spec.rb +22 -7
  140. data/spec/models/message_train/receipt_spec.rb +14 -4
  141. data/spec/models/role_spec.rb +10 -6
  142. data/spec/models/user_spec.rb +74 -22
  143. data/spec/rails_helper.rb +9 -4
  144. data/spec/spec_helper.rb +6 -54
  145. data/spec/support/controller_behaviors.rb +8 -5
  146. data/spec/support/controller_macros.rb +2 -2
  147. data/spec/support/factory_girl.rb +1 -1
  148. data/spec/support/feature_behaviors.rb +42 -13
  149. data/spec/support/loaded_site/attachments.rb +8 -0
  150. data/spec/support/loaded_site/conversations.rb +73 -0
  151. data/spec/support/{groups.rb → loaded_site/groups.rb} +1 -1
  152. data/spec/support/{loaded_site.rb → loaded_site/loaded_site.rb} +1 -1
  153. data/spec/support/{messages.rb → loaded_site/messages.rb} +13 -5
  154. data/spec/support/{roles.rb → loaded_site/roles.rb} +1 -1
  155. data/spec/support/{users.rb → loaded_site/users.rb} +1 -1
  156. data/spec/support/shared_connection.rb +8 -6
  157. data/spec/support/utilities.rb +10 -10
  158. metadata +67 -10
  159. data/spec/dummy/config/unused/temporary_i18n_debugging.rb +0 -12
  160. data/spec/support/attachments.rb +0 -4
  161. data/spec/support/conversations.rb +0 -23
@@ -5,15 +5,29 @@ describe MessageTrain::BoxesController do
5
5
  include ControllerMacros
6
6
  routes { MessageTrain::Engine.routes }
7
7
 
8
- let(:valid_params) { { 'conversations' => {unread_conversation.id.to_s => unread_conversation.id} } }
9
- let(:invalid_params) { { 'conversations' => {'999' => 999} } }
10
- let(:disallowed_params) { { 'conversations' => {someone_elses_conversation.id.to_s => someone_elses_conversation.id} } }
8
+ let(:valid_params) do
9
+ {
10
+ 'conversations' => {
11
+ unread_conversation.id.to_s => unread_conversation.id
12
+ }
13
+ }
14
+ end
15
+ let(:invalid_params) do
16
+ { 'conversations' => { '999' => 999 } }
17
+ end
18
+ let(:disallowed_params) do
19
+ {
20
+ 'conversations' => {
21
+ someone_elses_conversation.id.to_s => someone_elses_conversation.id
22
+ }
23
+ }
24
+ end
11
25
 
12
26
  before do
13
27
  login_user first_user
14
28
  end
15
29
 
16
- describe "GET #show" do
30
+ describe 'GET #show' do
17
31
  before do
18
32
  get :show, division: 'in'
19
33
  end
@@ -31,18 +45,31 @@ describe MessageTrain::BoxesController do
31
45
  end
32
46
  end
33
47
 
34
- describe "PATCH/PUT #update" do
48
+ describe 'PATCH/PUT #update' do
35
49
  describe 'with invalid params' do
36
50
  before do
37
- put :update, division: 'in', mark_to_set: 'read', objects: invalid_params
51
+ put(
52
+ :update,
53
+ division: 'in',
54
+ mark_to_set: 'read',
55
+ objects: invalid_params
56
+ )
38
57
  end
39
58
  it_should_behave_like 'a 404 Not Found error'
40
59
  end
41
60
  describe 'with disallowed params' do
42
61
  before do
43
- put :update, division: 'in', mark_to_set: 'read', objects: disallowed_params
62
+ put(
63
+ :update,
64
+ division: 'in',
65
+ mark_to_set: 'read',
66
+ objects: disallowed_params
67
+ )
44
68
  end
45
- it_should_behave_like 'a page with an error message matching', /Access to Conversation \d+ denied/
69
+ it_should_behave_like(
70
+ 'a page with an error message matching',
71
+ /Access to Conversation \d+ denied/
72
+ )
46
73
  end
47
74
  describe 'without params' do
48
75
  before do
@@ -58,10 +85,15 @@ describe MessageTrain::BoxesController do
58
85
  end
59
86
  end
60
87
 
61
- describe "DELETE #destroy" do
88
+ describe 'DELETE #destroy' do
62
89
  describe 'with invalid params' do
63
90
  before do
64
- delete :destroy, division: 'in', mark_to_set: 'ignore', objects: invalid_params
91
+ delete(
92
+ :destroy,
93
+ division: 'in',
94
+ mark_to_set: 'ignore',
95
+ objects: invalid_params
96
+ )
65
97
  end
66
98
  it_should_behave_like 'a 404 Not Found error'
67
99
  end
@@ -74,16 +106,32 @@ describe MessageTrain::BoxesController do
74
106
  describe 'with valid params' do
75
107
  context 'ignoring' do
76
108
  before do
77
- delete :destroy, division: 'in', mark_to_set: 'ignore', objects: valid_params
109
+ delete(
110
+ :destroy,
111
+ division: 'in',
112
+ mark_to_set: 'ignore',
113
+ objects: valid_params
114
+ )
78
115
  end
79
- it_should_behave_like 'a page with a notice message', 'Update successful'
116
+ it_should_behave_like(
117
+ 'a page with a notice message',
118
+ 'Update successful'
119
+ )
80
120
  end
81
121
  context 'unignoring' do
82
122
  before do
83
- delete :destroy, division: 'in', mark_to_set: 'unignore', objects: valid_params
123
+ delete(
124
+ :destroy,
125
+ division: 'in',
126
+ mark_to_set: 'unignore',
127
+ objects: valid_params
128
+ )
84
129
  end
85
- it_should_behave_like 'a page with a notice message', 'Update successful'
130
+ it_should_behave_like(
131
+ 'a page with a notice message',
132
+ 'Update successful'
133
+ )
86
134
  end
87
135
  end
88
136
  end
89
- end
137
+ end
@@ -5,21 +5,17 @@ describe MessageTrain::BoxesController do
5
5
  include ControllerMacros
6
6
  routes { MessageTrain::Engine.routes }
7
7
 
8
- describe "GET #show" do
9
- # describe 'when not logged in' do
10
- # before do
11
- # access_anonymous
12
- # get :show, division: 'in'
13
- # end
14
- # it_should_behave_like 'a redirect with error', '/users/sign_in', 'You must sign in or sign up to continue.'
15
- # end
16
-
8
+ describe 'GET #show' do
17
9
  describe 'when neither sending nor receiving is allowed' do
18
10
  before do
19
11
  login_user third_user
20
12
  get :show, division: 'in', collective_id: 'groups:first-group'
21
13
  end
22
- it_should_behave_like 'a redirect with error', '/', 'Access to that box denied'
14
+ it_should_behave_like(
15
+ 'a redirect with error',
16
+ '/',
17
+ 'Access to that box denied'
18
+ )
23
19
  end
24
20
 
25
21
  describe 'when only sending is allowed' do
@@ -27,7 +23,11 @@ describe MessageTrain::BoxesController do
27
23
  login_user first_user
28
24
  get :show, division: 'in', collective_id: 'groups:first-group'
29
25
  end
30
- it_should_behave_like 'a redirect with error', '/collectives/groups:first-group/box/sent', 'Access to that box denied'
26
+ it_should_behave_like(
27
+ 'a redirect with error',
28
+ '/collectives/groups:first-group/box/sent',
29
+ 'Access to that box denied'
30
+ )
31
31
  end
32
32
 
33
33
  describe 'when only receiving is allowed' do
@@ -35,7 +35,11 @@ describe MessageTrain::BoxesController do
35
35
  login_user first_user
36
36
  get :show, division: 'sent', collective_id: 'groups:membered-group'
37
37
  end
38
- it_should_behave_like 'a redirect with error', '/collectives/groups:membered-group/box/in', 'Access to that box denied'
38
+ it_should_behave_like(
39
+ 'a redirect with error',
40
+ '/collectives/groups:membered-group/box/in',
41
+ 'Access to that box denied'
42
+ )
39
43
  end
40
44
  end
41
- end
45
+ end
@@ -5,14 +5,18 @@ describe MessageTrain::ConversationsController do
5
5
  include ControllerMacros
6
6
  routes { MessageTrain::Engine.routes }
7
7
 
8
- let(:valid_params) { { 'messages' => {unread_message.id.to_s => unread_message.id} } }
9
- let(:invalid_params) { { 'messages' => {'999999' => 999999} } }
8
+ let(:valid_params) do
9
+ { 'messages' => { unread_message.id.to_s => unread_message.id } }
10
+ end
11
+ let(:invalid_params) do
12
+ { 'messages' => { '999999' => 999_999 } }
13
+ end
10
14
 
11
15
  before do
12
16
  login_user first_user
13
17
  end
14
18
 
15
- describe "GET #show" do
19
+ describe 'GET #show' do
16
20
  before do
17
21
  get :show, box_division: 'in', id: unread_conversation.id
18
22
  end
@@ -34,10 +38,16 @@ describe MessageTrain::ConversationsController do
34
38
  end
35
39
  end
36
40
 
37
- describe "PATCH/PUT #update" do
41
+ describe 'PATCH/PUT #update' do
38
42
  describe 'with invalid params' do
39
43
  before do
40
- put :update, box_division: 'in', id: unread_conversation.id, mark_to_set: 'read', objects: invalid_params
44
+ put(
45
+ :update,
46
+ box_division: 'in',
47
+ id: unread_conversation.id,
48
+ mark_to_set: 'read',
49
+ objects: invalid_params
50
+ )
41
51
  end
42
52
  it_should_behave_like 'a 404 Not Found error'
43
53
  end
@@ -49,13 +59,19 @@ describe MessageTrain::ConversationsController do
49
59
  end
50
60
  describe 'with valid params' do
51
61
  before do
52
- put :update, box_division: 'in', id: unread_conversation.id, mark_to_set: 'read', objects: valid_params
62
+ put(
63
+ :update,
64
+ box_division: 'in',
65
+ id: unread_conversation.id,
66
+ mark_to_set: 'read',
67
+ objects: valid_params
68
+ )
53
69
  end
54
70
  it_should_behave_like 'a page with a notice message', 'Update successful'
55
71
  end
56
72
  end
57
73
 
58
- describe "DELETE #destroy" do
74
+ describe 'DELETE #destroy' do
59
75
  describe 'with invalid params' do
60
76
  before do
61
77
  delete :destroy, box_division: 'in', id: 999, mark_to_set: 'ignore'
@@ -71,16 +87,32 @@ describe MessageTrain::ConversationsController do
71
87
  describe 'with valid params' do
72
88
  context 'ignoring' do
73
89
  before do
74
- delete :destroy, box_division: 'in', id: unread_conversation.id, mark_to_set: 'ignore'
90
+ delete(
91
+ :destroy,
92
+ box_division: 'in',
93
+ id: unread_conversation.id,
94
+ mark_to_set: 'ignore'
95
+ )
75
96
  end
76
- it_should_behave_like 'a page with a notice message', 'Update successful'
97
+ it_should_behave_like(
98
+ 'a page with a notice message',
99
+ 'Update successful'
100
+ )
77
101
  end
78
102
  context 'unignoring' do
79
103
  before do
80
- delete :destroy, box_division: 'in', id: unread_conversation.id, mark_to_set: 'unignore'
104
+ delete(
105
+ :destroy,
106
+ box_division: 'in',
107
+ id: unread_conversation.id,
108
+ mark_to_set: 'unignore'
109
+ )
81
110
  end
82
- it_should_behave_like 'a page with a notice message', 'Update successful'
111
+ it_should_behave_like(
112
+ 'a page with a notice message',
113
+ 'Update successful'
114
+ )
83
115
  end
84
116
  end
85
117
  end
86
- end
118
+ end
@@ -8,23 +8,27 @@ describe MessageTrain::MessagesController do
8
8
  # This should return the minimal set of attributes required to create a valid
9
9
  # Dog. As you add validations to Dog, be sure to
10
10
  # adjust the attributes here as well.
11
- let(:valid_attributes) {
12
- { subject: 'Test Subject', recipients_to_save: {'users' => 'second-user, third-user'}, draft: false }
13
- }
11
+ let(:valid_attributes) do
12
+ {
13
+ subject: 'Test Subject',
14
+ recipients_to_save: { 'users' => 'second-user, third-user' },
15
+ draft: false
16
+ }
17
+ end
14
18
 
15
- let(:draft_attributes) {
16
- { subject: 'Test Subject', recipients_to_save: {'users' => ''} }
17
- }
19
+ let(:draft_attributes) do
20
+ { subject: 'Test Subject', recipients_to_save: { 'users' => '' } }
21
+ end
18
22
 
19
- let(:invalid_attributes) {
23
+ let(:invalid_attributes) do
20
24
  { subject: nil }
21
- }
25
+ end
22
26
 
23
27
  before do
24
28
  login_user first_user
25
29
  end
26
30
 
27
- describe "GET #show" do
31
+ describe 'GET #show' do
28
32
  before do
29
33
  get :show, box_division: 'in', id: unread_message.id, format: :json
30
34
  end
@@ -41,9 +45,13 @@ describe MessageTrain::MessagesController do
41
45
  end
42
46
  end
43
47
 
44
- describe "GET #new" do
48
+ describe 'GET #new' do
45
49
  before do
46
- get :new, box_division: 'in', conversation_id: unread_message.message_train_conversation_id
50
+ get(
51
+ :new,
52
+ box_division: 'in',
53
+ conversation_id: unread_message.message_train_conversation_id
54
+ )
47
55
  end
48
56
  it_should_behave_like 'a successful page', which_renders: 'new'
49
57
 
@@ -59,7 +67,7 @@ describe MessageTrain::MessagesController do
59
67
  end
60
68
  end
61
69
 
62
- describe "GET #edit" do
70
+ describe 'GET #edit' do
63
71
  describe 'as someone other than the owner' do
64
72
  before do
65
73
  get :edit, box_division: 'in', id: someone_elses_message.id
@@ -87,7 +95,7 @@ describe MessageTrain::MessagesController do
87
95
  end
88
96
  end
89
97
 
90
- describe "POST #create" do
98
+ describe 'POST #create' do
91
99
  describe 'with valid attributes' do
92
100
  describe 'when draft' do
93
101
  before do
@@ -98,7 +106,7 @@ describe MessageTrain::MessagesController do
98
106
 
99
107
  context "sets the flash with an alert of the messages's draft status" do
100
108
  subject { flash[:alert] }
101
- it { should eq 'Message saved as draft.'}
109
+ it { should eq 'Message saved as draft.' }
102
110
  end
103
111
  end
104
112
  describe 'when not draft' do
@@ -110,22 +118,30 @@ describe MessageTrain::MessagesController do
110
118
 
111
119
  context "sets the flash with a notice of the messages's creation" do
112
120
  subject { flash[:notice] }
113
- it { should eq 'Message sent.'}
121
+ it { should eq 'Message sent.' }
114
122
  end
115
123
  end
116
124
  end
117
125
  describe 'with valid attributes, counting' do
118
126
  it 'results in a new conversation' do
119
- expect { post :create, box_division: 'in', message: valid_attributes }.to change { MessageTrain::Conversation.count }.by(1)
127
+ expect do
128
+ post(:create, box_division: 'in', message: valid_attributes)
129
+ end.to change { MessageTrain::Conversation.count }.by(1)
120
130
  end
121
131
  it 'results in a new message' do
122
- expect { post :create, box_division: 'in', message: valid_attributes }.to change { MessageTrain::Message.count }.by(1)
132
+ expect do
133
+ post(:create, box_division: 'in', message: valid_attributes)
134
+ end.to change { MessageTrain::Message.count }.by(1)
123
135
  end
124
136
  it 'results in new receipts' do
125
- expect { post :create, box_division: 'in', message: valid_attributes }.to change { MessageTrain::Receipt.count }.by(3)
137
+ expect do
138
+ post(:create, box_division: 'in', message: valid_attributes)
139
+ end.to change { MessageTrain::Receipt.count }.by(3)
126
140
  end
127
141
  it 'results in email notifications' do
128
- expect { post :create, box_division: 'in', message: valid_attributes }.to change { ActionMailer::Base.deliveries.count }.by(2)
142
+ expect do
143
+ post(:create, box_division: 'in', message: valid_attributes)
144
+ end.to change { ActionMailer::Base.deliveries.count }.by(2)
129
145
  end
130
146
  end
131
147
  describe 'with invalid params' do
@@ -141,58 +157,76 @@ describe MessageTrain::MessagesController do
141
157
 
142
158
  context "sets the flash with the message's errors" do
143
159
  subject { flash[:error] }
144
- it { should eq "Subject can't be blank"}
160
+ it { should eq "Subject can't be blank" }
145
161
  end
146
162
  end
147
163
 
148
164
  describe 'with invalid params, counting' do
149
165
  it 'does not result in a new message' do
150
- expect { post :create, box_division: 'in', message: invalid_attributes }.to_not change { MessageTrain::Message.count }
166
+ expect do
167
+ post :create, box_division: 'in', message: invalid_attributes
168
+ end.to_not change { MessageTrain::Message.count }
151
169
  end
152
170
  end
153
171
  end
154
172
 
155
- describe "PUT #update" do
173
+ describe 'PUT #update' do
156
174
  describe 'as someone other than the owner' do
157
175
  before do
158
- put :update, box_division: 'in', id: someone_elses_message.id, message: valid_attributes
176
+ put(
177
+ :update,
178
+ box_division: 'in',
179
+ id: someone_elses_message.id,
180
+ message: valid_attributes
181
+ )
159
182
  end
160
183
  it_should_behave_like 'a 404 Not Found error'
161
184
  end
162
185
  describe 'as the owner' do
163
186
  describe 'with invalid params' do
164
187
  before do
165
- put :update, box_division: 'in', id: draft_message.id, message: invalid_attributes
188
+ put(
189
+ :update,
190
+ box_division: 'in',
191
+ id: draft_message.id,
192
+ message: invalid_attributes
193
+ )
166
194
  end
167
195
  it_should_behave_like 'a successful page', which_renders: 'edit'
168
-
169
196
  context 'loads the given message into @message' do
170
197
  subject { assigns(:message) }
171
198
  it { should eq draft_message }
172
199
  end
173
-
174
200
  context 'does not update @message' do
175
201
  subject { draft_message.reload }
176
202
  its(:subject) { should eq 'This should turn into a draft' }
177
203
  end
178
-
179
204
  context "sets the flash with the message's errors" do
180
205
  subject { flash[:error] }
181
- it { should eq "Subject can't be blank"}
206
+ it { should eq "Subject can't be blank" }
182
207
  end
183
208
  end
184
209
  describe 'with valid params' do
185
210
  describe 'when not a draft' do
186
211
  before do
187
- put :update, box_division: 'in', id: sent_message.id, message: valid_attributes
212
+ put(
213
+ :update,
214
+ box_division: 'in',
215
+ id: sent_message.id,
216
+ message: valid_attributes
217
+ )
188
218
  end
189
219
  it_should_behave_like 'a 404 Not Found error'
190
220
  end
191
221
  describe 'when a draft' do
192
222
  describe 'and updating to not draft' do
193
-
194
223
  before do
195
- put :update, box_division: 'in', id: draft_message.id, message: valid_attributes
224
+ put(
225
+ :update,
226
+ box_division: 'in',
227
+ id: draft_message.id,
228
+ message: valid_attributes
229
+ )
196
230
  end
197
231
  it_should_behave_like 'a redirect to', '/box/sent'
198
232
  it_should_behave_like 'a response without error'
@@ -202,22 +236,36 @@ describe MessageTrain::MessagesController do
202
236
  its(:subject) { should eq 'Test Subject' }
203
237
  end
204
238
 
205
- context "sets no alert" do
239
+ context 'sets no alert' do
206
240
  subject { flash[:alert] }
207
241
  it { should be nil }
208
242
  end
209
243
 
210
244
  context "sets the flash with a notice of the message's update" do
211
245
  subject { flash[:notice] }
212
- it { should eq 'Message sent.'}
246
+ it { should eq 'Message sent.' }
213
247
  end
214
248
  end
215
249
  describe 'and updating but keeping as a draft' do
216
- let(:edited_draft_message) { { id: draft_message.id, subject: 'Still a draft', draft: 'Save As Draft' } }
250
+ let(:edited_draft_message) do
251
+ {
252
+ id: draft_message.id,
253
+ subject: 'Still a draft',
254
+ draft: 'Save As Draft'
255
+ }
256
+ end
217
257
  before do
218
- put :update, box_division: 'in', id: draft_message.id, message: edited_draft_message
258
+ put(
259
+ :update,
260
+ box_division: 'in',
261
+ id: draft_message.id,
262
+ message: edited_draft_message
263
+ )
219
264
  end
220
- it_should_behave_like 'a redirect matching', %r(/box/in/conversations/\d+)
265
+ it_should_behave_like(
266
+ 'a redirect matching',
267
+ %r{/box/in/conversations/\d+}
268
+ )
221
269
  it_should_behave_like 'a response without error'
222
270
 
223
271
  context 'updates @message' do
@@ -225,19 +273,18 @@ describe MessageTrain::MessagesController do
225
273
  its(:subject) { should eq 'Still a draft' }
226
274
  end
227
275
 
228
- context "sets no notice" do
276
+ context 'sets no notice' do
229
277
  subject { flash[:notice] }
230
278
  it { should be nil }
231
279
  end
232
280
 
233
281
  context "sets the flash with a alert of the message's update" do
234
282
  subject { flash[:alert] }
235
- it { should eq 'Message saved as draft.'}
283
+ it { should eq 'Message saved as draft.' }
236
284
  end
237
285
  end
238
286
  end
239
287
  end
240
-
241
288
  end
242
289
  end
243
- end
290
+ end
@@ -9,7 +9,7 @@ describe MessageTrain::ParticipantsController do
9
9
  login_user first_user
10
10
  end
11
11
 
12
- describe "GET #index" do
12
+ describe 'GET #index' do
13
13
  describe 'with model to users' do
14
14
  before do
15
15
  get :index, box_division: 'in', model: 'users', format: :json
@@ -56,9 +56,15 @@ describe MessageTrain::ParticipantsController do
56
56
  end
57
57
  end
58
58
 
59
- describe "GET #show" do
59
+ describe 'GET #show' do
60
60
  before do
61
- get :show, box_division: 'in', model: 'users', id: first_user.id, format: :json
61
+ get(
62
+ :show,
63
+ box_division: 'in',
64
+ model: 'users',
65
+ id: first_user.id,
66
+ format: :json
67
+ )
62
68
  end
63
69
  it_should_behave_like 'a successful page', which_renders: 'show'
64
70
 
@@ -67,4 +73,4 @@ describe MessageTrain::ParticipantsController do
67
73
  it { should eq first_user }
68
74
  end
69
75
  end
70
- end
76
+ end
@@ -5,19 +5,19 @@ describe MessageTrain::UnsubscribesController do
5
5
  include ControllerMacros
6
6
  routes { MessageTrain::Engine.routes }
7
7
 
8
- let(:valid_attributes) {
8
+ let(:valid_attributes) do
9
9
  { from_type: 'Group', from_id: membered_group.id }
10
- }
10
+ end
11
11
 
12
- let(:invalid_attributes) {
12
+ let(:invalid_attributes) do
13
13
  { from_type: 'Group', from_id: empty_group.id }
14
- }
14
+ end
15
15
 
16
16
  before do
17
17
  login_user first_user
18
18
  end
19
19
 
20
- describe "GET #index" do
20
+ describe 'GET #index' do
21
21
  before do
22
22
  get :index
23
23
  end
@@ -30,7 +30,7 @@ describe MessageTrain::UnsubscribesController do
30
30
  end
31
31
  end
32
32
 
33
- describe "POST #create" do
33
+ describe 'POST #create' do
34
34
  describe 'with invalid attributes' do
35
35
  before do
36
36
  post :create, unsubscribe: invalid_attributes
@@ -41,30 +41,60 @@ describe MessageTrain::UnsubscribesController do
41
41
  before do
42
42
  post :create, unsubscribe: valid_attributes
43
43
  end
44
- it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You are now unsubscribed from Membered Group, which means that you will not be notified by email of any messages received by that Group.'
44
+ it_should_behave_like(
45
+ 'a redirect with a message',
46
+ '/unsubscribes',
47
+ notice: 'You are now unsubscribed from Membered Group, which means '\
48
+ 'that you will not be notified by email of any messages received by '\
49
+ 'that Group.'
50
+ )
45
51
  it_should_behave_like 'a response without error'
46
52
  end
47
53
  describe 'with :all set to true' do
48
54
  before do
49
55
  post :create, all: true
50
56
  end
51
- it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You have unsubscribed from all messages, which means that you will not be notified by email of any messages received in any of your boxes.'
57
+ it_should_behave_like(
58
+ 'a redirect with a message',
59
+ '/unsubscribes',
60
+ notice: 'You have unsubscribed from all messages, which means that '\
61
+ 'you will not be notified by email of any messages received in any '\
62
+ 'of your boxes.'
63
+ )
52
64
  it_should_behave_like 'a response without error'
53
65
  end
54
66
  end
55
67
 
56
- describe "DELETE #destroy" do
68
+ describe 'DELETE #destroy' do
57
69
  describe 'with an id' do
58
70
  before do
59
- delete :destroy, id: first_user.unsubscribes.where(from_type: 'Group', from_id: unsubscribed_group.id).first.id
71
+ delete(
72
+ :destroy,
73
+ id: first_user.unsubscribes.where(
74
+ from_type: 'Group',
75
+ from_id: unsubscribed_group.id
76
+ ).first.id
77
+ )
60
78
  end
61
- it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You are no longer unsubscribed from Unsubscribed Group, which means that you will now be notified by email of any messages received in that Group.'
79
+ it_should_behave_like(
80
+ 'a redirect with a message',
81
+ '/unsubscribes',
82
+ notice: 'You are no longer unsubscribed from Unsubscribed Group, '\
83
+ 'which means that you will now be notified by email of any '\
84
+ 'messages received in that Group.'
85
+ )
62
86
  end
63
87
  describe 'with :all set to true' do
64
88
  before do
65
89
  delete :destroy, all: true
66
90
  end
67
- it_should_behave_like 'a redirect with a message', '/unsubscribes', notice: 'You are no longer unsubscribed from all messages, which means that you will now be notified by email of any messages received in boxes you are subscribed to.'
91
+ it_should_behave_like(
92
+ 'a redirect with a message',
93
+ '/unsubscribes',
94
+ notice: 'You are no longer unsubscribed from all messages, which '\
95
+ 'means that you will now be notified by email of any messages '\
96
+ 'received in boxes you are subscribed to.'
97
+ )
68
98
  end
69
99
  end
70
- end
100
+ end