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
@@ -2,8 +2,12 @@ after :users, :groups do
2
2
  first_user = User.friendly.find('first-user')
3
3
 
4
4
  # Create some conversations that first user has received
5
- FactoryGirl.create_list(:message_from_random_sender, 10, recipients_to_save: { 'users' => first_user.slug })
5
+ FactoryGirl.create_list(
6
+ :message_from_random_sender,
7
+ 10,
8
+ recipients_to_save: { 'users' => first_user.slug }
9
+ )
6
10
 
7
11
  # Create some conversations that first user has sent
8
12
  FactoryGirl.create_list(:message, 10, sender: first_user)
9
- end
13
+ end
@@ -9,4 +9,4 @@ after :groups do
9
9
  unsubscribed_user.unsubscribe_from(membered_group)
10
10
  unsubscribed_user.unsubscribe_from(unsubscribed_user)
11
11
  first_user.unsubscribe_from(unsubscribed_group)
12
- end
12
+ end
@@ -1,42 +1,47 @@
1
- first_user = FactoryGirl.create(
2
- :user,
3
- display_name: 'First User',
4
- email: 'first.user@example.com'
5
- )
6
- second_user = FactoryGirl.create(
7
- :user,
8
- display_name: 'Second User',
9
- email: 'second.user@example.com'
10
- )
11
- third_user = FactoryGirl.create(
12
- :user,
13
- display_name: 'Third User',
14
- email: 'third.user@example.com'
15
- )
16
- fourth_user = FactoryGirl.create(
17
- :user,
18
- display_name: 'Fourth User',
19
- email: 'fourth.user@example.com'
20
- )
21
- unsubscribed_user = FactoryGirl.create(
22
- :user,
23
- display_name: 'Unsubscribed User',
24
- email: 'unsubscribed.user@example.com'
25
- )
26
- silent_user = FactoryGirl.create(
27
- :user,
28
- display_name: 'Silent User',
29
- email: 'silent.user@example.com'
30
- )
31
- superadmin_user = FactoryGirl.create(
32
- :user,
33
- display_name: 'Superadmin User',
34
- email: 'superadmin.user@example.com'
35
- )
36
- superadmin_user.add_role(:superadmin)
37
- admin_user = FactoryGirl.create(
38
- :user,
39
- display_name: 'Admin User',
40
- email: 'admin.user@example.com'
41
- )
42
- admin_user.add_role(:admin)
1
+ FactoryGirl.create(
2
+ :user,
3
+ display_name: 'First User',
4
+ email: 'first.user@example.com'
5
+ )
6
+
7
+ FactoryGirl.create(
8
+ :user,
9
+ display_name: 'Second User',
10
+ email: 'second.user@example.com'
11
+ )
12
+
13
+ FactoryGirl.create(
14
+ :user,
15
+ display_name: 'Third User',
16
+ email: 'third.user@example.com'
17
+ )
18
+
19
+ FactoryGirl.create(
20
+ :user,
21
+ display_name: 'Fourth User',
22
+ email: 'fourth.user@example.com'
23
+ )
24
+
25
+ FactoryGirl.create(
26
+ :user,
27
+ display_name: 'Unsubscribed User',
28
+ email: 'unsubscribed.user@example.com'
29
+ )
30
+
31
+ FactoryGirl.create(
32
+ :user,
33
+ display_name: 'Silent User',
34
+ email: 'silent.user@example.com'
35
+ )
36
+
37
+ FactoryGirl.create(
38
+ :user,
39
+ display_name: 'Superadmin User',
40
+ email: 'superadmin.user@example.com'
41
+ ).add_role(:superadmin)
42
+
43
+ FactoryGirl.create(
44
+ :user,
45
+ display_name: 'Admin User',
46
+ email: 'admin.user@example.com'
47
+ ).add_role(:admin)
Binary file
@@ -1,6 +1,10 @@
1
1
  FactoryGirl.define do
2
2
  factory :attachment, class: 'MessageTrain::Attachment' do
3
3
  message { MessageTrain::Message.order('RANDOM()').first }
4
- attachment { File.open(Dir['spec/dummy/app/assets/files/message_train/attachments/*'].sample) }
4
+ attachment do
5
+ File.open(
6
+ Dir['spec/dummy/app/assets/files/message_train/attachments/*'].sample
7
+ )
8
+ end
5
9
  end
