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
data/config/routes.rb CHANGED
@@ -1,10 +1,23 @@
1
1
  MessageTrain::Engine.routes.draw do
2
2
  concern :boxable do
3
- resources :boxes, path: 'box', param: :division, only: [:show, :update, :destroy] do
3
+ resources(
4
+ :boxes,
5
+ path: 'box',
6
+ param: :division,
7
+ only: [:show, :update, :destroy]
8
+ ) do
4
9
  resources :conversations, only: [:show, :update, :destroy]
5
10
  resources :messages, except: [:index, :destroy]
6
- get 'participants/:model', as: :model_participants, to: 'participants#index'
7
- get 'participants/:model/:id', as: :model_participant, to: 'participants#show'
11
+ get(
12
+ 'participants/:model',
13
+ as: :model_participants,
14
+ to: 'participants#index'
15
+ )
16
+ get(
17
+ 'participants/:model/:id',
18
+ as: :model_participant,
19
+ to: 'participants#show'
20
+ )
8
21
  end
9
22
  end
10
23
 
@@ -16,18 +29,27 @@ MessageTrain::Engine.routes.draw do
16
29
  resources :unsubscribes, only: [:index, :create, :destroy]
17
30
  end
18
31
 
19
- match '/box(/*path)' => redirect { |p, req|
20
- req.flash[:error] = :you_must_sign_in_or_sign_up_to_continue.l
21
- MessageTrain.configuration.user_sign_in_path
22
- }, via: [:get, :put, :post, :delete]
32
+ match(
33
+ '/box(/*path)' => redirect do |_p, req|
34
+ req.flash[:error] = :you_must_sign_in_or_sign_up_to_continue.l
35
+ MessageTrain.configuration.user_sign_in_path
36
+ end,
37
+ via: [:get, :put, :post, :delete]
38
+ )
23
39
 
24
- match '/collectives(/*path)' => redirect { |p, req|
25
- req.flash[:error] = :you_must_sign_in_or_sign_up_to_continue.l
26
- MessageTrain.configuration.user_sign_in_path
27
- }, via: [:get, :put, :post, :delete]
40
+ match(
41
+ '/collectives(/*path)' => redirect do |_p, req|
42
+ req.flash[:error] = :you_must_sign_in_or_sign_up_to_continue.l
43
+ MessageTrain.configuration.user_sign_in_path
44
+ end,
45
+ via: [:get, :put, :post, :delete]
46
+ )
28
47
 
29
- match '/unsubscribes(/*path)' => redirect { |p, req|
30
- req.flash[:error] = :you_must_sign_in_or_sign_up_to_continue.l
31
- MessageTrain.configuration.user_sign_in_path
32
- }, via: [:get, :put, :post, :delete]
48
+ match(
49
+ '/unsubscribes(/*path)' => redirect do |_p, req|
50
+ req.flash[:error] = :you_must_sign_in_or_sign_up_to_continue.l
51
+ MessageTrain.configuration.user_sign_in_path
52
+ end,
53
+ via: [:get, :put, :post, :delete]
54
+ )
33
55
  end
@@ -1,36 +1,51 @@
1
1
  module MessageTrain
2
+ # Install Generator
2
3
  class InstallGenerator < Rails::Generators::Base
3
- source_root File.expand_path("../templates", __FILE__)
4
+ source_root File.expand_path('../templates', __FILE__)
4
5
  require File.expand_path('../../utils', __FILE__)
5
6
  include Generators::Utils
6
7
  include Rails::Generators::Migration
7
8
 
8
9
  def hello
9
- output "MessageTrain Installer will now install itself", :magenta
10
+ output 'MessageTrain Installer will now install itself', :magenta
10
11
  end
11
12
 
12
13
  # all public methods in here will be run in order
13
14
 
14
15
  def add_initializer
15
- output "First, you'll need an initializer. This is where you put your configuration options.", :magenta
16
- template "initializer.rb", "config/initializers/message_train.rb"
16
+ output(
17
+ "First, you'll need an initializer. "\
18
+ 'This is where you put your configuration options.',
19
+ :magenta
20
+ )
21
+ template 'initializer.rb', 'config/initializers/message_train.rb'
17
22
  end
18
23
 
19
24
  # Not doing this any more thanks to:
20
- # http://blog.pivotal.io/pivotal-labs/labs/leave-your-migrations-in-your-rails-engines
25
+ # http://blog.pivotal.io/pivotal-labs/labs/\
26
+ # leave-your-migrations-in-your-rails-engines
21
27
  def add_migrations
22
- output "Next come migrations.", :magenta
28
+ output 'Next come migrations.', :magenta
23
29
  rake 'message_train:install:migrations'
24
30
  end
25
31
 
26
32
  def add_route
27
- output "Adding MessageTrain to your routes.rb file", :magenta
28
- gsub_file "config/routes.rb", /mount MessageTrain::Engine => '\/.*', :as => 'message_train'/, ''
29
- route("mount MessageTrain::Engine => '/', :as => 'message_train'")
33
+ output 'Adding MessageTrain to your routes.rb file', :magenta
34
+ gsub_file(
35
+ 'config/routes.rb',
36
+ %r{mount MessageTrain::Engine => '/.*', as: 'message_train'},
37
+ ''
38
+ )
39
+ route("mount MessageTrain::Engine => '/', as: 'message_train'")
30
40
  end
