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
@@ -13,126 +13,126 @@
13
13
 
14
14
  ActiveRecord::Schema.define(version: 20160207190409) do
15
15
 
16
- create_table "groups", force: :cascade do |t|
17
- t.string "title"
18
- t.string "slug"
19
- t.text "description"
20
- t.datetime "created_at", null: false
21
- t.datetime "updated_at", null: false
16
+ create_table 'groups', force: :cascade do |t|
17
+ t.string 'title'
18
+ t.string 'slug'
19
+ t.text 'description'
20
+ t.datetime 'created_at', null: false
21
+ t.datetime 'updated_at', null: false
22
22
  end
23
23
 
24
- create_table "message_train_attachments", force: :cascade do |t|
25
- t.integer "message_train_message_id"
26
- t.string "attachment_file_name"
27
- t.string "attachment_content_type"
28
- t.integer "attachment_file_size"
29
- t.datetime "attachment_updated_at"
30
- t.datetime "created_at", null: false
31
- t.datetime "updated_at", null: false
24
+ create_table 'message_train_attachments', force: :cascade do |t|
25
+ t.integer 'message_train_message_id'
26
+ t.string 'attachment_file_name'
27
+ t.string 'attachment_content_type'
28
+ t.integer 'attachment_file_size'
29
+ t.datetime 'attachment_updated_at'
30
+ t.datetime 'created_at', null: false
31
+ t.datetime 'updated_at', null: false
32
32
  end
33
33
 
34
- add_index "message_train_attachments", ["message_train_message_id"], name: "index_message_train_attachments_on_message_train_message_id"
34
+ add_index 'message_train_attachments', ['message_train_message_id'], name: 'index_message_train_attachments_on_message_train_message_id'
35
35
 
36
- create_table "message_train_conversations", force: :cascade do |t|
37
- t.string "subject"
38
- t.datetime "created_at", null: false
39
- t.datetime "updated_at", null: false
36
+ create_table 'message_train_conversations', force: :cascade do |t|
37
+ t.string 'subject'
38
+ t.datetime 'created_at', null: false
39
+ t.datetime 'updated_at', null: false
40
40
  end
41
41
 
42
- create_table "message_train_ignores", force: :cascade do |t|
43
- t.integer "participant_id"
44
- t.string "participant_type"
45
- t.integer "message_train_conversation_id"
46
- t.datetime "created_at", null: false
47
- t.datetime "updated_at", null: false
42
+ create_table 'message_train_ignores', force: :cascade do |t|
43
+ t.integer 'participant_id'
44
+ t.string 'participant_type'
45
+ t.integer 'message_train_conversation_id'
46
+ t.datetime 'created_at', null: false
47
+ t.datetime 'updated_at', null: false
48
48
  end
49
49
 
50
- add_index "message_train_ignores", ["message_train_conversation_id"], name: "index_message_train_ignores_on_message_train_conversation_id"
51
- add_index "message_train_ignores", ["participant_type", "participant_id"], name: "participant_index"
52
-
53
- create_table "message_train_messages", force: :cascade do |t|
54
- t.integer "message_train_conversation_id"
55
- t.integer "sender_id"
56
- t.string "sender_type"
57
- t.text "recipients_to_save"
58
- t.string "subject"
59
- t.text "body"
60
- t.boolean "draft", default: false
61
- t.datetime "created_at", null: false
62
- t.datetime "updated_at", null: false
50
+ add_index 'message_train_ignores', ['message_train_conversation_id'], name: 'index_message_train_ignores_on_message_train_conversation_id'
51
+ add_index 'message_train_ignores', ['participant_type', 'participant_id'], name: 'participant_index'
52
+
53
+ create_table 'message_train_messages', force: :cascade do |t|
54
+ t.integer 'message_train_conversation_id'
55
+ t.integer 'sender_id'
56
+ t.string 'sender_type'
57
+ t.text 'recipients_to_save'
58
+ t.string 'subject'
59
+ t.text 'body'
60
+ t.boolean 'draft', default: false
61
+ t.datetime 'created_at', null: false
62
+ t.datetime 'updated_at', null: false
63
63
  end
64
64
 