6
- end
10
+ end
@@ -3,7 +3,7 @@ FactoryGirl.define do
3
3
  title { Faker::Lorem.sentence }
4
4
  description { Faker::Lorem.paragraphs([*1..5].sample).join("\n\n") }
5
5
  transient do
6
- owner { User.order("RANDOM()").first }
6
+ owner { User.order('RANDOM()').first }
7
7
  # member_count 5
8
8
  end
9
9
  # the after(:create) yields two values; the user instance itself and the
@@ -12,9 +12,6 @@ FactoryGirl.define do
12
12
  # to create and we make sure the user is associated properly to the post
13
13
  after(:create) do |group, evaluator|
14
14
  evaluator.owner.add_role(:owner, group)
15
- # User.where('id != ?', evaluator.owner.id).order("RANDOM()").limit(evaluator.member_count).find_each do |user|
16
- # user.add_role(:member, group)
17
- # end
18
15
  end
19
16
  end
20
17
  end
@@ -1,21 +1,22 @@
1
1
  FactoryGirl.define do
2
2
  factory :message, class: 'MessageTrain::Message' do
3
- sender {
3
+ sender do
4
4
  User
5
- .order('RANDOM()')
6
- .first
7
- }
8
- recipients_to_save { { 'users' =>
9
- User
10
- .where
11
- .not(id: sender.id)
12
- .where
13
- .not(slug: 'silent-user')
14
- .order('RANDOM()')
15
- .limit([*1..5].sample)
16
- .collect { |x| x.slug }
17
- .join(', ')
18
- } }
5
+ .order('RANDOM()')
6
+ .first
7
+ end
8
+ recipients_to_save do
9
+ {
10
+ 'users' => User.where
11
+ .not(id: sender.id)
12
+ .where
13
+ .not(slug: 'silent-user')
14
+ .order('RANDOM()')
15
+ .limit([*1..5].sample)
16
+ .collect(&:slug)
17
+ .join(', ')
18
+ }
19
+ end
19
20
  subject { Faker::Lorem.sentence }
20
21
  body { "<p>#{Faker::Lorem.paragraphs([*1..5].sample).join('</p><p>')}</p>" }
21
22
 
@@ -34,11 +35,13 @@ FactoryGirl.define do
34
35
  FactoryGirl.create(:attachment, message: message)
35
36
  end
36
37
  if message.recipients_to_save['users'].present?
37
- participants = (message.recipients_to_save['users'].split(',') + [message.sender.slug]).collect{ |x| x.strip }
38
+ participants = (
39
+ message.recipients_to_save['users'].split(',') + [message.sender.slug]
40
+ ).collect(&:strip)
38
41
  if evaluator.generate_ignore?
39
42
  ignorer = User.friendly.find(participants.sample)
40
- participants = participants - [ignorer.slug]
41
- message.conversation.set_ignored(ignorer)
43
+ participants -= [ignorer.slug]
44
+ message.conversation.participant_ignore(ignorer)
42
45
  end
43
46
  if evaluator.generate_response? && participants.count > 1
44
47
  response_sender = User.friendly.find(participants.sample)
@@ -54,16 +57,19 @@ FactoryGirl.define do
54
57
  end
55
58
 
56
59
  factory :message_from_random_sender do
57
- sender {
58
- recipient_user_ids = recipients_to_save['users'].split(',').collect{ |x| User.friendly.find(x.strip).id }
60
+ sender do
61
+ recipient_user_ids = (
62
+ recipients_to_save['users'].split(',')
63
+ .collect { |x| User.friendly.find(x.strip).id }
64
+ )
59
65
  User
60
66
  .where
61
- .not(id: recipient_user_ids )
67
+ .not(id: recipient_user_ids)
62
68
  .where
63
69
  .not(slug: 'silent-user')
64
70
  .order('RANDOM()')
65
71
  .first
66
- }
72
+ end
67
73
  end
68
74
 
69
75
  factory :simple_message do
@@ -72,4 +78,4 @@ FactoryGirl.define do
72
78
  generate_attachment? false
73
79
  end
