meta_notification 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +35 -0
  5. data/app/assets/javascripts/meta_notification/application.js +13 -0
  6. data/app/assets/stylesheets/meta_notification/application.css +15 -0
  7. data/app/controllers/meta_notification/api/v1/notification_settings_controller.rb +24 -0
  8. data/app/controllers/meta_notification/api/v1/notification_templates_controller.rb +61 -0
  9. data/app/controllers/meta_notification/api/v1/notification_types_controller.rb +64 -0
  10. data/app/controllers/meta_notification/api/v1/notifications_controller.rb +22 -0
  11. data/app/controllers/meta_notification/api/v1/user_notification_settings_controller.rb +20 -0
  12. data/app/controllers/meta_notification/api/v1/user_notifications_controller.rb +75 -0
  13. data/app/controllers/meta_notification/application_controller.rb +4 -0
  14. data/app/helpers/meta_notification/application_helper.rb +4 -0
  15. data/app/models/meta_notification/notification.rb +12 -0
  16. data/app/models/meta_notification/notification_setting.rb +9 -0
  17. data/app/models/meta_notification/notification_template.rb +17 -0
  18. data/app/models/meta_notification/notification_type.rb +22 -0
  19. data/app/models/meta_notification/user_notification.rb +6 -0
  20. data/app/models/meta_notification/user_notification_setting.rb +10 -0
  21. data/app/views/layouts/meta_notification/application.html.erb +14 -0
  22. data/app/views/meta_notification/api/v1/notification_settings/create.html.erb +2 -0
  23. data/app/views/meta_notification/api/v1/notification_settings/destroy.html.erb +2 -0
  24. data/app/views/meta_notification/api/v1/notification_settings/index.html.erb +2 -0
  25. data/app/views/meta_notification/api/v1/notification_settings/show.html.erb +2 -0
  26. data/app/views/meta_notification/api/v1/notification_settings/update.html.erb +2 -0
  27. data/app/views/meta_notification/api/v1/notification_templates/create.html.erb +2 -0
  28. data/app/views/meta_notification/api/v1/notification_templates/destroy.html.erb +2 -0
  29. data/app/views/meta_notification/api/v1/notification_templates/index.html.erb +2 -0
  30. data/app/views/meta_notification/api/v1/notification_templates/show.html.erb +2 -0
  31. data/app/views/meta_notification/api/v1/notification_templates/update.html.erb +2 -0
  32. data/app/views/meta_notification/api/v1/notification_types/create.html.erb +2 -0
  33. data/app/views/meta_notification/api/v1/notification_types/destroy.html.erb +2 -0
  34. data/app/views/meta_notification/api/v1/notification_types/index.html.erb +2 -0
  35. data/app/views/meta_notification/api/v1/notification_types/show.html.erb +2 -0
  36. data/app/views/meta_notification/api/v1/notification_types/update.html.erb +2 -0
  37. data/app/views/meta_notification/api/v1/notifications/resource_notification.rabl +14 -0
  38. data/app/views/meta_notification/api/v1/user_notification_settings/create.html.erb +2 -0
  39. data/app/views/meta_notification/api/v1/user_notification_settings/destroy.html.erb +2 -0
  40. data/app/views/meta_notification/api/v1/user_notification_settings/index.html.erb +2 -0
  41. data/app/views/meta_notification/api/v1/user_notification_settings/show.html.erb +2 -0
  42. data/app/views/meta_notification/api/v1/user_notification_settings/update.html.erb +2 -0
  43. data/app/views/meta_notification/api/v1/user_notifications/message_notifications.rabl +0 -0
  44. data/app/views/meta_notification/api/v1/user_notifications/notifications.rabl +21 -0
  45. data/config/routes.rb +45 -0
  46. data/db/migrate/20160615074820_create_meta_notification_notification_types.rb +15 -0
  47. data/db/migrate/20160618094218_create_meta_notification_notification_templates.rb +19 -0
  48. data/db/migrate/20160619133533_create_meta_notification_notifications.rb +14 -0
  49. data/db/migrate/20160620015754_create_meta_notification_user_notifications.rb +12 -0
  50. data/db/migrate/20160620020944_create_meta_notification_notification_settings.rb +10 -0
  51. data/db/migrate/20160620052742_create_meta_notification_user_notification_settings.rb +12 -0
  52. data/db/migrate/20160727124414_add_attachment_attachment_to_mn_notifications.rb +11 -0
  53. data/lib/api_constraints.rb +10 -0
  54. data/lib/meta_notification/engine.rb +15 -0
  55. data/lib/meta_notification/version.rb +3 -0
  56. data/lib/meta_notification.rb +7 -0
  57. data/lib/meta_notification_authority.rb +39 -0
  58. data/lib/mn_authorizers/notification_setting_authorizer.rb +28 -0
  59. data/lib/mn_authorizers/notification_template_authorizer.rb +28 -0
  60. data/lib/mn_authorizers/notification_type_authorizer.rb +28 -0
  61. data/lib/mn_authorizers/test_authorizer.rb +11 -0
  62. data/lib/mn_authorizers/user_notification_authorizer.rb +28 -0
  63. data/lib/tasks/meta_notification_tasks.rake +4 -0
  64. data/spec/controllers/meta_notification/api/v1/notification_settings_controller_spec.rb +42 -0
  65. data/spec/controllers/meta_notification/api/v1/notification_templates_controller_spec.rb +42 -0
  66. data/spec/controllers/meta_notification/api/v1/notification_types_controller_spec.rb +42 -0
  67. data/spec/controllers/meta_notification/api/v1/notifications_controller_spec.rb +7 -0
  68. data/spec/controllers/meta_notification/api/v1/user_notification_settings_controller_spec.rb +42 -0
  69. data/spec/controllers/meta_notification/api/v1/user_notifications_controller_spec.rb +42 -0
  70. data/spec/dummy/README.rdoc +28 -0
  71. data/spec/dummy/Rakefile +6 -0
  72. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  73. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  74. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  75. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  76. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  77. data/spec/dummy/bin/bundle +3 -0
  78. data/spec/dummy/bin/rails +4 -0
  79. data/spec/dummy/bin/rake +4 -0
  80. data/spec/dummy/bin/setup +29 -0
  81. data/spec/dummy/config/application.rb +33 -0
  82. data/spec/dummy/config/boot.rb +5 -0
  83. data/spec/dummy/config/database.yml +54 -0
  84. data/spec/dummy/config/environment.rb +5 -0
  85. data/spec/dummy/config/environments/development.rb +41 -0
  86. data/spec/dummy/config/environments/production.rb +79 -0
  87. data/spec/dummy/config/environments/test.rb +42 -0
  88. data/spec/dummy/config/initializers/assets.rb +11 -0
  89. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  90. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  91. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  92. data/spec/dummy/config/initializers/inflections.rb +16 -0
  93. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  94. data/spec/dummy/config/initializers/session_store.rb +3 -0
  95. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  96. data/spec/dummy/config/locales/en.yml +23 -0
  97. data/spec/dummy/config/routes.rb +4 -0
  98. data/spec/dummy/config/secrets.yml +22 -0
  99. data/spec/dummy/config.ru +4 -0
  100. data/spec/dummy/db/schema.rb +91 -0
  101. data/spec/dummy/log/development.log +264 -0
  102. data/spec/dummy/log/test.log +1192 -0
  103. data/spec/dummy/public/404.html +67 -0
  104. data/spec/dummy/public/422.html +67 -0
  105. data/spec/dummy/public/500.html +66 -0
  106. data/spec/dummy/public/favicon.ico +0 -0
  107. data/spec/factories/meta_notification/notification_settings.rb +28 -0
  108. data/spec/factories/meta_notification/notification_templates.rb +59 -0
  109. data/spec/factories/meta_notification/notification_types.rb +35 -0
  110. data/spec/factories/meta_notification/notifications.rb +80 -0
  111. data/spec/factories/meta_notification/user_notification_settings.rb +34 -0
  112. data/spec/factories/meta_notification/user_notifications.rb +35 -0
  113. data/spec/models/meta_notification/notification_setting_spec.rb +31 -0
  114. data/spec/models/meta_notification/notification_spec.rb +39 -0
  115. data/spec/models/meta_notification/notification_template_spec.rb +37 -0
  116. data/spec/models/meta_notification/notification_type_spec.rb +36 -0
  117. data/spec/models/meta_notification/user_notification_setting_spec.rb +31 -0
  118. data/spec/models/meta_notification/user_notification_spec.rb +28 -0
  119. data/spec/rails_helper.rb +60 -0
  120. data/spec/spec_helper.rb +92 -0
  121. data/spec/views/meta_notification/api/v1/notification_settings/create.html.erb_spec.rb +5 -0
  122. data/spec/views/meta_notification/api/v1/notification_settings/destroy.html.erb_spec.rb +5 -0
  123. data/spec/views/meta_notification/api/v1/notification_settings/index.html.erb_spec.rb +5 -0
  124. data/spec/views/meta_notification/api/v1/notification_settings/show.html.erb_spec.rb +5 -0
  125. data/spec/views/meta_notification/api/v1/notification_settings/update.html.erb_spec.rb +5 -0
  126. data/spec/views/meta_notification/api/v1/notification_templates/create.html.erb_spec.rb +5 -0
  127. data/spec/views/meta_notification/api/v1/notification_templates/destroy.html.erb_spec.rb +5 -0
  128. data/spec/views/meta_notification/api/v1/notification_templates/index.html.erb_spec.rb +5 -0
  129. data/spec/views/meta_notification/api/v1/notification_templates/show.html.erb_spec.rb +5 -0
  130. data/spec/views/meta_notification/api/v1/notification_templates/update.html.erb_spec.rb +5 -0
  131. data/spec/views/meta_notification/api/v1/notification_types/create.html.erb_spec.rb +5 -0
  132. data/spec/views/meta_notification/api/v1/notification_types/destroy.html.erb_spec.rb +5 -0
  133. data/spec/views/meta_notification/api/v1/notification_types/index.html.erb_spec.rb +5 -0
  134. data/spec/views/meta_notification/api/v1/notification_types/show.html.erb_spec.rb +5 -0
  135. data/spec/views/meta_notification/api/v1/notification_types/update.html.erb_spec.rb +5 -0
  136. data/spec/views/meta_notification/api/v1/user_notification_settings/create.html.erb_spec.rb +5 -0
  137. data/spec/views/meta_notification/api/v1/user_notification_settings/destroy.html.erb_spec.rb +5 -0
  138. data/spec/views/meta_notification/api/v1/user_notification_settings/index.html.erb_spec.rb +5 -0
  139. data/spec/views/meta_notification/api/v1/user_notification_settings/show.html.erb_spec.rb +5 -0
  140. data/spec/views/meta_notification/api/v1/user_notification_settings/update.html.erb_spec.rb +5 -0
  141. data/spec/views/meta_notification/api/v1/user_notifications/create.html.erb_spec.rb +5 -0
  142. data/spec/views/meta_notification/api/v1/user_notifications/destroy.html.erb_spec.rb +5 -0
  143. data/spec/views/meta_notification/api/v1/user_notifications/index.html.erb_spec.rb +5 -0
  144. data/spec/views/meta_notification/api/v1/user_notifications/show.html.erb_spec.rb +5 -0
  145. data/spec/views/meta_notification/api/v1/user_notifications/update.html.erb_spec.rb +5 -0
  146. metadata +355 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,28 @@
