activity_notification 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +11 -1
  3. data/README.md +63 -28
  4. data/activity_notification.gemspec +4 -2
  5. data/app/controllers/activity_notification/notifications_controller.rb +1 -1
  6. data/app/controllers/activity_notification/notifications_with_devise_controller.rb +10 -10
  7. data/app/views/activity_notification/notifications/default/_index.html.erb +9 -4
  8. data/lib/activity_notification.rb +7 -6
  9. data/lib/activity_notification/apis/notification_api.rb +14 -15
  10. data/lib/activity_notification/common.rb +15 -7
  11. data/lib/activity_notification/config.rb +2 -0
  12. data/lib/activity_notification/helpers/view_helpers.rb +5 -4
  13. data/lib/activity_notification/mailers/helpers.rb +9 -9
  14. data/lib/activity_notification/models.rb +16 -0
  15. data/lib/activity_notification/models/{notifiable.rb → concerns/notifiable.rb} +15 -10
  16. data/lib/activity_notification/models/{notifier.rb → concerns/notifier.rb} +6 -0
  17. data/lib/activity_notification/models/{target.rb → concerns/target.rb} +34 -17
  18. data/lib/activity_notification/renderable.rb +2 -1
  19. data/lib/activity_notification/roles/acts_as_notifiable.rb +38 -23
  20. data/lib/activity_notification/roles/acts_as_notifier.rb +11 -0
  21. data/lib/activity_notification/roles/acts_as_target.rb +9 -18
  22. data/lib/activity_notification/version.rb +1 -1
  23. data/lib/generators/activity_notification/{migration → active_record}/migration_generator.rb +5 -4
  24. data/lib/generators/activity_notification/controllers_generator.rb +1 -1
  25. data/lib/generators/activity_notification/install_generator.rb +3 -6
  26. data/lib/generators/activity_notification/{notification → models}/notification_generator.rb +5 -4
  27. data/lib/generators/activity_notification/views_generator.rb +20 -22
  28. data/lib/generators/templates/active_record/migration.rb +1 -1
  29. data/lib/generators/templates/activity_notification.rb +13 -3
  30. data/{config → lib/generators/templates}/locales/en.yml +0 -0
  31. data/lib/generators/templates/notification/notification.rb +4 -1
  32. data/spec/concerns/{notification_api_spec.rb → apis/notification_api_spec.rb} +169 -45
  33. data/spec/concerns/common_spec.rb +150 -0
  34. data/spec/concerns/models/notifiable_spec.rb +435 -0
  35. data/spec/concerns/models/notifier_spec.rb +23 -0
  36. data/spec/concerns/models/target_spec.rb +579 -0
  37. data/spec/concerns/renderable_spec.rb +110 -0
  38. data/spec/controllers/notifications_controller_shared_examples.rb +457 -0
  39. data/spec/controllers/notifications_controller_spec.rb +12 -0
  40. data/spec/controllers/notifications_with_devise_controller_spec.rb +81 -0
  41. data/spec/factories/admins.rb +5 -0
  42. data/spec/factories/articles.rb +1 -1
  43. data/spec/factories/comments.rb +1 -1
  44. data/spec/factories/dummy/dummy_notifiable.rb +4 -0
  45. data/spec/factories/dummy/dummy_notifier.rb +4 -0
  46. data/spec/factories/dummy/dummy_target.rb +4 -0
  47. data/spec/factories/notifications.rb +1 -1
  48. data/spec/factories/users.rb +7 -1
  49. data/spec/generators/active_record/migration_generator_spec.rb +41 -0
  50. data/spec/generators/controllers_generator_spec.rb +62 -0
  51. data/spec/generators/install_generator_spec.rb +43 -0
  52. data/spec/generators/models/notification_generator_spec.rb +41 -0
  53. data/spec/generators/views_generator_spec.rb +111 -0
  54. data/spec/helpers/polymorphic_helpers_spec.rb +89 -0
  55. data/spec/helpers/view_helpers_spec.rb +258 -0
  56. data/spec/mailers/mailer_spec.rb +98 -0
  57. data/spec/models/dummy/dummy_notifiable_spec.rb +6 -0
  58. data/spec/models/dummy/dummy_notifier_spec.rb +6 -0
  59. data/spec/models/dummy/dummy_target_spec.rb +6 -0
  60. data/spec/models/notification_spec.rb +5 -4
  61. data/spec/rails_app/app/assets/javascripts/application.js +2 -0
  62. data/spec/rails_app/app/controllers/articles_controller.rb +62 -0
  63. data/spec/rails_app/app/controllers/comments_controller.rb +34 -0
  64. data/spec/rails_app/app/models/admin.rb +8 -0
  65. data/spec/rails_app/app/models/article.rb +6 -6
  66. data/spec/rails_app/app/models/comment.rb +2 -2
  67. data/spec/rails_app/app/models/dummy/dummy_base.rb +2 -0
  68. data/spec/rails_app/app/models/dummy/dummy_notifiable.rb +4 -0
  69. data/spec/rails_app/app/models/dummy/dummy_notifier.rb +4 -0
  70. data/spec/rails_app/app/models/dummy/dummy_target.rb +4 -0
  71. data/spec/rails_app/app/models/user.rb +5 -5
  72. data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_path_test.html.erb +1 -0
  73. data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_test.html.erb +1 -0
  74. data/spec/rails_app/app/views/activity_notification/notifications/users/_custom_index.html.erb +1 -0
  75. data/spec/rails_app/app/views/activity_notification/notifications/users/custom/_test.html.erb +1 -0
  76. data/spec/rails_app/app/views/articles/_form.html.erb +20 -0
  77. data/spec/rails_app/app/views/articles/edit.html.erb +6 -0
  78. data/spec/rails_app/app/views/articles/index.html.erb +67 -0
  79. data/spec/rails_app/app/views/articles/new.html.erb +5 -0
  80. data/spec/rails_app/app/views/articles/show.html.erb +38 -0
  81. data/spec/rails_app/app/views/layouts/_header.html.erb +8 -0
  82. data/spec/rails_app/app/views/layouts/application.html.erb +3 -4
  83. data/spec/rails_app/config/initializers/activity_notification.rb +13 -3
  84. data/spec/rails_app/config/initializers/devise.rb +274 -274
  85. data/spec/rails_app/config/locales/activity_notification.en.yml +20 -0
  86. data/spec/rails_app/config/locales/devise.en.yml +62 -0
  87. data/spec/rails_app/config/routes.rb +6 -2
  88. data/spec/rails_app/db/migrate/20160715050433_create_test_tables.rb +6 -2
  89. data/spec/rails_app/db/schema.rb +8 -0
  90. data/spec/rails_app/db/seeds.rb +43 -0
  91. data/spec/roles/acts_as_notifiable_spec.rb +32 -0
  92. data/spec/roles/acts_as_notifier_spec.rb +17 -0
  93. data/spec/roles/acts_as_target_spec.rb +40 -0
  94. data/spec/spec_helper.rb +18 -14
  95. metadata +136 -12