74
80
  end
75
- end
81
+ end
@@ -1,8 +1,10 @@
1
1
  FactoryGirl.define do
2
2
  factory :user do
3
3
  display_name { Faker::Name.name }
4
- email { "#{display_name.gsub(' ', '.').downcase}.#{rand(1000).to_s}@example.com" }
5
- password "password"
6
- password_confirmation "password"
4
+ sequence :email do |n|
5
+ "#{display_name.tr(' ', '.').downcase}#{n}@example.com"
6
+ end
7
+ password 'password'
8
+ password_confirmation 'password'
7
9
  end
8
- end
10
+ end
@@ -3,40 +3,59 @@ RSpec.feature 'Boxes' do
3
3
  include_context 'loaded site'
4
4
 
5
5
  it_behaves_like 'an authenticated section', '/box'
6
- it_behaves_like 'an authenticated section', '/collectives/groups:membered-group'
6
+ it_behaves_like(
7
+ 'an authenticated section',
8
+ '/collectives/groups:membered-group'
9
+ )
7
10
 
8
11
  describe 'When logged in as first-user' do
9
12
  before do
10
13
  login_as first_user
11
14
  end
12
15
  describe 'Without a collective' do
13
-
14
16
  describe 'Showing' do
15
17
  describe 'at /box/in' do
16
18
  before do
17
19
  visit '/box/in'
18
20
  click_link 'Last'
19
21
  end
20
- it_behaves_like 'a bootstrap page listing a collection of items', MessageTrain::Conversation, plural_title: 'Inbox', minimum: 1
22
+ it_behaves_like(
23
+ 'a bootstrap page listing a collection of items',
24
+ MessageTrain::Conversation,
25
+ plural_title: 'Inbox',
26
+ minimum: 1
27
+ )
21
28
 
22
29
  describe 'does not list Roles dropdown' do
23
30
  subject { page }
24
- it { should_not have_css('li.dropdown a.dropdown-toggle', text: 'Roles') }
31
+ it do
32
+ should_not have_css(
33
+ 'li.dropdown a.dropdown-toggle',
34
+ text: 'Roles'
35
+ )
36
+ end
25
37
  end
26
38
 
27
39
  describe 'shows the attachment icon on the correct conversation' do
28
40
  before do
29
- if page.has_no_css?("#message_train_conversation_#{attachment_conversation.id.to_s}")
41
+ if page.has_no_css?(
42
+ "#message_train_conversation_#{attachment_conversation.id}"
43
+ )
30
44
  click_link 'Prev'
31
45
  end
32
46
  end
33
47
  subject { page }
34
- it { should have_css("#message_train_conversation_#{attachment_conversation.id.to_s} .glyphicon-paperclip")}
48
+ it do
49
+ should have_css(
50
+ "#message_train_conversation_#{attachment_conversation.id} "\
51
+ '.glyphicon-paperclip'
52
+ )
53
+ end
35
54
  end
36
55
 
37
56
  describe 'shows a link to compose' do
38
57
  before do
39
- within ".content" do
58
+ within '.content' do
40
59
  find('.compose').click
41
60
  end
42
61
  end
@@ -51,14 +70,20 @@ RSpec.feature 'Boxes' do
51
70
  before do
52
71
  visit '/box/in'
53
72
  click_link 'Last'
54
- find("#message_train_conversation_#{unread_conversation.id.to_s}").hover
55
- within "#message_train_conversation_#{unread_conversation.id.to_s}" do
73
+ find(
74
+ "#message_train_conversation_#{unread_conversation.id}"
75
+ ).hover
76
+ within "#message_train_conversation_#{unread_conversation.id}" do
56
77
  accept_confirm do
57
78
  find('.trash-toggle').click
58
79
  end
59
80
  end
60
81
  end
61
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
82
+ it_behaves_like(
83
+ 'a bootstrap page with an alert',
84
+ 'info',
85
+ 'Update successful'
86
+ )
62
87
  end
63
88
  describe 'without checking anything' do
64
89
  before do
@@ -66,43 +91,58 @@ RSpec.feature 'Boxes' do
66
91
  click_button 'Mark'
67
92
  click_link 'mark-read'
68
93
  end