1
+ require 'pp'
2
+ invalid_notification_setting_list = [
3
+ {
4
+ # notification_type_id: 1,
5
+ is_mute: true
6
+ },
7
+ {
8
+ notification_type_id: 1
9
+ # is_mute: true
10
+ }
11
+ ]
12
+
13
+ FactoryGirl.define do
14
+ factory :valid_notification_setting, class: 'MetaNotification::NotificationSetting' do
15
+ # pp 'valid_notification_setting'
16
+ notification_type { FactoryGirl.create(:valid_notification_type_0) } # list[:notification_type_id]
17
+ is_mute { Faker::Boolean.boolean(0.5) }
18
+ end
19
+
20
+ invalid_notification_setting_list.each_with_index do |list, index|
21
+ invalid_method_name = 'invalid_notification_setting' + "_#{index}"
22
+ # pp invalid_method_name
23
+ factory invalid_method_name.to_sym, class: 'MetaNotification::NotificationSetting' do
24
+ notification_type_id list[:notification_type_id]
25
+ is_mute list[:is_mute]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,59 @@
1
+ require 'faker'
2
+
3
+ invalid_notification_template_list=[
4
+ {
5
+ notification_type: "blank",
6
+ in_app: Faker::Lorem.word,
7
+ mobile: Faker::Lorem.word,
8
+ push: Faker::Lorem.word,
9
+ email: Faker::Lorem.paragraph(5),
10
+ sms: Faker::Lorem.words(10).join(" "),
11
+ email_subject: Faker::Lorem.words(5).join(" "),
12
+ resource_id: Faker::Number.between(1, 10),
13
+ resource_type: Faker::Lorem.word
14
+ },
15
+ {
16
+ # in_app: Faker::Lorem.word,
17
+ # mobile: Faker::Lorem.word,
18
+ # push: Faker::Lorem.word,
19
+ # email: Faker::Lorem.paragraph(5),
20
+ # sms: Faker::Lorem.words(10).join(" "),
21
+ email_subject: Faker::Lorem.words(5).join(" "),
22
+ resource_id: Faker::Number.between(1, 10),
23
+ resource_type: Faker::Lorem.word
24
+ }
25
+ ]
26
+ FactoryGirl.define do
27
+ factory :valid_notification_template, class: 'MetaNotification::NotificationTemplate' do
28
+ # pp "valid_notification_template"
29
+ notification_type {FactoryGirl.create(:valid_notification_type_0)}
30
+ in_app {Faker::Lorem.word}
31
+ mobile {Faker::Lorem.word}
32
+ push {Faker::Lorem.word}
33
+ email {Faker::Lorem.paragraph(5)}
34
+ sms {Faker::Lorem.words(10).join(" ")}
35
+ email_subject {Faker::Lorem.words(5).join(" ")}
36
+ resource_id {Faker::Number.between(1, 10)}
37
+ resource_type {Faker::Lorem.word}
38
+ end
39
+
40
+
41
+ invalid_notification_template_list.each_with_index do |list, index|
42
+ invalid_method_name = 'invalid_notification_template' + "_#{index}"
43
+ factory invalid_method_name.to_sym, class: 'MetaNotification::NotificationTemplate' do
44
+ if list[:notification_type]=="blank"
45
+ notification_type nil
46
+ else
47
+ notification_type {FactoryGirl.create(:valid_notification_type_0)}
48
+ end
49
+ in_app list[:in_app]
50
+ mobile list[:mobile]
51
+ push list[:push]
52
+ email list[:email]
53
+ sms list[:sms]
54
+ email_subject list[:email_subject]
55
+ resource_id list[:resource_id]
56
+ resource_type list[:resource_type]
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,35 @@
1
+
2
+ name_display_name_valid_hash_list = {
3
+ 'drive_create' => 'Drive Create', 'drive_update' => 'Drive Update', 'student_move' => 'Student Move',
4
+ 'recruiter_add' => 'Recruiter Add', 'coordinator_add' => 'Coordinator Add', 'message' => 'message',
5
+ 'connection_request' => 'Connection Request', 'welcome_notification' => 'Welcome Notification',
6
+ 'd_c' => 'Drive create', '_test' => 'test', 'test_' => 'test', '0test' => 'test', 'test0' => 'test', '123' => 'test'
7
+ }
8
+ name_display_name_invalid_hash_list = {
9
+ '' => 'test', 'dc' => 'Drive Create', 'd@c' => 'Drive Create', '@dc' => 'Drive Create', 'd#c' => 'Drive Create',
10
+ 'test' => Faker::Lorem.paragraph(90)
11
+ }
12
+
13
+ FactoryGirl.define do
14
+ name_display_name_valid_hash_list.each_with_index do |(key, value), index|
15
+ valid_method_name = 'valid_notification_type' + "_#{index}"
16
+ # pp valid_method_name
17
+ factory valid_method_name.to_sym, class: MetaNotification::NotificationType do
18
+ name key
19
+ display_name value
20
+ created_by_id 1
21
+ updated_by_id 1
22
+ end
23
+ end
24
+
25
+ name_display_name_invalid_hash_list.each_with_index do |(key, value), index|
26
+ invalid_method_name = 'invalid_notification_type' + "_#{index}"
27
+ # pp invalid_method_name
28
+ factory invalid_method_name.to_sym, class: MetaNotification::NotificationType do
29
+ name key
30
+ display_name value
31
+ created_by_id 1
32
+ updated_by_id 1
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,80 @@
1
+
2
+ notification_list_for_null_validation=[{
3
+ notification_template_id:1,
4
+ in_app: "test",
5
+ mobile: "test",
6
+ # resource_type: "test",
7
+ resource_id: 1,
8
+ created_by_id: 1
9
+ },
10
+ {
11
+ notification_template_id:1,
12
+ in_app: "test",
13
+ mobile: "test",
14
+ resource_type: "test",
15
+ # resource_id: 1,
16
+ created_by_id: 1
17
+ },
18
+ ]
19
+ invalid_list=[{
20
+ # notification_template_id:nil,
21
+ in_app: "test",
22
+ mobile: "test",
23
+ resource_type: "test",
24
+ resource_id: 1,
25
+ created_by_id: 1
26
+ },
27
+ {
28
+ notification_template_id:1,
29
+ # in_app: nil,
30
+ mobile: "test",
31
+ resource_type: "test",
32
+ resource_id: 1,
33
+ created_by_id: 1
34
+ },
35
+ {
36
+ notification_template_id:1,
37
+ in_app: "test",
38
+ # mobile: "test",
39
+ resource_type: "test",
40
+ resource_id: 1,
41
+ created_by_id: 1
42
+ }
43
+ ]
44
+
45
+ FactoryGirl.define do
46
+ factory :valid_notification, class: 'MetaNotification::Notification' do
47
+ notification_template_id {Faker::Number.between(1, 10)}
48
+ in_app {Faker::Lorem.words(15).join(" ")}
49
+ mobile {Faker::Lorem.words(10).join(" ")}
50
+ resource_type {Faker::Lorem.word}
51
+ resource_id {Faker::Number.between(1, 10)}
52
+ created_by_id {Faker::Number.between(1, 10)}
53
+ end
54
+
55
+ notification_list_for_null_validation.each_with_index do|list,index|
56
+ valid_method_name="null_validation_notification"+"_#{index}"
57
+ # pp valid_method_name
58
+ factory valid_method_name.to_sym, class: 'MetaNotification::Notification' do
59
+ notification_template_id list[:notification_template_id]
60
+ in_app list[:in_app]
61
+ mobile list[:mobile]
62
+ resource_type list[:resource_type]
63
+ resource_id list[:resource_id]
64
+ created_by_id list[:created_by_id]
65
+ end
66
+ end
67
+
68
+ invalid_list.each_with_index do|list,index|
69
+ invalid_method_name="invalid_notification"+"_#{index}"
70
+ # pp invalid_method_name
71
+ factory invalid_method_name.to_sym, class: 'MetaNotification::Notification' do
72
+ notification_template_id list[:notification_template_id]
73
+ in_app list[:in_app]
74
+ mobile list[:mobile]
75
+ resource_type list[:resource_type]
76
+ resource_id list[:resource_id]
77
+ created_by_id list[:created_by_id]
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,34 @@
1
+ invalid_user_notification_settings_list = [
2
+ {
3
+ # user_id: 1,
4
+ notification_type_id: 1,
5
+ is_mute: true
6
+ },
7
+ {
8
+ user_id: 1,
9
+ # notification_type_id: 1,
10
+ is_mute: true
11
+ },
12
+ {
13
+ user_id: 1,
14
+ notification_type_id: 1,
15
+ # is_mute: true
16
+ }
17
+ ]
18
+ FactoryGirl.define do
19
+ factory :valid_user_notification_settings, class: 'MetaNotification::UserNotificationSetting' do
20
+ user_id { Faker::Number.between(1, 10) }
21
+ notification_type { FactoryGirl.create(:valid_notification_type_0) }
22
+ is_mute {Faker::Boolean.boolean(0.5)}
23
+ end
24
+
25
+ invalid_user_notification_settings_list.each_with_index do |list, index|
26
+ method_name = 'invalid_user_notification_setting' + "_#{index}"
27
+ # pp method_name
28
+ factory method_name.to_sym, class: 'MetaNotification::UserNotificationSetting' do
29
+ user_id list[:user_id]
30
+ notification_type_id list[:notification_type_id]
31
+ is_mute list[:is_mute]
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ invalid_user_notification_list = [
2
+ {
3
+ # user_id: 1,
4
+ notification_id: 1,
5
+ is_read: false
6
+ },
7
+ {
8
+ user_id: 1,
9
+ # notification_id: 1,
10
+ is_read: true
11
+ },
12
+ {
13
+ user_id: 1,
14
+ notification_id: 1,
15
+ # is_read: nil
16
+ }
17
+ ]
18
+
19
+ FactoryGirl.define do
20
+ factory :valid_user_notification, class: 'MetaNotification::UserNotification' do
21
+ user_id { Faker::Number.between(1, 10) }
22
+ notification_id { Faker::Number.between(1, 10) }
23
+ is_read { Faker::Boolean.boolean(0.5) }
24
+ end
25
+
26
+ invalid_user_notification_list.each_with_index do |list, index|
27
+ invalid_method_name = 'invalid_user_notification' + "_#{index}"
28
+ # pp invalid_method_name
29
+ factory invalid_method_name.to_sym, class: 'MetaNotification::UserNotification' do
30
+ user_id list[:user_id]
31
+ notification_id list[:notification_id]
32
+ is_read list[:is_read]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ require 'rails_helper'
2
+
3
+ module MetaNotification
4
+ RSpec.describe NotificationSetting, type: :model do
5
+ 10.times do
6
+ it "check valid notification setting" do
7
+ notification = FactoryGirl.build(:valid_notification_setting)
8
+ pp notification
9
+ expect(notification).to be_valid
10
+ end
11
+ end
12
+
13
+ 2.times do|index|
14
+ it "check invalid notification setting" do
15
+ method_name="invalid_notification_setting"+"_#{index}"
16
+ notification = FactoryGirl.build(method_name)
17
+ pp notification
18
+ expect(notification).not_to be_valid
19
+ end
20
+ end
21
+
22
+ 10.times do
23
+ it "create valid notification setting" do
24
+ notification = FactoryGirl.create(:valid_notification_setting)
25
+ pp notification
26
+ expect(notification).to be_valid
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,39 @@
1
+ require 'rails_helper'
2
+
3
+ module MetaNotification
4
+ RSpec.describe Notification, type: :model do
5
+ 2.times do
6
+ it 'check valid notification' do
7
+ notification = FactoryGirl.build(:valid_notification)
8
+ pp notification
9
+ expect(notification).to be_valid
10
+ end
11
+ end
12
+
13
+ 2.times do |index|
14
+ it 'check null validation for notification' do
15
+ method_name = 'null_validation_notification' + "_#{index}"
16
+ notification = FactoryGirl.build(method_name)
17
+ pp notification
18
+ expect(notification).to be_valid
19
+ end
20
+ end
21
+
22
+ 3.times do |index|
23
+ it 'check invalid notification' do
24
+ method_name = 'invalid_notification' + "_#{index}"
25
+ notification = FactoryGirl.build(method_name)
26
+ pp notification
27
+ expect(notification).not_to be_valid
28
+ end
29
+ end
30
+
31
+ 2.times do
32
+ it 'create valid notification type' do
33
+ notification = FactoryGirl.create(:valid_notification)
34
+ pp notification
35
+ expect(notification.id).not_to eql(nil)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails_helper'
2
+
3
+
4
+ module MetaNotification
5
+ RSpec.describe NotificationTemplate, type: :model do
6
+ 10.times do
7
+ it "validation of notification template" do
8
+ template = FactoryGirl.build(:valid_notification_template)
9
+ pp template
10
+ expect(template).to be_valid
11
+ end
12
+ end
13
+
14
+ 2.times do |index|
15
+ it "null validation of notification template" do
16
+ method_name = 'invalid_notification_template' + "_#{index}"
17
+ template = FactoryGirl.build(method_name)
18
+ pp template
19
+ expect(template).not_to be_valid
20
+ end
21
+ end
22
+
23
+ 10.times do
24
+ it "create valid notification template" do
25
+ template = FactoryGirl.create(:valid_notification_template)
26
+ pp template
27
+ expect(template).to be_valid
28
+ end
29
+ end
30
+
31
+ # pending "validate notification template."
32
+ # pending "creation of notification template."
33
+ # pending "update notification template."
34
+ # pending "delete notification template"
35
+ # pending "read notification template"
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ require 'rails_helper'
2
+
3
+ module MetaNotification
4
+ RSpec.describe NotificationType, type: :model do
5
+ 14.times do |index|
6
+ it 'check valid notification type' do
7
+ method_name = 'valid_notification_type' + "_#{index}"
8
+ type = FactoryGirl.build(method_name)
9
+ pp type
10
+ expect(type).to be_valid
11
+ end
12
+ end
13
+
14
+ 6.times do |index|
15
+ it 'check invalid notification type' do
16
+ method_name = 'invalid_notification_type' + "_#{index}"
17
+ type = FactoryGirl.build(method_name)
18
+ pp type
19
+ expect(type).not_to be_valid
20
+ end
21
+ end
22
+
23
+ 14.times do |index|
24
+ it 'create valid notification type' do
25
+ method_name = 'valid_notification_type' + "_#{index}"
26
+ type = FactoryGirl.create(method_name)
27
+ pp type
28
+ expect(type.id).not_to eql(nil)
29
+ end
30
+ end
31
+
32
+ # it "check uniqueness of name" do
33
+ # should validate_uniqueness_of(:name)
34
+ # end
35
+ end
36
+ end
@@ -0,0 +1,31 @@
1
+ require 'rails_helper'
2
+
3
+ module MetaNotification
4
+ RSpec.describe UserNotificationSetting, type: :model do
5
+ 10.times do
6
+ it 'check valid user notification settings' do
7
+ type = FactoryGirl.build(:valid_user_notification_settings)
8
+ pp type
9
+ expect(type).to be_valid
10
+ end
11
+ end
12
+
13
+ 3.times do |index|
14
+ it 'check invalid user notification settings' do
15
+ method_name = 'invalid_user_notification_setting' + "_#{index}"
16
+ pp method_name
17
+ type = FactoryGirl.build(method_name)
18
+ pp type
19
+ expect(type).not_to be_valid
20
+ end
21
+ end
22
+
23
+ 10.times do
24
+ it 'create valid user notification settings' do
25
+ type = FactoryGirl.create(:valid_user_notification_settings)
26
+ pp type
27
+ expect(type).to be_valid
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ require 'rails_helper'
2
+
3
+ module MetaNotification
4
+ RSpec.describe UserNotification, type: :model do
5
+ 10.times do
6
+ it 'check valid user notification ' do
7
+ type = FactoryGirl.build(:valid_user_notification)
8
+ pp type
9
+ expect(type).to be_valid
10
+ end
11
+ end
12
+ 3.times do |index|
13
+ it 'check invalid user notification' do
14
+ method_name = 'invalid_user_notification' + "_#{index}"
15
+ type = FactoryGirl.build(method_name)
16
+ pp type
17
+ expect(type).to be_valid
18
+ end
19
+ end
20
+ 10.times do
21
+ it 'create valid user notification ' do
22
+ type = FactoryGirl.build(:valid_user_notification)
23
+ pp type
24
+ expect(type).to be_valid
25
+ end
26
+ end
27
+ end
28
+ end