@@ -3,6 +3,7 @@ module ActivityNotification
3
3
  class Config
4
4
  attr_accessor :enabled,
5
5
  :table_name,
6
+ :email_enabled,
6
7
  :mailer_sender,
7
8
  :mailer,
8
9
  :parent_mailer,
@@ -12,6 +13,7 @@ module ActivityNotification
12
13
  def initialize
13
14
  @enabled = true
14
15
  @table_name = "notifications"
16
+ @email_enabled = false
15
17
  @mailer_sender = nil
16
18
  @mailer = "ActivityNotification::Mailer"
17
19
  @parent_mailer = 'ActionMailer::Base'
@@ -41,11 +41,12 @@ module ActivityNotification
41
41
 
42
42
  if notification_index.present?
43
43
  content_for :notification_index do
44
+ @target = target
44
45
  begin
45
- render_notifications notification_index, notification_options
46
- rescue ActionView::MissingTemplate => e
46
+ render_notification notification_index, notification_options
47
+ rescue ActionView::MissingTemplate
47
48
  notification_options.delete(:target)
48
- render_notifications notification_index, notification_options
49
+ render_notification notification_index, notification_options
49
50
  end
50
51
  end
51
52
  end
@@ -53,7 +54,7 @@ module ActivityNotification
53
54
  # Render partial index
54
55
  begin
55
56
  render options.merge(partial: partial, layout: layout, locals: locals)