69
- it_behaves_like 'a bootstrap page with an alert', 'warning', 'Nothing to do'
94
+ it_behaves_like(
95
+ 'a bootstrap page with an alert',
96
+ 'warning',
97
+ 'Nothing to do'
98
+ )
70
99
  end
71
100
  describe 'after checking a box' do
72
101
  describe 'Marking Read' do
73
102
  before do
74
103
  visit '/box/in'
75
104
  click_link 'Last'
76
- check "objects_conversations_#{unread_conversation.id.to_s}"
105
+ check "objects_conversations_#{unread_conversation.id}"
77
106
  click_button 'Mark'
78
107
  click_link 'mark-read'
79
108
  end
80
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
109
+ it_behaves_like(
110
+ 'a bootstrap page with an alert',
111
+ 'info',
112
+ 'Update successful'
113
+ )
81
114
  end
82
115
  describe 'Marking Ignored' do
83
116
  before do
84
117
  visit '/box/in'
85
118
  click_link 'Last'
86
- check "objects_conversations_#{unread_conversation.id.to_s}"
119
+ check "objects_conversations_#{unread_conversation.id}"
87
120
  click_button 'Mark'
88
121
  click_link 'mark-ignored'
89
122
  end
90
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
123
+ it_behaves_like(
124
+ 'a bootstrap page with an alert',
125
+ 'info',
126
+ 'Update successful'
127
+ )
91
128
  end
92
129
  end
93
130
  end
94
-
95
131
  end
96
132
  end
97
133
 
98
134
  describe 'Within a collective' do
99
-
100
135
  describe 'Showing' do
101
136
  describe 'at /collectives/groups:membered-group/box/in' do
102
137
  before do
103
138
  visit '/collectives/groups:membered-group/box/in'
104
139
  end
105
- it_behaves_like 'a bootstrap page listing a collection of items', MessageTrain::Conversation, plural_title: 'Inbox', minimum: 1
140
+ it_behaves_like(
141
+ 'a bootstrap page listing a collection of items',
142
+ MessageTrain::Conversation,
143
+ plural_title: 'Inbox',
144
+ minimum: 1
145
+ )
106
146
  end
107
147
  end
108
148
 
@@ -114,33 +154,45 @@ RSpec.feature 'Boxes' do
114
154
  click_button 'Mark'
115
155
  click_link 'mark-read'
116
156
  end
117
- it_behaves_like 'a bootstrap page with an alert', 'warning', 'Nothing to do'
157
+ it_behaves_like(
158
+ 'a bootstrap page with an alert',
159
+ 'warning',
160
+ 'Nothing to do'
161
+ )
118
162
  end
119
163
  describe 'after checking a box' do
120
164
  describe 'Marking Read' do
121
165
  before do
122
166
  visit '/collectives/groups:membered-group/box/in'
123
- check "objects_conversations_#{membered_group_conversation.id.to_s}"
167
+ check "objects_conversations_#{membered_group_conversation.id}"
124
168
  click_button 'Mark'
125
169
  click_link 'mark-read'
126
170
  end
127
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
171
+ it_behaves_like(
172
+ 'a bootstrap page with an alert',
173
+ 'info',
174
+ 'Update successful'
175
+ )
128
176
  end
129
177
  describe 'Marking Ignored' do
130
178
  before do
131
179
  visit '/collectives/groups:membered-group/box/in'
132
- check "objects_conversations_#{membered_group_conversation.id.to_s}"
180
+ check "objects_conversations_#{membered_group_conversation.id}"
133
181
  click_button 'Mark'
134
182
  click_link 'mark-ignored'
135
183
  end
136
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
184
+ it_behaves_like(
185
+ 'a bootstrap page with an alert',
186
+ 'info',
187
+ 'Update successful'
188
+ )
137
189
  end
138
190
  end
139
191
  end
140
-
141
192
  end
142
193
  end
143
194
  end
195
+
144
196
  describe 'When logged in as admin-user' do
145
197
  before do
146
198
  login_as admin_user
@@ -11,9 +11,13 @@ RSpec.feature 'Conversations' do
11
11
  describe 'Showing' do
12
12
  describe 'at /box/in/conversations/:id' do
13
13
  before do