65
- add_index "message_train_messages", ["message_train_conversation_id"], name: "index_message_train_messages_on_message_train_conversation_id"
66
- add_index "message_train_messages", ["sender_type", "sender_id"], name: "index_message_train_messages_on_sender_type_and_sender_id"
67
-
68
- create_table "message_train_receipts", force: :cascade do |t|
69
- t.integer "recipient_id"
70
- t.string "recipient_type"
71
- t.integer "message_train_message_id"
72
- t.boolean "marked_read", default: false
73
- t.boolean "marked_trash", default: false
74
- t.boolean "marked_deleted", default: false
75
- t.boolean "sender", default: false
76
- t.datetime "created_at", null: false
77
- t.datetime "updated_at", null: false
78
- t.integer "received_through_id"
79
- t.string "received_through_type"
65
+ add_index 'message_train_messages', ['message_train_conversation_id'], name: 'index_message_train_messages_on_message_train_conversation_id'
66
+ add_index 'message_train_messages', ['sender_type', 'sender_id'], name: 'index_message_train_messages_on_sender_type_and_sender_id'
67
+
68
+ create_table 'message_train_receipts', force: :cascade do |t|
69
+ t.integer 'recipient_id'
70
+ t.string 'recipient_type'
71
+ t.integer 'message_train_message_id'
72
+ t.boolean 'marked_read', default: false
73
+ t.boolean 'marked_trash', default: false
74
+ t.boolean 'marked_deleted', default: false
75
+ t.boolean 'sender', default: false
76
+ t.datetime 'created_at', null: false
77
+ t.datetime 'updated_at', null: false
78
+ t.integer 'received_through_id'
79
+ t.string 'received_through_type'
80
80
  end
81
81
 
82
- add_index "message_train_receipts", ["message_train_message_id", "recipient_type", "recipient_id"], name: "message_recipient", unique: true
83
- add_index "message_train_receipts", ["message_train_message_id"], name: "index_message_train_receipts_on_message_train_message_id"
84
- add_index "message_train_receipts", ["received_through_type", "received_through_id"], name: "index_message_train_receipts_on_received_through"
85
- add_index "message_train_receipts", ["recipient_type", "recipient_id"], name: "index_message_train_receipts_on_recipient"
86
-
87
- create_table "message_train_unsubscribes", force: :cascade do |t|
88
- t.integer "recipient_id"
89
- t.string "recipient_type"
90
- t.integer "from_id"
91
- t.string "from_type"
92
- t.datetime "created_at", null: false
93
- t.datetime "updated_at", null: false
82
+ add_index 'message_train_receipts', ['message_train_message_id', 'recipient_type', 'recipient_id'], name: 'message_recipient', unique: true
83
+ add_index 'message_train_receipts', ['message_train_message_id'], name: 'index_message_train_receipts_on_message_train_message_id'
84
+ add_index 'message_train_receipts', ['received_through_type', 'received_through_id'], name: 'index_message_train_receipts_on_received_through'
85
+ add_index 'message_train_receipts', ['recipient_type', 'recipient_id'], name: 'index_message_train_receipts_on_recipient'
86
+
87
+ create_table 'message_train_unsubscribes', force: :cascade do |t|
88
+ t.integer 'recipient_id'
89
+ t.string 'recipient_type'
90
+ t.integer 'from_id'
91
+ t.string 'from_type'
92
+ t.datetime 'created_at', null: false
93
+ t.datetime 'updated_at', null: false
94
94
  end
95
95
 
96
- add_index "message_train_unsubscribes", ["from_type", "from_id"], name: "unsubscribe_from"
97
- add_index "message_train_unsubscribes", ["recipient_type", "recipient_id", "from_type", "from_id"], name: "unsubscribe", unique: true
98
- add_index "message_train_unsubscribes", ["recipient_type", "recipient_id"], name: "unsubscribe_recipient"
96
+ add_index 'message_train_unsubscribes', ['from_type', 'from_id'], name: 'unsubscribe_from'
97
+ add_index 'message_train_unsubscribes', ['recipient_type', 'recipient_id', 'from_type', 'from_id'], name: 'unsubscribe', unique: true
98
+ add_index 'message_train_unsubscribes', ['recipient_type', 'recipient_id'], name: 'unsubscribe_recipient'
99
99
 
100
- create_table "roles", force: :cascade do |t|
101
- t.string "name"
102
- t.integer "resource_id"
103
- t.string "resource_type"
104
- t.datetime "created_at"
105
- t.datetime "updated_at"
100
+ create_table 'roles', force: :cascade do |t|
101
+ t.string 'name'
102
+ t.integer 'resource_id'
103
+ t.string 'resource_type'
104
+ t.datetime 'created_at'
105
+ t.datetime 'updated_at'
106
106
  end