56
- rescue ActionView::MissingTemplate => e
57
+ rescue ActionView::MissingTemplate
57
58
  partial_root = "activity_notification/notifications/default"
58
59
  partial = select_path(partial_path, partial_root)
59
60
  render options.merge(partial: partial, layout: layout, locals: locals)
@@ -11,7 +11,7 @@ module ActivityNotification
11
11
  headers = headers_for(notification.key, options)
12
12
  begin
13
13
  mail headers
14
- rescue ActionView::MissingTemplate => e
14
+ rescue ActionView::MissingTemplate
15
15
  mail headers.merge(template_name: 'default')
16
16
  end
17
17
  end
@@ -28,8 +28,8 @@ module ActivityNotification
28
28
  headers = {
29
29
  subject: subject_for(key),
30
30
  to: mailer_to(@target),
31
- from: mailer_sender(@target.to_resource_name),
32
- reply_to: mailer_reply_to(@target.to_resource_name),
31
+ from: mailer_from(@notification),
32
+ reply_to: mailer_reply_to(@notification),
33
33
  template_path: template_paths,
34
34
  template_name: template_name(key)
35
35
  }.merge(options)
@@ -42,20 +42,20 @@ module ActivityNotification
42
42
  target.mailer_to
43
43
  end
44
44
 
45
- def mailer_reply_to(target_type)
46
- mailer_sender(target_type, :reply_to)
45
+ def mailer_reply_to(notification)
46
+ mailer_sender(notification, :reply_to)
47
47
  end
48
48
 
49
- def mailer_from(target_type)
50
- mailer_sender(target_type, :from)
49
+ def mailer_from(notification)
50
+ mailer_sender(notification, :from)
51
51
  end
52
52
 
53
- def mailer_sender(target_type, sender = :from)
53
+ def mailer_sender(notification, sender = :from)
54
54
  default_sender = default_params[sender]
55
55
  if default_sender.present?
56
56
  default_sender.respond_to?(:to_proc) ? instance_eval(&default_sender) : default_sender
57
57
  elsif ActivityNotification.config.mailer_sender.is_a?(Proc)
58
- ActivityNotification.config.mailer_sender.call(target_type)
58
+ ActivityNotification.config.mailer_sender.call(notification)
59
59
  else
60
60
  ActivityNotification.config.mailer_sender
61
61
  end
@@ -0,0 +1,16 @@
1
+ require 'activity_notification/roles/acts_as_target'
2
+ require 'activity_notification/roles/acts_as_notifiable'
3
+ require 'activity_notification/roles/acts_as_notifier'
4
+
5
+ module ActivityNotification
6
+ module Models
7
+ extend ActiveSupport::Concern
8
+ included do
9
+ include ActivityNotification::ActsAsTarget
10
+ include ActivityNotification::ActsAsNotifiable
11
+ include ActivityNotification::ActsAsNotifier
12
+ end
13
+ end
14
+ end
15
+
16
+ ActiveRecord::Base.class_eval { include ActivityNotification::Models }
@@ -4,7 +4,6 @@ module ActivityNotification
4
4
 
5
5
  included do
6
6
  include Common
7
- include ActsAsNotifiable
8
7
  include ActionDispatch::Routing::PolymorphicRoutes
9
8
  include Rails.application.routes.url_helpers
10
9
  class_attribute :_notification_targets,
@@ -21,6 +20,10 @@ module ActivityNotification
21
20
  end
22
21
 
23
22
  class_methods do
23
+ def available_as_notifiable?
24
+ true
25
+ end
26
+
24
27
  def set_notifiable_class_defaults
25
28
  self._notification_targets = {}
26
29
  self._notification_group = {}
@@ -55,7 +58,7 @@ module ActivityNotification
55
58
  if respond_to?(target_typed_method_name)
56
59
  send(target_typed_method_name, key)
57
60
  else
58
- resolve_value(_notification_group[plural_target_type_sym])
61
+ resolve_value(_notification_group[plural_target_type_sym], key)
59
62
  end
60
63
  end
61
64
 
@@ -77,16 +80,20 @@ module ActivityNotification
77
80
  if respond_to?(target_typed_method_name)
78
81
  send(target_typed_method_name, key)
79
82
  else
80
- resolve_value(_notifier[plural_target_type_sym])
83
+ resolve_value(_notifier[plural_target_type_sym], key)
81
84
  end
