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
@@ -1,14 +1,20 @@
1
1
  module MessageTrain
2
+ # Ignore model
2
3
  class Ignore < ActiveRecord::Base
3
4
  belongs_to :participant, polymorphic: true
4
5
  belongs_to :conversation, foreign_key: :message_train_conversation_id
5
6
 
6
7
  validates_presence_of :conversation, :participant
7
8
 
8
- scope :find_all_by_participant, ->(participant) { where(participant: participant) }
9
+ scope :find_all_by_participant, (lambda do |participant|
10
+ where(participant: participant)
11
+ end)
9
12
 
10
13
  def self.conversations
11
- MessageTrain::Conversation.joins(:ignores).where(message_train_ignores: { id: where(nil) })
14
+ MessageTrain::Conversation.joins(:ignores)
15
+ .where(
16
+ message_train_ignores: { id: where(nil) }
17
+ )
12
18
  end
13
19
  end
14
20
  end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # Message model
2
3
  class Message < ActiveRecord::Base
3
4
  # Serializations
4
5
  serialize :recipients_to_save, Hash
@@ -19,7 +20,11 @@ module MessageTrain
19
20
  after_save :set_conversation_subject_if_alone
20
21
 
21
22
  # Nested Attributes
22
- accepts_nested_attributes_for :attachments, reject_if: :all_blank, allow_destroy: true
23
+ accepts_nested_attributes_for(
24
+ :attachments,
25
+ reject_if: :all_blank,
26
+ allow_destroy: true
27
+ )
23
28
 
24
29
  # Scopes
25
30
  default_scope { order(updated_at: :desc) }
@@ -27,12 +32,15 @@ module MessageTrain
27
32
  scope :drafts, -> { where(draft: true) }
28
33
  scope :by, ->(participant) { where(sender: participant) }
29
34
  scope :drafts_by, ->(participant) { drafts.by(participant) }
35
+ scope :filter_by_receipt_method, (lambda do |receipt_method, participant|
36
+ where(
37
+ id: where(nil).receipts.send(receipt_method, participant).message_ids
38
+ )
39
+ end)
30
40
 
31
41
  def mark(mark_to_set, participant)
32
42
  receipt_to_mark = receipts.for(participant).first
33
- unless receipt_to_mark.nil?
34
- receipt_to_mark.mark(mark_to_set)
35
- end
43
+ receipt_to_mark.present? && receipt_to_mark.mark(mark_to_set)
36
44
  end
37
45
 
38
46
  def self.mark(mark_to_set, participant)
@@ -54,37 +62,45 @@ module MessageTrain
54
62
  end
55
63
 
56
64
  def self.receipts
57
- MessageTrain::Receipt.joins(:message).where(message_train_messages: { id: where(nil) })
65
+ MessageTrain::Receipt.joins(:message)
66
+ .where(message_train_messages: { id: where(nil) })
58
67
  end
59
68
 
60
69
  def self.conversations
61
- MessageTrain::Conversation.joins(:messages).where(message_train_messages: { id: where(nil) })
70
+ MessageTrain::Conversation.joins(:messages)
71
+ .where(
72
+ message_train_messages: { id: where(nil) }
73
+ )
62
74
  end
63
75
 
64
76
  def method_missing(method_sym, *arguments, &block)
65
- # the first argument is a Symbol, so you need to_s it if you want to pattern match
77
+ # the first argument is a Symbol, so you need to_s it if you want to
78
+ # pattern match
66
79
  if method_sym.to_s =~ /^is_((.*)_(by|to|for|through))\?$/
67
- !receipts.send($1.to_sym, arguments.first).empty?
80
+ !receipts.send(Regexp.last_match[1].to_sym, arguments.first).empty?
68
81
  elsif method_sym.to_s =~ /^mark_(.*)_for$/
69
- receipts.for(arguments.first).first.mark($1.to_sym)
82
+ receipts.for(arguments.first).first.mark(Regexp.last_match[1].to_sym)
70
83
  else
71
84
  super
72
85
  end
73
86
  end
74
87
 
75
88
  def self.method_missing(method_sym, *arguments, &block)