107
107
 
108
- add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
109
- add_index "roles", ["name"], name: "index_roles_on_name"
110
-
111
- create_table "users", force: :cascade do |t|
112
- t.string "email", default: "", null: false
113
- t.string "encrypted_password", default: "", null: false
114
- t.string "reset_password_token"
115
- t.datetime "reset_password_sent_at"
116
- t.datetime "remember_created_at"
117
- t.integer "sign_in_count", default: 0, null: false
118
- t.datetime "current_sign_in_at"
119
- t.datetime "last_sign_in_at"
120
- t.string "current_sign_in_ip"
121
- t.string "last_sign_in_ip"
122
- t.datetime "created_at", null: false
123
- t.datetime "updated_at", null: false
124
- t.string "display_name"
125
- t.string "slug"
108
+ add_index 'roles', ['name', 'resource_type', 'resource_id'], name: 'index_roles_on_name_and_resource_type_and_resource_id'
109
+ add_index 'roles', ['name'], name: 'index_roles_on_name'
110
+
111
+ create_table 'users', force: :cascade do |t|
112
+ t.string 'email', default: "", null: false
113
+ t.string 'encrypted_password', default: "", null: false
114
+ t.string 'reset_password_token'
115
+ t.datetime 'reset_password_sent_at'
116
+ t.datetime 'remember_created_at'
117
+ t.integer 'sign_in_count', default: 0, null: false
118
+ t.datetime 'current_sign_in_at'
119
+ t.datetime 'last_sign_in_at'
120
+ t.string 'current_sign_in_ip'
121
+ t.string 'last_sign_in_ip'
122
+ t.datetime 'created_at', null: false
123
+ t.datetime 'updated_at', null: false
124
+ t.string 'display_name'
125
+ t.string 'slug'
126
126
  end
127
127
 
128
- add_index "users", ["email"], name: "index_users_on_email", unique: true
129
- add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
128
+ add_index 'users', ['email'], name: 'index_users_on_email', unique: true
129
+ add_index 'users', ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
130
130
 
131
- create_table "users_roles", id: false, force: :cascade do |t|
132
- t.integer "user_id"
133
- t.integer "role_id"
131
+ create_table 'users_roles', id: false, force: :cascade do |t|
132
+ t.integer 'user_id'
133
+ t.integer 'role_id'
134
134
  end
135
135
 
136
- add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
136
+ add_index 'users_roles', ['user_id', 'role_id'], name: 'index_users_roles_on_user_id_and_role_id'
137
137
 
138
138
  end
@@ -8,168 +8,168 @@ after :users, :groups do
8
8
  first_group = Group.find_by_slug('first-group')
9
9
  membered_group = Group.find_by_slug('membered-group')
10
10
 