82
85
  end
83
86
 
84
87
  def notification_email_allowed?(target, key)
88
+ plural_target_type = target.class.to_s.underscore.pluralize
85
89
  plural_target_type_sym = target.to_resources_name.to_sym
86
- if _notification_email_allowed[plural_target_type_sym]
90
+ target_typed_method_name = "notification_email_allowed_for_#{plural_target_type}?"
91
+ if respond_to?(target_typed_method_name)
92
+ send(target_typed_method_name, target, key)
93
+ elsif _notification_email_allowed[plural_target_type_sym]
87
94
  resolve_value(_notification_email_allowed[plural_target_type_sym], target, key)
88
95
  else
89
- true
96
+ ActivityNotification.config.email_enabled
90
97
  end
91
98
  end
92
99
 
@@ -97,13 +104,11 @@ module ActivityNotification
97
104
  if respond_to?(target_typed_method_name)
98
105
  send(target_typed_method_name, key)
99
106
  elsif _notifiable_path[plural_target_type_sym]
100
- resolve_value(_notifiable_path[plural_target_type_sym])
107
+ resolve_value(_notifiable_path[plural_target_type_sym], key)
101
108
  else
102
109
  begin
103
110
  polymorphic_path(self)
104
- rescue NoMethodError => e
105
- raise NotImplementedError, "You have to implement #{self.class}##{__method__}, set :notifiable_path in acts_as_notifiable or set polymorphic_path routing for #{self.class}"
106
- rescue ActionController::UrlGenerationError => e
111
+ rescue NoMethodError, ActionController::UrlGenerationError
107
112
  raise NotImplementedError, "You have to implement #{self.class}##{__method__}, set :notifiable_path in acts_as_notifiable or set polymorphic_path routing for #{self.class}"
108
113
  end
109
114
  end
@@ -115,7 +120,7 @@ module ActivityNotification
115
120
  # TODO docs
116
121
  # overriding_notification_email_key(target, key)
117
122
 
118
- # Wrapper methods of SimpleNotify class methods
123
+ # Wrapper methods of Notification class methods
119
124
 
120
125
  def notify(target_type, options = {})
121
126
  Notification.notify(target_type, self, options)
@@ -7,5 +7,11 @@ module ActivityNotification
7
7
  class_name: "::ActivityNotification::Notification",
8
8
  as: :notifier
9
9
  end
10
+
11
+ class_methods do
12
+ def available_as_notifier?
13
+ true
14
+ end
15
+ end
10
16
  end
11
17
  end
@@ -3,18 +3,22 @@ module ActivityNotification
3
3
  extend ActiveSupport::Concern
4
4
  included do
5
5
  include Common
6
- include ActsAsTarget
7
6
  has_many :notifications,
8
7
  class_name: "::ActivityNotification::Notification",
9
8
  as: :target
10
- class_attribute :_notification_email, :_notification_email_allowed
9
+ class_attribute :_notification_email, :_notification_email_allowed, :_notification_devise_resource
11
10
  set_target_class_defaults
12
11
  end
13
12
 
14
13
  class_methods do
14
+ def available_as_target?
15
+ true
16
+ end
17
+
15
18
  def set_target_class_defaults
16
- self._notification_email = nil
17
- self._notification_email_allowed = false
19
+ self._notification_email = nil
20
+ self._notification_email_allowed = ActivityNotification.config.email_enabled
21
+ self._notification_devise_resource = ->(model) { model }
18
22
  end
19
23
  end
20
24
 
@@ -26,6 +30,17 @@ module ActivityNotification
26
30
  resolve_value(_notification_email_allowed, notifiable, key)
27
31
  end
28
32
 
33
+ def authenticated_with_devise?(current_resource)
34
+ devise_resource = resolve_value(_notification_devise_resource)
35
+ unless current_resource.instance_of? devise_resource.class
36
+ raise TypeError,
37
+ "Defferent type of current resource #{current_resource.class.to_s} "\
38
+ "with devise resource #{devise_resource.class.to_s} has been passed to #{self.class}##{__method__}. "\
39
+ "You have to override #{self.class}##{__method__} method or set devise_resource in acts_as_target."
40
+ end
41
+ current_resource == devise_resource
42
+ end
43
+
29
44
  def unopened_notification_count