76
- # the first argument is a Symbol, so you need to_s it if you want to pattern match
89
+ # the first argument is a Symbol, so you need to_s it if you want to
90
+ # pattern match
77
91
  if method_sym.to_s =~ /^with_(.*_(by|to|for|through))$/
78
- filter_by_receipt_method($1.to_sym, arguments.first)
92
+ filter_by_receipt_method(Regexp.last_match[1].to_sym, arguments.first)
79
93
  else
80
94
  super
81
95
  end
82
96
  end
83
97
 
84
- # It's important to know Object defines respond_to to take two parameters: the method to check, and whether to include private methods
98
+ # It's important to know Object defines respond_to to take two parameters:
99
+ # the method to check, and whether to include private methods
85
100
  # http://www.ruby-doc.org/core/classes/Object.html#M000333
86
101
  def respond_to?(method_sym, include_private = false)
87
- if method_sym.to_s =~ /^is_.*_(by|to|for|through)\?$/ || method_sym.to_s =~ /^mark_.*_for\?$/
102
+ if method_sym.to_s =~ /^is_.*_(by|to|for|through)\?$/ ||
103
+ method_sym.to_s =~ /^mark_.*_for\?$/
88
104
  true
89
105
  else
90
106
  super
@@ -99,11 +115,7 @@ module MessageTrain
99
115
  end
100
116
  end
101
117
 
102
- private
103
-
104
- scope :filter_by_receipt_method, ->(receipt_method, participant) {
105
- where(id: where(nil).receipts.send(receipt_method, participant).message_ids)
106
- }
118
+ private
107
119
 
108
120
  def create_conversation_if_blank
109
121
  if conversation.nil?
@@ -112,35 +124,20 @@ module MessageTrain
112
124
  end
113
125
 
114
126
  def generate_sender_receipt
115
- receipts.first_or_create!(recipient: sender, received_through: sender, sender: true)
127
+ receipts.first_or_create!(
128
+ recipient: sender,
129
+ received_through: sender,
130
+ sender: true
131
+ )
116
132
  end
117
133
 
118
134
  def generate_receipts_or_set_draft
119
135
  unless draft
120
136
  recipients_to_save.each do |table, slugs|
121
- model_name = table.classify
122
- model = model_name.constantize
123
-
124
- slugs.split(',').each do |slug|
125
- slug = slug.strip
126
- slug_column = MessageTrain.configuration.slug_columns[table.to_sym] || :slug
127
- if model.exists?(slug_column => slug)
128
- recipient = model.find_by(slug_column => slug)
129
- end_recipient_method = MessageTrain.configuration.valid_recipients_methods[table.to_sym]
130
- if end_recipient_method.nil?
131
- unless conversation.is_ignored?(recipient)
132
- receipts.create!(recipient: recipient, received_through: recipient)
133
- end
134
- else
135
- recipient.send(end_recipient_method).uniq.each do |end_recipient|
136
- unless conversation.is_ignored?(end_recipient) || end_recipient == sender
137
- receipts.create!(recipient: end_recipient, received_through: recipient)
138
- end
139
- end
140
- end
141
- else
142
- errors.add :recipients_to_save, :name_not_found.l(name: slug)
143
- end
137
+ slugs = slugs.split(',')
138
+ sender.class.table_name == table && (slugs -= [sender.slug])
139
+ slugs.each do |slug|
140
+ send_receipts(table, slug)
144
141
  end
145
142
  end
146
143
  reload
@@ -158,5 +155,38 @@ module MessageTrain
158
155
  end
159
156
  end
160
157
 
158
+ def send_receipts(table, slug)
159
+ model_name = table.classify
160
+ model = model_name.constantize
161
+ slug = slug.strip
162
+ slug_column = MessageTrain.configuration
163
+ .slug_columns[table.to_sym] || :slug
164
+ if model.exists?(slug_column => slug)
165
+ recipient = model.find_by(slug_column => slug)
166
+ end_recipient_method = MessageTrain.configuration
167
+ .valid_recipients_methods[
168
+ table.to_sym
169
+ ]
170
+ if end_recipient_method.nil?
171
+ unless conversation.participant_ignored?(recipient)
172
+ receipts.create!(
173
+ recipient: recipient,
174
+ received_through: recipient
175
+ )
176
+ end
177
+ else
178
+ recipient.send(end_recipient_method).uniq.each do |end_recipient|
179
+ next if conversation.participant_ignored?(end_recipient) ||
180
+ end_recipient == sender
181
+ receipts.create!(
182
+ recipient: end_recipient,
183
+ received_through: recipient
184
+ )
185
+ end
186
+ end
187
+ else
188
+ errors.add :recipients_to_save, :name_not_found.l(name: slug)
189
+ end
190
+ end
161
191
  end