11
- sent_message = FactoryGirl.create(
12
- :simple_message,
13
- sender: first_user,
14
- recipients_to_save: { 'users' => second_user.slug },
15
- subject: 'Sent Conversation'
16
- )
17
-
18
- unread_message = FactoryGirl.create(
19
- :simple_message,
20
- sender: second_user,
21
- recipients_to_save: { 'users' => first_user.slug },
22
- subject: 'Unread Conversation'
23
- )
24
-
25
- to_many_message = FactoryGirl.create(
26
- :simple_message,
27
- sender: first_user,
28
- recipients_to_save: { 'users' => [second_user.slug, third_user.slug, fourth_user.slug].join(', ') },
29
- subject: 'To Many Conversation'
30
- )
31
-
32
- ignored_message = FactoryGirl.create(
33
- :simple_message,
34
- sender: second_user,
35
- recipients_to_save: { 'users' => first_user.slug },
36
- subject: 'Ignored Conversation'
37
- )
38
- ignored_message.conversation.set_ignored(first_user)
39
-
40
- trashed_message = FactoryGirl.create(
41
- :simple_message,
42
- sender: second_user,
43
- recipients_to_save: { 'users' => first_user.slug },
44
- subject: 'Trashed Conversation'
45
- )
46
- trashed_message.mark_trash_for(first_user)
47
-
48
- read_message = FactoryGirl.create(
49
- :simple_message,
50
- sender: second_user,
51
- recipients_to_save: { 'users' => first_user.slug },
52
- subject: 'Read Conversation'
53
- )
54
- read_message.mark_read_for(first_user)
55
-
56
-
57
- attachment_message = FactoryGirl.create(
58
- :simple_message,
59
- sender: second_user,
60
- recipients_to_save: { 'users' => first_user.slug },
61
- subject: 'Attachment Conversation',
62
- generate_attachment?: true
63
- )
64
-
65
- deleted_message = FactoryGirl.create(
66
- :simple_message,
67
- sender: second_user,
68
- recipients_to_save: { 'users' => first_user.slug },
69
- subject: 'Deleted Conversation'
70
- )
71
- deleted_message.mark_deleted_for(first_user)
72
-
73
- group_message = FactoryGirl.create(
74
- :simple_message,
75
- sender: first_user,
76
- recipients_to_save: { 'groups' => first_group.slug },
77
- subject: 'Group Announcement'
78
- )
79
-
80
- membered_group_message = FactoryGirl.create(
81
- :simple_message,
82
- sender: second_user,
83
- recipients_to_save: { 'groups' => membered_group.slug },
84
- subject: 'Membered Group Announcement'
85
- )
86
-
87
- membered_group_trashed_message = FactoryGirl.create(
88
- :simple_message,
89
- sender: second_user,
90
- recipients_to_save: { 'groups' => membered_group.slug },
91
- subject: 'Membered Group Trashed Conversation'
92
- )
93
- membered_group_trashed_message.mark(:trash, first_user)
94
-
95
- membered_group_read_message = FactoryGirl.create(
96
- :simple_message,
97
- sender: second_user,
98
- recipients_to_save: { 'groups' => membered_group.slug },
99
- subject: 'Membered Group Read Conversation'
100
- )
101
- membered_group_read_message.mark(:read, first_user)
102
-
103
- membered_group_ignored_message = FactoryGirl.create(
104
- :simple_message,
105
- sender: second_user,
106
- recipients_to_save: { 'groups' => membered_group.slug },
107
- subject: 'Membered Group Ignored Conversation'
108
- )
109
- membered_group_ignored_message.conversation.set_ignored(first_user)
110
-
111
- membered_group_deleted_message = FactoryGirl.create(
112
- :simple_message,
113
- sender: second_user,
114
- recipients_to_save: { 'groups' => membered_group.slug },
115
- subject: 'Membered Group Deleted Conversation'
116
- )
117
- membered_group_deleted_message.mark(:deleted, first_user)
118
-
119
- membered_group_draft = FactoryGirl.create(
120
- :simple_message,
121
- sender: second_user,
122
- recipients_to_save: { 'groups' => membered_group.slug },
123
- subject: 'Membered Group Draft',
124
- draft: true
125
- )
126
-
127
- owned_group_draft = FactoryGirl.create(
128
- :simple_message,
129
- sender: first_user,
130
- recipients_to_save: { 'groups' => first_group.slug },
131
- subject: 'Owned Group Draft',
132
- draft: true
133
- )
134
-
135
- role_message = FactoryGirl.create(
136
- :simple_message,
137
- sender: superadmin_user,
138
- recipients_to_save: { 'roles' => 'admin' },
139
- subject: 'Role Conversation'
140
- )
141
-
142
- role_draft = FactoryGirl.create(
143
- :simple_message,
144
- sender: superadmin_user,
145
- recipients_to_save: { 'roles' => 'admin' },
146
- subject: 'Role Draft',
147
- draft: true
148
- )
149
-
150
- draft_message = FactoryGirl.create(
151
- :simple_message,
152
- subject: 'This should turn into a draft',
153
- sender: first_user,
154
- recipients_to_save: {}
155
- )
156
-
157
- someone_elses_message = FactoryGirl.create(
158
- :simple_message,
159
- subject: "Someone Else's Conversation",
160
- sender: User.order(:id).last,
161
- recipients_to_save: { 'users' => second_user.slug }
11
+ FactoryGirl.create(
12
+ :simple_message,
13
+ sender: first_user,
14
+ recipients_to_save: { 'users' => second_user.slug },
15
+ subject: 'Sent Conversation'
16
+ )
17
+
18
+ FactoryGirl.create(
19
+ :simple_message,
20
+ sender: second_user,
21
+ recipients_to_save: { 'users' => first_user.slug },
22
+ subject: 'Unread Conversation'
23
+ )
24
+
25
+ FactoryGirl.create(
26
+ :simple_message,
27
+ sender: first_user,
28
+ recipients_to_save: {
29
+ 'users' => [
30
+ second_user.slug,
31
+ third_user.slug,
32
+ fourth_user.slug
33
+ ].join(', ')
34
+ },
35
+ subject: 'To Many Conversation'
36
+ )
37
+
38
+ FactoryGirl.create(
39
+ :simple_message,
40
+ sender: second_user,
41
+ recipients_to_save: { 'users' => first_user.slug },
42
+ subject: 'Ignored Conversation'
43
+ ).conversation.participant_ignore(first_user)
44
+
45
+ FactoryGirl.create(
46
+ :simple_message,
47
+ sender: second_user,
48
+ recipients_to_save: { 'users' => first_user.slug },
49
+ subject: 'Trashed Conversation'
50
+ ).mark_trash_for(first_user)
51
+
52
+ FactoryGirl.create(
53
+ :simple_message,
54
+ sender: second_user,
55
+ recipients_to_save: { 'users' => first_user.slug },
56
+ subject: 'Read Conversation'
57
+ ).mark_read_for(first_user)
58
+
59
+ FactoryGirl.create(
60
+ :simple_message,
61
+ sender: second_user,
62
+ recipients_to_save: { 'users' => first_user.slug },
63
+ subject: 'Attachment Conversation',
64
+ generate_attachment?: true
65
+ )
66
+
67
+ FactoryGirl.create(
68
+ :simple_message,
69
+ sender: second_user,
70
+ recipients_to_save: { 'users' => first_user.slug },
71
+ subject: 'Deleted Conversation'
72
+ ).mark_deleted_for(first_user)
73
+
74
+ FactoryGirl.create(
75
+ :simple_message,
76
+ sender: first_user,
77
+ recipients_to_save: { 'groups' => first_group.slug },
78
+ subject: 'Group Announcement'
79
+ )
80
+
81
+ FactoryGirl.create(
82
+ :simple_message,
83
+ sender: second_user,
84
+ recipients_to_save: { 'groups' => membered_group.slug },
85
+ subject: 'Membered Group Announcement'
86
+ )
87
+
88
+ FactoryGirl.create(
89
+ :simple_message,
90
+ sender: second_user,
91
+ recipients_to_save: { 'groups' => membered_group.slug },
92
+ subject: 'Membered Group Trashed Conversation'
93
+ ).mark(:trash, first_user)
94
+
95
+ FactoryGirl.create(
96
+ :simple_message,
97
+ sender: second_user,
98
+ recipients_to_save: { 'groups' => membered_group.slug },
99
+ subject: 'Membered Group Read Conversation'
100
+ ).mark(:read, first_user)
101
+
102
+ FactoryGirl.create(
103
+ :simple_message,
104
+ sender: second_user,
105
+ recipients_to_save: { 'groups' => membered_group.slug },
106
+ subject: 'Membered Group Ignored Conversation'
107
+ ).conversation.participant_ignore(first_user)
108
+
109
+ FactoryGirl.create(
110
+ :simple_message,
111
+ sender: second_user,
112
+ recipients_to_save: { 'groups' => membered_group.slug },
113
+ subject: 'Membered Group Deleted Conversation'
114
+ ).mark(:deleted, first_user)
115
+
116
+ FactoryGirl.create(
117
+ :simple_message,
118
+ sender: second_user,
119
+ recipients_to_save: { 'groups' => membered_group.slug },
120
+ subject: 'Membered Group Draft',
121
+ draft: true
122
+ )
123
+
124
+ FactoryGirl.create(
125
+ :simple_message,
126
+ sender: first_user,
127
+ recipients_to_save: { 'groups' => first_group.slug },
128
+ subject: 'Owned Group Draft',
129
+ draft: true
130
+ )
131
+
132
+ FactoryGirl.create(
133
+ :simple_message,
134
+ sender: superadmin_user,
135
+ recipients_to_save: { 'roles' => 'admin' },
136
+ subject: 'Role Conversation'
137
+ )
138
+
139
+ FactoryGirl.create(
140
+ :simple_message,
141
+ sender: superadmin_user,
142
+ recipients_to_save: { 'roles' => 'admin' },
143
+ subject: 'Role Draft',
144
+ draft: true
145
+ )
146
+
147
+ FactoryGirl.create(
148
+ :simple_message,
149
+ subject: 'This should turn into a draft',
150
+ sender: first_user,
151
+ recipients_to_save: {}
152
+ )
153
+
154
+ FactoryGirl.create(
155
+ :simple_message,
156
+ subject: "Someone Else's Conversation",
157
+ sender: User.order(:id).last,
158
+ recipients_to_save: { 'users' => second_user.slug }
162
159
  )
163
160
 
164
161
  long_message = FactoryGirl.create(
165
- :simple_message,
166
- subject: "Long Conversation",
167
- sender: second_user,
168
- recipients_to_save: { 'users' => first_user.slug }
162
+ :simple_message,
163
+ subject: 'Long Conversation',
164
+ sender: second_user,
165
+ recipients_to_save: { 'users' => first_user.slug }
169
166
  )
170
- FactoryGirl.create_list(:simple_message, 11,
171
- conversation: long_message.conversation,
172
- sender: first_user,
173
- recipients_to_save: { 'users' => second_user.slug }
167
+
168
+ FactoryGirl.create_list(
169
+ :simple_message,
170
+ 11,
171
+ conversation: long_message.conversation,
172
+ sender: first_user,
173
+ recipients_to_save: { 'users' => second_user.slug }
174
174
  )
175
- end
175
+ end
@@ -1,9 +1,13 @@
1
1
  after :users, :groups do
2
2
  User.find_each do |user|
3
3
  # Create some conversations that this user has received
4
- FactoryGirl.create_list(:message_from_random_sender, [*5..10].sample, recipients_to_save: { 'users' => user.slug })
4
+ FactoryGirl.create_list(
5
+ :message_from_random_sender,
6
+ [*5..10].sample,
7
+ recipients_to_save: { 'users' => user.slug }
8
+ )
5
9
 
6
10
  # Create some conversations that this user has sent
7
11
  FactoryGirl.create_list(:message, [*5..10].sample, sender: user)
8
12
  end
9
- end
13
+ end
@@ -1,7 +1,6 @@
1
1
  after :users do
2
2
  first_user = User.friendly.find('first-user')
3
3
  second_user = User.friendly.find('second-user')
4
- third_user = User.friendly.find('third-user')
5
4
  fourth_user = User.friendly.find('fourth-user')
6
5
  unsubscribed_user = User.friendly.find('unsubscribed-user')
7
6
 
@@ -14,23 +13,23 @@ after :users do
14
13
  unsubscribed_user.add_role(:member, first_group)
15
14
 
16
15
  membered_group = FactoryGirl.create(
17
- :group,
18
- title: 'Membered Group',
19
- owner: second_user
16
+ :group,
17
+ title: 'Membered Group',
18
+ owner: second_user
20
19
  )
21
20
  first_user.add_role(:member, membered_group)
22
21
  unsubscribed_user.add_role(:member, membered_group)
23
22
 
24
- empty_group = FactoryGirl.create(
25
- :group,
26
- title: 'Empty Group',
27
- owner: first_user
23
+ FactoryGirl.create(
24
+ :group,
25
+ title: 'Empty Group',
26
+ owner: first_user
28
27
  )
29
28
 
30
29
  unsubscribed_group = FactoryGirl.create(
31
- :group,
32
- title: 'Unsubscribed Group',
33
- owner: second_user
30
+ :group,
31
+ title: 'Unsubscribed Group',
32
+ owner: second_user
34
33
  )
35
34
  first_user.add_role(:member, unsubscribed_group)
36
- end
35
+ end
@@ -1,4 +1,14 @@
1
1
  after 'test:conversations' do
2
- FactoryGirl.create(:attachment, attachment: File.open('spec/dummy/app/assets/files/message_train/attachments/image-sample.jpg'))
3
- FactoryGirl.create(:attachment, attachment: File.open('spec/dummy/app/assets/files/message_train/attachments/pdf-sample.pdf'))
4
- end
2
+ FactoryGirl.create(
3
+ :attachment,
4
+ attachment: File.open(
5
+ 'spec/dummy/app/assets/files/message_train/attachments/image-sample.jpg'
6
+ )
7
+ )
8
+ FactoryGirl.create(
9
+ :attachment,
10
+ attachment: File.open(
11
+ 'spec/dummy/app/assets/files/message_train/attachments/pdf-sample.pdf'
12
+ )
13
+ )
14
+ end