31
41
 
32
42
  def goodbye
33
- output "Thanks for installing! Don't forget to run your migrations. See http://gemvein.com/museum/cases/message_train for configuration tips.", :magenta
43
+ output(
44
+ "Thanks for installing! Don't forget to run your migrations. "\
45
+ 'See http://gemvein.com/museum/cases/message_train for '\
46
+ 'configuration tips.',
47
+ :magenta
48
+ )
34
49
  end
35
50
  end
36
- end
51
+ end
@@ -9,5 +9,3 @@ MessageTrain.configure do |config|
9
9
  config.from_email = 'from@example.com'
10
10
  config.site_name = 'Example Site Name'
11
11
  end
12
-
13
- Rails.application.config.eager_load = true #FIXME: This is a weird place to put this. What would be better?
@@ -1,16 +1,23 @@
1
1
  module MessageTrain
2
2
  module Generators
3
+ # Generator Utiities
3
4
  module Utils
4
5
  def output(output, color = :green)
5
6
  say(" - #{output}", color)
6
7
  end
7
8
 
8
9
  def ask_for(wording, default_value = nil, override_if_present_value = nil)
9
- override_if_present_value.present? ?
10
- display("Using [#{override_if_present_value}] for question '#{wording}'") && override_if_present_value :
11
- ask(" ? #{wording} Press <enter> for [#{default_value}] >", :yellow).presence || default_value
10
+ if override_if_present_value.present?
11
+ display(
12
+ "Using [#{override_if_present_value}] for question '#{wording}'"
13
+ ) && override_if_present_value
14
+ else
15
+ ask(
16
+ " ? #{wording} Press <enter> for [#{default_value}] >",
17
+ :yellow
18
+ ).presence || default_value
19
+ end
12
20
  end
13
21
  end
14
22
  end
15
23
  end
16
-
@@ -1,8 +1,7 @@
1
+ # MessageTrain module
1
2
  module MessageTrain
2
3
  def self.configure(configuration = MessageTrain::Configuration.new)
3
- if block_given?
4
- yield configuration
5
- end
4
+ block_given? && yield(configuration)
6
5
  @@configuration = configuration
7
6
  end
8
7
 
@@ -10,6 +9,7 @@ module MessageTrain
10
9
  @@configuration ||= MessageTrain::Configuration.new
11
10
  end
12
11
 
12
+ # MessageTrain configuration
13
13
  class Configuration
14
14
  attr_accessor :slug_columns,
15
15
  :name_columns,
@@ -42,6 +42,5 @@ module MessageTrain
42
42
  self.from_email = ''
43
43
  self.site_name = 'Example Site Name'
44
44
  end
45
-
46
45
  end
47
- end
46
+ end
@@ -1,4 +1,5 @@
1
1
  module MessageTrain
2
+ # MessageTrain Engine
2
3
  class Engine < ::Rails::Engine
3
4
  isolate_namespace MessageTrain
4
5
  config.generators do |g|
@@ -9,12 +10,5 @@ module MessageTrain
9
10
  g.stylesheets false
10
11
  g.javascripts false
11
12
  end
12
-
13
- config.to_prepare do
14
- # Rails.application.config.assets.paths << File.expand_path("../../assets/stylesheets", __FILE__)
15
- # Rails.application.config.assets.paths << File.expand_path("../../assets/javascripts", __FILE__)
16
- # Rails.application.config.assets.precompile << %w( index )
17
- end
18
-
19
13
  end
20
14
  end
@@ -1,31 +1,27 @@
1
+ # String Extension
1
2
  module StringExtension
2
3
  def localize(*args)
3
- if args.first.is_a? Symbol
4
- sym = args.shift
5
- else
6
- sym = underscore.tr(' ', '_').gsub(/[^a-z0-9_]+/i, '').to_sym
7
- end
8
- args << {:default => self}
9
-
4
+ sym = if args.first.is_a? Symbol
5
+ args.shift
6
+ else
7
+ underscore.tr(' ', '_').gsub(/[^a-z0-9_]+/i, '').to_sym
8
+ end
9
+ args << { default: self }
10
10
  I18n.t(sym, *args).html_safe
11
11
  end
12
- alias :l :localize
13
- end
12
+ alias l localize
13
+ end
14
14
  String.send :include, StringExtension
15
-
16
-
15
+
16
+ # Symbol Extension
17
17
  module SymbolExtensionCustom
18
-
19
18
  def localize_with_debugging(*args)
20
19
  localized_sym = I18n.translate(self, *args)
21
20
  localized_sym.is_a?(String) ? localized_sym.html_safe : localized_sym
22
21
  end
23
- alias_method :l, :localize_with_debugging
24
-
22
+ alias l localize_with_debugging
25
23
  def l_with_args(*args)
26
- self.l(*args).html_safe
24
+ l(*args).html_safe
27
25
  end
28
-
29
26
  end
30
-
31
- Symbol.send :include, SymbolExtensionCustom
27
+ Symbol.send :include, SymbolExtensionCustom