162
192
  end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # Receipt model
2
3
  class Receipt < ActiveRecord::Base
3
4
  belongs_to :recipient, polymorphic: true
4
5
  belongs_to :received_through, polymorphic: true
@@ -6,15 +7,19 @@ module MessageTrain
6
7
  validates_presence_of :recipient, :message
7
8
 
8
9
  default_scope { order(updated_at: :desc) }
9
- scope :sender_receipt, -> { where('sender = ?', true) }
10
- scope :recipient_receipt, -> { where('sender = ?', false) }
10
+ scope :sender_receipt, -> { where(sender: true) }
11
+ scope :recipient_receipt, -> { where(sender: false) }
11
12
  scope :by, ->(sender) { sender_receipt.for(sender) }
12
- scope :for, ->(recipient) { where('recipient_type = ? AND recipient_id = ?', recipient.class.name, recipient.id) }
13
+ scope :for, (lambda do |recipient|
14
+ where(recipient: recipient)
15
+ end)
13
16
  scope :to, ->(recipient) { recipient_receipt.for(recipient) }
14
- scope :through, ->(received_through) { where('received_through_type = ? AND received_through_id = ?', received_through.class.name, received_through.id) }
15
- scope :trashed, ->(setting = true) { where('marked_trash = ?', setting) }
16
- scope :read, ->(setting = true) { where('marked_read = ?', setting) }
17
- scope :deleted, ->(setting = true) { where('marked_deleted = ?', setting) }
17
+ scope :through, (lambda do |received_through|
18
+ where(received_through: received_through)
19
+ end)
20
+ scope :trashed, ->(setting = true) { where(marked_trash: setting) }
21
+ scope :read, ->(setting = true) { where(marked_read: setting) }
22
+ scope :deleted, ->(setting = true) { where(marked_deleted: setting) }
18
23
 
19
24
  after_create :notify
20
25
 
@@ -35,7 +40,8 @@ module MessageTrain
35
40
  end
36
41
 
37
42
  def self.messages
38
- MessageTrain::Message.joins(:receipts).where(message_train_receipts: { id: where(nil) })
43
+ MessageTrain::Message.joins(:receipts)
44
+ .where(message_train_receipts: { id: where(nil) })
39
45
  end
40
46
 
41
47
  def self.conversation_ids
@@ -43,36 +49,43 @@ module MessageTrain
43
49
  end
44
50
 
45
51
  def self.conversations
46
- MessageTrain::Conversation.joins(:receipts).where(message_train_receipts: { id: where(nil) })
52
+ MessageTrain::Conversation.joins(:receipts)
53
+ .where(
54
+ message_train_receipts: { id: where(nil) }
55
+ )
47
56
  end
48
57
 
49
58
  def self.method_missing(method_sym, *arguments, &block)
50
- # the first argument is a Symbol, so you need to_s it if you want to pattern match
59
+ # the first argument is a Symbol, so you need to_s it if you want to
60
+ # pattern match
51
61
  if method_sym.to_s =~ /^receipts_(by|to|for|through)$/
52
- send($1.to_sym, arguments.first)
62
+ send(Regexp.last_match[1].to_sym, arguments.first)
53
63
  elsif method_sym.to_s =~ /^(.*)_(by|to|for|through)$/
54
- send($1.to_sym).send($2.to_sym, arguments.first)
64
+ send(Regexp.last_match[1].to_sym)
65
+ .send(Regexp.last_match[2].to_sym, arguments.first)
55
66
  elsif method_sym.to_s =~ /^un(.*)$/
56
- send($1.to_sym, false)
67
+ send(Regexp.last_match[1].to_sym, false)
57
68
  else
58
69
  super
59
70
  end
60
71
  end
61
72
 