14
- visit '/box/in/conversations/' + unread_conversation.id.to_s
14
+ visit "/box/in/conversations/#{unread_conversation.id}"
15
15
  end
16
- it_behaves_like 'a bootstrap page showing an item', MessageTrain::Conversation, 'Unread Conversation'
16
+ it_behaves_like(
17
+ 'a bootstrap page showing an item',
18
+ MessageTrain::Conversation,
19
+ 'Unread Conversation'
20
+ )
17
21
 
18
22
  describe 'shows a reply link' do
19
23
  before do
@@ -27,19 +31,27 @@ RSpec.feature 'Conversations' do
27
31
  describe 'at /box/in/conversations/:id' do
28
32
  describe 'Marking Read' do
29
33
  before do
30
- visit '/box/in/conversations/' + unread_conversation.id.to_s
31
- click_link "mark_read_#{unread_message.id.to_s}"
34
+ visit "/box/in/conversations/#{unread_conversation.id}"
35
+ click_link "mark_read_#{unread_message.id}"
32
36
  end
33
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
37
+ it_behaves_like(
38
+ 'a bootstrap page with an alert',
39
+ 'info',
40
+ 'Update successful'
41
+ )
34
42
  end
35
43
  describe 'Marking Ignored' do
36
44
  before do
37
- visit '/box/in/conversations/' + unread_conversation.id.to_s
45
+ visit "/box/in/conversations/#{unread_conversation.id}"
38
46
  accept_confirm do
39
47
  click_link 'Mark as Ignored'
40
48
  end
41
49
  end
42
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Update successful'
50
+ it_behaves_like(
51
+ 'a bootstrap page with an alert',
52
+ 'info',
53
+ 'Update successful'
54
+ )
43
55
  end
44
56
  end
45
57
  end
@@ -17,7 +17,11 @@ RSpec.feature 'Messages' do
17
17
  fill_in_ckeditor 'Body', with: 'This is the body.'
18
18
  submit_via_button 'Send'
19
19
  end
20
- it_behaves_like 'a bootstrap page with an alert', 'warning', 'Message saved as draft.'
20
+ it_behaves_like(
21
+ 'a bootstrap page with an alert',
22
+ 'warning',
23
+ 'Message saved as draft.'
24
+ )
21
25
  end
22
26
  end
23
27
  describe 'Composing', js: true do
@@ -31,10 +35,16 @@ RSpec.feature 'Messages' do
31
35
  click_link 'add-attachment'
32
36
  click_link 'add-attachment'
33
37
  within '#attachments .nested-fields:nth-child(1)' do
34
- attach_file 'Attachment', File.absolute_path('./spec/dummy/app/assets/files/message_train/attachments/example.pdf')
38
+ attach_file 'Attachment', File.absolute_path(
39
+ './spec/dummy/app/assets/files/message_train/attachments/'\
40
+ 'example.pdf'
41
+ )
35
42
  end
36
43
  within '#attachments .nested-fields:nth-child(2)' do
37
- attach_file 'Attachment', File.absolute_path('./spec/dummy/app/assets/files/message_train/attachments/Bambisj.jpg')
44
+ attach_file 'Attachment', File.absolute_path(
45
+ './spec/dummy/app/assets/files/message_train/attachments/'\
46
+ 'Bambisj.jpg'
47
+ )
38
48
  end
39
49
  within '#attachments .nested-fields:nth-child(3)' do
40
50
  accept_confirm do
@@ -43,7 +53,11 @@ RSpec.feature 'Messages' do
43
53
  end
44
54
  submit_via_button 'Send'
45
55
  end
46
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Message sent.'
56
+ it_behaves_like(
57
+ 'a bootstrap page with an alert',
58
+ 'info',
59
+ 'Message sent.'
60
+ )
47
61
  end
48
62
  end
49
63
  describe 'Editing a Draft', js: true do
@@ -54,8 +68,13 @@ RSpec.feature 'Messages' do
54
68
  fill_in 'Subject', with: 'This is the subject.'
55
69
  fill_in_ckeditor 'Body', with: 'This is the body.'
56
70
  submit_via_button 'Send'
71
+ wait_until { page.has_css?('.alert') }
57
72
  end