30
45
  unopened_notification_index.count
31
46
  end
@@ -57,7 +72,7 @@ module ActivityNotification
57
72
  end
58
73
 
59
74
 
60
- # Wrapper methods of SimpleNotify class methods
75
+ # Wrapper methods of Notification class methods
61
76
 
62
77
  def notify_to(notifiable, options = {})
63
78
  Notification.notify_to(self, notifiable, options)
@@ -67,6 +82,7 @@ module ActivityNotification
67
82
  Notification.open_all_of(self, opened_at)
68
83
  end
69
84
 
85
+
70
86
  # Methods to be overriden
71
87
 
72
88
  # Typical method to get notifications index
@@ -82,22 +98,23 @@ module ActivityNotification
82
98
  end
83
99
 
84
100
  def unopened_notification_index_with_attributes(limit = nil)
85
- Notification.group_member_exists?(unopened_notification_index(limit)) ?
86
- unopened_notification_index(limit).with_target.with_notifiable.with_group.with_notifier :
87
- unopened_notification_index(limit).with_target.with_notifiable.with_notifier
101
+ if unopened_notification_index(limit).present?
102
+ Notification.group_member_exists?(unopened_notification_index(limit)) ?
103
+ unopened_notification_index(limit).with_target.with_notifiable.with_group.with_notifier :
104
+ unopened_notification_index(limit).with_target.with_notifiable.with_notifier
105
+ else
106
+ notifications.none
107
+ end
88
108
  end
89
109
 
90
110
  def opened_notification_index_with_attributes(limit = ActivityNotification.config.opened_limit)
91
- Notification.group_member_exists?(opened_notification_index(limit)) ?
92
- opened_notification_index(limit).with_target.with_notifiable.with_group.with_notifier :
93
- opened_notification_index(limit).with_target.with_notifiable.with_notifier
94
- end
95
-
96
- def authenticate_with_devise?(current_resource)
97
- unless current_resource.instance_of? self.class
98
- raise TypeError, "Defferent type of devise resource #{current_resource.class.to_s} has been passed to #{self.class}##{__method__}. You have to override #{self.class}##{__method__} method."
111
+ if opened_notification_index(limit).present?
112
+ Notification.group_member_exists?(opened_notification_index(limit)) ?
113
+ opened_notification_index(limit).with_target.with_notifiable.with_group.with_notifier :
114
+ opened_notification_index(limit).with_target.with_notifiable.with_notifier
115
+ else
116
+ notifications.none
99
117
  end
100
- current_resource == self
101
118
  end
102
119
 
103
120
  end
@@ -13,9 +13,10 @@ module ActivityNotification
13
13
  else
14
14
  k.insert(1, target.to_resource_name)
15
15
  end
16
+ k.push('text')
16
17
  k = k.join('.')
17
18
 
18
- I18n.t(k, parameters.merge(params) || {})
19
+ I18n.t(k, (parameters.merge(params) || {}).merge(group_member_count: group_member_count))
19
20
  end
20
21
 
21
22
  # Renders notification from views.
@@ -3,35 +3,50 @@ module ActivityNotification
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  class_methods do
6
- # Adds required callbacks for creating and updating
7
- # notifiable models.
6
+ # Adds required callbacks for creating and updating notifiable models.
8
7
  #
9
8
  # == Parameters:
10
- # [:targets]
11
- #TODO
12
- def acts_as_notifiable(target_type, opts = {})
13
- options = opts.clone
14
- assign_globals target_type, options
15
- nil
9
+ # [:targets, :group, :notifier, :parameters, :email_allowed, :notifiable_path]
10
+ # targets: Targets to send notification. It it set as ActiveRecord records or array of models.
11
+ # This is a only necessary option. If you do not specify this option, you have to override
12
+ # notification_targets or notification_[plural target type] (e.g. notification_users) method.
13
+ #
14
+ # group: Group unit of notifications. Notifications will be bundled by this group (and target, notifiable_type, key).
15
+ # This parameter is a optional.
16
+ #
17
+ # notifier: Notifier of the notification.This will be stored as notifier with notification record.
18
+ # This parameter is a optional.
19
+ #
20
+ # parameters: Parameter to add notification data. This will be stored as parameters with notification record.
21
+ # This parameter is a optional.
22
+ #
23
+ # email_allowed: If activity_notification sends notification email to these targets.
24
+ # Specified method or symbol is expected to return true (not nil) or false (nil).
25
+ # This parameter is a optional since default value is false.
26
+ # To use notification email, email_allowed option must return true (not nil) in both of notifiable and target model.
27
+ # This can be also configured default option in initializer.
28
+ #
29
+ # notifiable_path: Path to redirect from open or move action of notification controller.
30
+ # You can use this notifiable_path as notifiable link in notification view.
31
+ # This parameter is a optional since polymorphic_path is used as default value.
32
+ def acts_as_notifiable(target_type, options = {})
33
+ include Notifiable
34
+ (
35
+ [:targets, :group, :parameters, :email_allowed].map { |key|
36
+ options[key] ?
37
+ [key, self.send("_notification_#{key}".to_sym).store(target_type.to_sym, options.delete(key))] :
38
+ [nil, nil]
39
+ }.to_h.merge [:notifier, :notifiable_path].map { |key|
40
+ options[key] ?
41
+ [key, self.send("_#{key}".to_sym).store(target_type.to_sym, options.delete(key))] :
42
+ [nil, nil]
43
+ }.to_h
44
+ ).delete_if { |k, v| k.nil? }
16
45
  end
17
46
 
18
- def available_options
47
+ def available_notifiable_options
19
48
  [:targets, :group, :notifier, :parameters, :email_allowed, :notifiable_path].freeze
20
49
  end
21
-
22
- def assign_globals(target_type, options)
23
- [:targets, :group, :parameters, :email_allowed].each do |key|
24
- if options[key]
25
- self.send("_notification_#{key}".to_sym).store(target_type.to_sym, options.delete(key))
26
- end
27
- end
28
- [:notifier, :notifiable_path].each do |key|
29
- if options[key]
30
- self.send("_#{key}".to_sym).store(target_type.to_sym, options.delete(key))
31
- end
32
- end
33
- end
34
-
35
50
  end
36
51
  end
37
52
  end
@@ -0,0 +1,11 @@
1
+ module ActivityNotification
2
+ module ActsAsNotifier
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ def acts_as_notifier
7
+ include Notifier
8
+ end
9
+ end
10
+ end
11
+ end
@@ -3,27 +3,18 @@ module ActivityNotification
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  class_methods do
6
- def acts_as_target(opts = {})
7
- options = opts.clone
8
- if options[:skip_email] == true
9
- self.send("_notification_email_allowed=".to_sym, false)
10
- end
11
-
12
- assign_globals options
13
- nil
6
+ def acts_as_target(options = {})
7
+ include Target
8
+ available_target_options.map { |key|
9
+ options[key] ?
10
+ [key, self.send("_notification_#{key}=".to_sym, options.delete(key))] :
11
+ [nil, nil]
12
+ }.to_h.delete_if { |k, v| k.nil? }
14
13
  end
15
14
  alias_method :acts_as_notification_target, :acts_as_target
16
15
 
17
- def available_options
18
- [:skip_email, :email, :email_allowed].freeze
19
- end
20
-
21
- def assign_globals(options)
22
- [:email, :email_allowed].each do |key|
23
- if options[key]
24
- self.send("_notification_#{key}=".to_sym, options.delete(key))
25
- end
26
- end
16
+ def available_target_options
17
+ [:email, :email_allowed, :devise_resource].freeze
27
18
  end
28
19
  end
29
20
  end
@@ -1,3 +1,3 @@
1
1
  module ActivityNotification
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -6,11 +6,12 @@ module ActivityNotification
6
6
  class MigrationGenerator < ActiveRecord::Generators::Base
7
7
  source_root File.expand_path("../../../templates/active_record", __FILE__)
8
8
 
9
- argument :name, type: :string, default: 'create_notifications'
9
+ argument :name, type: :string, default: 'CreateNotifications'
10
10
 
11
- # Create migration in project's folder
12
- def generate_files
13
- migration_template 'migration.rb', "db/migrate/#{name}.rb"
11
+ # Create migration files in application directory
12
+ def create_migrations
13
+ @migration_name = name
14
+ migration_template 'migration.rb', "db/migrate/#{name.underscore}.rb"
14
15
  end
15
16
  end
16
17
  end