62
- # It's important to know Object defines respond_to to take two parameters: the method to check, and whether to include private methods
73
+ # It's important to know Object defines respond_to to take two parameters:
74
+ # the method to check, and whether to include private methods
63
75
  # http://www.ruby-doc.org/core/classes/Object.html#M000333
64
76
  def self.respond_to?(method_sym, include_private = false)
65
- if method_sym.to_s =~ /^(.*)_(by|to|for|through)$/ || method_sym.to_s =~ /^un(.*)$/
77
+ if method_sym.to_s =~ /^(.*)_(by|to|for|through)$/ ||
78
+ method_sym.to_s =~ /^un(.*)$/
66
79
  true
67
80
  else
68
81
  super
69
82
  end
70
83
  end
71
84
 
72
- private
85
+ private
73
86
 
74
87
  def notify
75
- unless sender? or recipient.unsubscribed_from?(received_through)
88
+ unless sender? || recipient.unsubscribed_from?(received_through)
76
89
  ReceiptMailer.notification_email(self).deliver_later
77
90
  end
78
91
  end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # Unsubscribe model
2
3
  class Unsubscribe < ActiveRecord::Base
3
4
  belongs_to :recipient, polymorphic: true
4
5
  belongs_to :from, polymorphic: true
@@ -1,3 +1,3 @@
1
1
  - add_hero_unit do
2
2
  %h1
3
- 404 - Page Not Found
3
+ 404 - Page Not Found
@@ -1,6 +1,6 @@
1
1
  !!!
2
- %html{ lang: "en" }
2
+ %html{ lang: 'en' }
3
3
  %head
4
4
  %body
5
5
  #wrapper
6
- =yield
6
+ =yield
@@ -1 +1 @@
1
- = yield
1
+ = yield
@@ -4,4 +4,4 @@
4
4
  - if f.object.attachment.exists?
5
5
  .attachment
6
6
  = attachment_link(f.object)
7
- = f.file_field :attachment
7
+ = f.file_field :attachment
@@ -4,4 +4,4 @@
4
4
  = boxes_widget @box_user
5
5
  - else
6
6
  - add_widget do
7
- = collective_boxes_widget @collective, @box_user
7
+ = collective_boxes_widget @collective, @box_user
@@ -5,4 +5,4 @@ unless @box.results.all.empty?
5
5
  json.path item[:path]
6
6
  json.message item[:message]
7
7
  end
8
- end
8
+ end
@@ -1,4 +1,4 @@
1
1
  - unless boxes.empty?
2
2
  = dropdown_nav_item "#{:box_title_in.l} #{badge(boxes.first.unread_count.to_s) unless boxes.first.unread_count == 0}".html_safe, '#' do
3
3
  - boxes.each do |box|
4
- = box_nav_item box
4
+ = box_nav_item box
@@ -2,4 +2,4 @@
2
2
  %li{ html_options }
3
3
  = link_to box.title, message_train.box_path(box.division)
4
4
  - if unread_count > 0
5
- = badge unread_count.to_s
5
+ = badge unread_count.to_s
@@ -52,4 +52,4 @@
52
52
  = hidden_field_tag :mark_to_set
53
53
  %table#message-train-conversations.message-train-conversations.table.table-condensed
54
54
  = render @conversations
55
- = paginate @conversations
55
+ = paginate @conversations
@@ -3,4 +3,4 @@
3
3
  - if show[key]
4
4
  = dropdown_nav_item "#{key.to_s.humanize} #{badge(total_unread_count[key].to_s) unless total_unread_count[key] == 0}".html_safe, '#' do
5
5
  - boxes.each do |box|
6
- = collective_nav_item box, box_user
6
+ = collective_nav_item box, box_user
@@ -2,4 +2,4 @@
2
2
  %li{ html_options }
3
3
  = link_to box.title, message_train.collective_box_path(box.parent.path_part, box.division)
4
4
  - if unread_count > 0