58
- it_behaves_like 'a bootstrap page with an alert', 'info', 'Message sent.'
73
+ it_behaves_like(
74
+ 'a bootstrap page with an alert',
75
+ 'info',
76
+ 'Message sent.'
77
+ )
59
78
  it_behaves_like 'a bootstrap page without an alert', 'warning'
60
79
  end
61
80
  end
@@ -13,10 +13,13 @@ RSpec.feature 'Unsubscribes' do
13
13
  before do
14
14
  visit '/unsubscribes'
15
15
  end
16
- it_behaves_like 'a bootstrap page', title: 'Manage Your Email Notifications'
17
- context "displays a list of #subscriptions in .subscription" do
16
+ it_behaves_like(
17
+ 'a bootstrap page',
18
+ title: 'Manage Your Email Notifications'
19
+ )
20
+ context 'displays a list of #subscriptions in .subscription' do
18
21
  subject { page }
19
- it { should have_css("#subscriptions .subscription", minimum: 3) }
22
+ it { should have_css('#subscriptions .subscription', minimum: 3) }
20
23
  end
21
24
  end
22
25
  end
@@ -25,16 +28,28 @@ RSpec.feature 'Unsubscribes' do
25
28
  describe 'with a specific item' do
26
29
  before do
27
30
  visit '/unsubscribes'
28
- find("#unsubscribe-group-#{membered_group.id.to_s}").click
31
+ find("#unsubscribe-group-#{membered_group.id}").click
29
32
  end
30
- it_behaves_like 'a bootstrap page with an alert', 'info', 'You are now unsubscribed from Membered Group, which means that you will not be notified by email of any messages received by that Group.'
33
+ it_behaves_like(
34
+ 'a bootstrap page with an alert',
35
+ 'info',
36
+ 'You are now unsubscribed from Membered Group, which means that '\
37
+ 'you will not be notified by email of any messages received by '\
38
+ 'that Group.'
39
+ )
31
40
  end
32
41
  describe 'with all button' do
33
42
  before do
34
43
  visit '/unsubscribes'
35
44
  click_link 'Disable All Notifications'
36
45
  end
37
- it_behaves_like 'a bootstrap page with an alert', 'info', '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.'
46
+ it_behaves_like(
47
+ 'a bootstrap page with an alert',
48
+ 'info',
49
+ 'You have unsubscribed from all messages, which means that you '\
50
+ 'will not be notified by email of any messages received in any '\
51
+ 'of your boxes.'
52
+ )
38
53
  end
39
54
  end
40
55
  end
@@ -42,9 +57,15 @@ RSpec.feature 'Unsubscribes' do
42
57
  describe 'at /unsubscribes' do
43
58
  before do
44
59
  visit '/unsubscribes'
45
- find("#remove-unsubscribe-#{unsubscribed_group.id.to_s}").click
60
+ find("#remove-unsubscribe-#{unsubscribed_group.id}").click
46
61
  end
47
- it_behaves_like 'a bootstrap page with an alert', 'info', '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.'
62
+ it_behaves_like(
63
+ 'a bootstrap page with an alert',
64
+ 'info',
65
+ 'You are no longer unsubscribed from Unsubscribed Group, which '\
66
+ 'means that you will now be notified by email of any messages '\
67
+ 'received in that Group.'
68
+ )
48
69
  end
49
70
  describe 'with all button' do
50
71
  before do
@@ -52,7 +73,13 @@ RSpec.feature 'Unsubscribes' do
52
73
  click_link 'Disable All Notifications'
53
74
  click_link 'Enable Some Notifications'
54
75
  end
55
- it_behaves_like 'a bootstrap page with an alert', 'info', '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.'
76
+ it_behaves_like(
77
+ 'a bootstrap page with an alert',
78
+ 'info',
79
+ 'You are no longer unsubscribed from all messages, which means that '\
80
+ 'you will now be notified by email of any messages received in '\
81
+ 'boxes you are subscribed to.'
82
+ )
56
83
  end
57
84
  end
58
85
  end
@@ -59,4 +59,4 @@ describe MessageTrain::ApplicationHelper do
59
59
  it { should eq 2.years.ago.strftime('%b %-d, %Y') }
60
60
  end
61
61
  end
62
- end
62
+ end