5
- = badge unread_count.to_s
5
+ = badge unread_count.to_s
@@ -1 +1 @@
1
- = conversation_toggle conversation, 'remove', :deleted, :put, :mark_as_name.l(name: :deleted.l), data: { confirm: :delete_forever_this_cannot_be_undone.l }, collective: collective
1
+ = conversation_toggle conversation, 'remove', :deleted, :put, :mark_as_name.l(name: :deleted.l), data: { confirm: :delete_forever_this_cannot_be_undone.l }, collective: collective
@@ -1,4 +1,4 @@
1
- - if conversation.is_ignored?(@box_user)
1
+ - if conversation.participant_ignored?(@box_user)
2
2
  = conversation_toggle conversation, 'volume-up', :unignore, :delete, :mark_as_name.l(name: :unignored.l), collective: collective
3
3
  - else
4
- = conversation_toggle conversation, 'volume-off', :ignore, :delete, :mark_as_name.l(name: :ignored.l), data: { confirm: :are_you_sure.l}, collective: collective
4
+ = conversation_toggle conversation, 'volume-off', :ignore, :delete, :mark_as_name.l(name: :ignored.l), data: { confirm: :are_you_sure.l}, collective: collective
@@ -1,4 +1,4 @@
1
1
  - if conversation.includes_unread_for?(@box_user)
2
2
  = conversation_toggle conversation, 'eye-open', :read, :put, :mark_as_name.l(name: :read.l), collective: collective
3
3
  - else
4
- = conversation_toggle conversation, 'eye-close', :unread, :put, :mark_as_name.l(name: :unread.l), collective: collective
4
+ = conversation_toggle conversation, 'eye-close', :unread, :put, :mark_as_name.l(name: :unread.l), collective: collective
@@ -1,4 +1,4 @@
1
1
  - if options[:collective].nil?
2
2
  = icon_link_to icon, '', message_train.box_path(@box.division, objects: { 'conversations' => {conversation.id.to_s => conversation.id.to_s}}, mark_to_set: mark_to_set, format: :json), options
3
3
  - else
4
- = icon_link_to icon, '', message_train.collective_box_path(options[:collective].path_part, @box.division, objects: { 'conversations' => {conversation.id.to_s => conversation.id.to_s}}, mark_to_set: mark_to_set, format: :json), options
4
+ = icon_link_to icon, '', message_train.collective_box_path(options[:collective].path_part, @box.division, objects: { 'conversations' => {conversation.id.to_s => conversation.id.to_s}}, mark_to_set: mark_to_set, format: :json), options
@@ -1,4 +1,4 @@
1
1
  - if conversation.includes_untrashed_for?(@box_user)
2
2
  = conversation_toggle conversation, 'trash', :trash, :put, :mark_as_name.l(name: :trashed.l), data: { confirm: :are_you_sure.l}, collective: collective
3
3
  - else
4
- = conversation_toggle conversation, 'inbox', :untrash, :put, :mark_as_name.l(name: :untrashed.l), collective: collective
4
+ = conversation_toggle conversation, 'inbox', :untrash, :put, :mark_as_name.l(name: :untrashed.l), collective: collective
@@ -5,8 +5,8 @@
5
5
  .btn.btn-default.btn-lg= conversation_ignored_toggle(@conversation)
6
6
  #message_train_conversation.clear-both
7
7
  - unless @messages.empty?
8
- #message_train_messages.messages.panel-group{aria: { multiselectable: 'true' }, role: "tablist"}
8
+ #message_train_messages.messages.panel-group{aria: { multiselectable: 'true' }, role: 'tablist'}
9
9
  = render @messages
10
10
  = paginate @messages
11
11
  = modal 'attachment_preview', :attachment_preview.l do
12
- #image_placeholder
12
+ #image_placeholder
@@ -1,2 +1,6 @@
1
1
  json.id @conversation.id
2
- json.html render partial: 'conversation', formats: [:html], locals: { conversation: @conversation }
2
+ json.html render(
3
+ partial: 'conversation',
4
+ formats: [:html],
5
+ locals: { conversation: @conversation }
6
+ )
@@ -8,7 +8,7 @@
8
8
  = g.text_field :users, label: :recipients.l, class: 'recipient-input'
9
9
  - add_footer_javascript do
10
10
  :javascript
11
- url = "/box/in/participants/users.json"
11
+ url = '/box/in/participants/users.json'
12
12
  var suggestions = new Bloodhound({
13
13
  prefetch: url,
14
14
  remote: {
@@ -1,33 +1,33 @@
1
1
  - if message.draft
2
2
  .panel.panel-default{ class: message_class(@box, message), id: "message_train_message_#{message.id}", data: { mark_path: message_train.box_conversation_path(@box.division, id: message.message_train_conversation_id, objects: { 'messages' => {message.id.to_s => message.id.to_s} }) } }
3
- .panel-heading{role: "tab", id: "message_#{message.id}_heading"}
3
+ .panel-heading{role: 'tab', id: "message_#{message.id}_heading"}
4
4
  .message-actions.pull-right
5
5
  = message_read_toggle message
6
6
  = message_trashed_toggle message
7
7
  - if @box.division == :trash
8
8
  = message_deleted_toggle message
9
9
  %h4.panel-title
10
- = link_to "#message_#{message.id}_collapse", aria: { controls: "message_#{message.id}_collapse", expanded: 'true' }, data: { parent: '#accordion', toggle: 'collapse' }, role: "button" do
10
+ = link_to "#message_#{message.id}_collapse", aria: { controls: "message_#{message.id}_collapse", expanded: 'true' }, data: { parent: '#accordion', toggle: 'collapse' }, role: 'button' do
11
11
  %span.caret
12
12
  = :message_draft.l
13
13
  %small= message.updated_at
14
- .panel-collapse.collapse.in{aria: { labelledby: "message_#{message.id}_heading" }, role: "tabpanel", id: "message_#{message.id}_collapse"}
14
+ .panel-collapse.collapse.in{aria: { labelledby: "message_#{message.id}_heading" }, role: 'tabpanel', id: "message_#{message.id}_collapse"}
15
15
  .panel-body
16
16
  = render partial: 'message_train/messages/form', locals: { message: message }
17
17
  - else
18
18
  .panel.panel-default{ class: message_class(@box, message), id: "message_train_message_#{message.id}", data: { mark_path: message_train.box_conversation_path(@box.division, id: message.message_train_conversation_id, objects: { 'messages' => {message.id.to_s => message.id.to_s} }) } }
19
- .panel-heading{role: "tab", id: "message_#{message.id}_heading"}
19
+ .panel-heading{role: 'tab', id: "message_#{message.id}_heading"}
20
20
  .message-actions.pull-right
21
21
  = message_read_toggle message
22
22
  = message_trashed_toggle message
23
23
  - if @box.division == :trash
24
24
  = message_deleted_toggle message
25
25
  %h4.panel-title
26
- = link_to "#message_#{message.id}_collapse", aria: { controls: "message_#{message.id}_collapse", expanded: 'true' }, data: { parent: '#accordion', toggle: 'collapse' }, role: "button" do
26
+ = link_to "#message_#{message.id}_collapse", aria: { controls: "message_#{message.id}_collapse", expanded: 'true' }, data: { parent: '#accordion', toggle: 'collapse' }, role: 'button' do
27
27
  %span.caret
28
28
  = :from_sender.l(sender: message.sender.display_name)
29
29
  %small= message.updated_at
30
- .panel-collapse.collapse.in{aria: { labelledby: "message_#{message.id}_heading" }, role: "tabpanel", id: "message_#{message.id}_collapse"}
30
+ .panel-collapse.collapse.in{aria: { labelledby: "message_#{message.id}_heading" }, role: 'tabpanel', id: "message_#{message.id}_collapse"}
31
31
  .panel-body
32
32
  %p= :to_recipient.l(recipient: message_recipients(message))
33
33
  %p.lead= message.subject
@@ -1 +1 @@
1
- = icon_link_to icon, '', message_train.box_path(@box.division, objects: { 'messages' => {message.id.to_s => message.id.to_s}}, mark_to_set: mark_to_set, format: :json), options
1
+ = icon_link_to icon, '', message_train.box_path(@box.division, objects: { 'messages' => {message.id.to_s => message.id.to_s}}, mark_to_set: mark_to_set, format: :json), options
@@ -1,2 +1,6 @@
1
1
  json.id @message.id
2
- json.html render partial: 'message', formats: [:html], locals: { message: @message }
2
+ json.html render(
3
+ partial: 'message',
4
+ formats: [:html],
5
+ locals: { message: @message }
6
+ )
@@ -2,4 +2,4 @@ json.id participant.id
2
2
  json.model_name participant.class.name
3
3
  json.slug box_participant_slug(participant)
4
4
  json.name box_participant_name(participant)
5
- json.path message_train.box_model_participant_path(@box, participant.class.table_name, participant.id)
5
+ json.path box_participant_path(participant)
@@ -1,3 +1,3 @@
1
1
  json.participants @participants do |participant|
2
2
  json.partial! partial: 'participant', locals: { participant: participant }
3
- end
3
+ end
@@ -1 +1 @@
1
- json.participant render partial: 'participant', locals: { participant: @participant }
1
+ json.participant render(@participant)
@@ -10,4 +10,4 @@
10
10
  %p= :at_time_through_received_a_message.l(time: @receipt.created_at, through: @through_name, subject: @receipt.message.subject, path: message_train.collective_box_conversation_path(@through, :in, @receipt.message.conversation))
11
11
  %p{ style: 'font-size: .8rem; color: #666' }
12
12
  = :unsubscribe_from_option.l(from: @through_name)
13
- = link_to :manage_your_email_notifications.l, message_train.unsubscribes_url
13
+ = link_to :manage_your_email_notifications.l, message_train.unsubscribes_url
@@ -9,4 +9,4 @@
9
9
  = :at_time_through_received_a_message.l(time: @receipt.created_at, through: @through_name, subject: @receipt.message.subject, path: message_train.collective_box_conversation_path(@through, :in, @receipt.message.conversation))
10
10
 
11
11
  = :unsubscribe_from_option.l(from: @through_name)
12
- = message_train.unsubscribes_url
12
+ = message_train.unsubscribes_url
@@ -11,7 +11,7 @@
11
11
  %td= subscription[:from_name]
12
12
  - if subscription[:unsubscribe].nil?
13
13
  %td= :subscribed.l
14
- %td= button_to :disable_notifications.l, message_train.unsubscribes_path(unsubscribe: { from_type: subscription[:from_type], from_id: subscription[:from_id] }), class: 'btn btn-danger', id: "unsubscribe-#{subscription[:from_type].downcase}-#{subscription[:from_id]}", confirm: :are_you_sure.l
14
+ %td= button_to :disable_notifications.l, message_train.unsubscribes_path(unsubscribe: { from_type: subscription[:from_type], from_id: subscription[:from_id] }), class: 'btn btn-danger', id: "unsubscribe-#{subscription[:from_type].downcase}-#{subscription[:from_id]}"
15
15
  - else
16
16
  %td= :unsubscribed.l
17
17
  %td= button_to :enable_notifications.l, message_train.unsubscribe_path(subscription[:unsubscribe].id), method: :delete, class: 'btn btn-primary', id: "remove-unsubscribe-#{subscription[:unsubscribe].id}"
@@ -1 +1 @@
1
- ActionMailer::Base.register_template_extension('haml')
1
+ ActionMailer::Base.register_template_extension('haml')
@@ -1,5 +1,5 @@
1
1
  # Date
2
- Date::DATE_FORMATS[:default] = "%m/%d/%Y"
2
+ Date::DATE_FORMATS[:default] = '%m/%d/%Y'
3
3
 
4
4
  # Time
5
- Time::DATE_FORMATS[:default] = "%m/%d/%Y %I:%M %p"
5
+ Time::DATE_FORMATS[:default] = '%m/%d/%Y %I:%M %p'
@@ -92,7 +92,7 @@ en:
92
92
  untrashed: 'Untrashed'
93
93
  update_successful: 'Update successful'
94
94
  updated_at_time: "Updated at %{time}"
95
- wrong_number_of_arguments_for_thing_expected_right_got_wrong: "Wrong number of arguments for %{thing} (expected %{right}, got %{wrong})"
95
+ wrong_number_of_arguments_right_wrong: "Wrong number of arguments for %{thing} (expected %{right}, got %{wrong})"
96
96
  you_are_not_in_that_collective_type: "You are not in that %{collective_type}"
97
97
  you_have_chosen_not_to_be_emailed: 'You have chosen not to be emailed when new messages arrive.'
98
98
  you_must_sign_in_or_sign_up_to_continue: 'You must sign in or sign up to continue.'