mks_rate 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +38 -0
  5. data/app/controllers/mks/rate/application_controller.rb +8 -0
  6. data/app/controllers/mks/rate/chargeable_services_controller.rb +52 -0
  7. data/app/controllers/mks/rate/rate_change_requests_controller.rb +62 -0
  8. data/app/controllers/mks/rate/service_bundles_controller.rb +72 -0
  9. data/app/controllers/mks/rate/service_delivery_units_controller.rb +39 -0
  10. data/app/controllers/mks/rate/service_rates_controller.rb +14 -0
  11. data/app/controllers/mks/rate/service_types_controller.rb +45 -0
  12. data/app/controllers/mks/rate/unit_of_charges_controller.rb +11 -0
  13. data/app/models/mks/rate/application_record.rb +21 -0
  14. data/app/models/mks/rate/chargeable_service.rb +27 -0
  15. data/app/models/mks/rate/chargeable_service_discount.rb +31 -0
  16. data/app/models/mks/rate/rate_change_request.rb +16 -0
  17. data/app/models/mks/rate/service_bundle.rb +14 -0
  18. data/app/models/mks/rate/service_delivery_unit.rb +8 -0
  19. data/app/models/mks/rate/service_rate.rb +17 -0
  20. data/app/models/mks/rate/service_type.rb +7 -0
  21. data/app/models/mks/rate/unit_of_charge.rb +8 -0
  22. data/app/serializers/mks/rate/bundle_discount_serializer.rb +8 -0
  23. data/app/serializers/mks/rate/chargeable_service_serializer.rb +8 -0
  24. data/app/serializers/mks/rate/service_bundle_serializer.rb +7 -0
  25. data/app/serializers/mks/rate/service_rate_serializer.rb +8 -0
  26. data/app/serializers/mks/rate/working_rate_serializer.rb +8 -0
  27. data/app/services/mks/rate/rate_change_request_service.rb +61 -0
  28. data/app/services/mks/rate/service_bundle_service.rb +18 -0
  29. data/config/routes.rb +34 -0
  30. data/db/migrate/20171212165507_create_mks_rate_unit_of_charges.rb +10 -0
  31. data/db/migrate/20171213152154_create_mks_rate_service_delivery_units.rb +11 -0
  32. data/db/migrate/20171213152159_create_mks_rate_service_types.rb +10 -0
  33. data/db/migrate/20171214152030_create_mks_rate_chargeable_services.rb +19 -0
  34. data/db/migrate/20171215092528_create_mks_rate_chargeable_service_discounts.rb +16 -0
  35. data/db/migrate/20171218113530_create_mks_rate_service_rates.rb +15 -0
  36. data/db/migrate/20171219134144_create_mks_rate_service_bundles.rb +15 -0
  37. data/db/migrate/20171220133826_create_mks_rate_rate_change_requests.rb +21 -0
  38. data/db/migrate/20171221110018_create_mks_rate_service_bundles_chargeable_services.rb +12 -0
  39. data/db/seeds.rb +39 -0
  40. data/lib/mks/rate/engine.rb +24 -0
  41. data/lib/mks/rate/version.rb +5 -0
  42. data/lib/mks/rate.rb +4 -0
  43. data/lib/mks_rate.rb +2 -0
  44. data/lib/tasks/mks_rate_tasks.rake +4 -0
  45. data/spec/controllers/mks/rate/chargeable_services_controller_spec.rb +102 -0
  46. data/spec/controllers/mks/rate/rate_change_requests_controller_spec.rb +132 -0
  47. data/spec/controllers/mks/rate/service_bundles_controller_spec.rb +161 -0
  48. data/spec/controllers/mks/rate/service_delivery_units_controller_spec.rb +83 -0
  49. data/spec/controllers/mks/rate/service_rates_controller_spec.rb +34 -0
  50. data/spec/controllers/mks/rate/service_types_controller_spec.rb +103 -0
  51. data/spec/controllers/mks/rate/unit_of_charges_controller_spec.rb +24 -0
  52. data/spec/dummy/Rakefile +6 -0
  53. data/spec/dummy/app/assets/config/manifest.js +5 -0
  54. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  55. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  56. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  57. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  58. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  59. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  60. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  61. data/spec/dummy/app/jobs/application_job.rb +2 -0
  62. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  63. data/spec/dummy/app/models/application_record.rb +3 -0
  64. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  65. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  66. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  67. data/spec/dummy/bin/bundle +3 -0
  68. data/spec/dummy/bin/rails +4 -0
  69. data/spec/dummy/bin/rake +4 -0
  70. data/spec/dummy/bin/setup +34 -0
  71. data/spec/dummy/bin/update +29 -0
  72. data/spec/dummy/config/application.rb +31 -0
  73. data/spec/dummy/config/boot.rb +5 -0
  74. data/spec/dummy/config/cable.yml +9 -0
  75. data/spec/dummy/config/database.yml +25 -0
  76. data/spec/dummy/config/environment.rb +5 -0
  77. data/spec/dummy/config/environments/development.rb +54 -0
  78. data/spec/dummy/config/environments/production.rb +86 -0
  79. data/spec/dummy/config/environments/test.rb +42 -0
  80. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  81. data/spec/dummy/config/initializers/assets.rb +11 -0
  82. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  84. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  85. data/spec/dummy/config/initializers/inflections.rb +16 -0
  86. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  87. data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
  88. data/spec/dummy/config/initializers/session_store.rb +3 -0
  89. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  90. data/spec/dummy/config/locales/en.yml +23 -0
  91. data/spec/dummy/config/puma.rb +47 -0
  92. data/spec/dummy/config/routes.rb +3 -0
  93. data/spec/dummy/config/secrets.yml +22 -0
  94. data/spec/dummy/config/spring.rb +6 -0
  95. data/spec/dummy/config.ru +5 -0
  96. data/spec/dummy/db/schema.rb +440 -0
  97. data/spec/dummy/log/development.log +16917 -0
  98. data/spec/dummy/log/test.log +58746 -0
  99. data/spec/dummy/public/404.html +67 -0
  100. data/spec/dummy/public/422.html +67 -0
  101. data/spec/dummy/public/500.html +66 -0
  102. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  103. data/spec/dummy/public/apple-touch-icon.png +0 -0
  104. data/spec/dummy/public/favicon.ico +0 -0
  105. data/spec/factories/application_modules.rb +6 -0
  106. data/spec/factories/chargeable_service.rb +10 -0
  107. data/spec/factories/equipment_categories.rb +8 -0
  108. data/spec/factories/equipment_items.rb +14 -0
  109. data/spec/factories/equipment_locations.rb +9 -0
  110. data/spec/factories/equipment_types.rb +7 -0
  111. data/spec/factories/equipments.rb +9 -0
  112. data/spec/factories/location_types.rb +7 -0
  113. data/spec/factories/menus.rb +10 -0
  114. data/spec/factories/rate_change_requests.rb +15 -0
  115. data/spec/factories/service_bundles.rb +9 -0
  116. data/spec/factories/service_delivery_units.rb +7 -0
  117. data/spec/factories/service_rate.rb +8 -0
  118. data/spec/factories/service_types.rb +6 -0
  119. data/spec/factories/unit_of_charges.rb +6 -0
  120. data/spec/factories/user_roles.rb +18 -0
  121. data/spec/factories/users.rb +27 -0
  122. data/spec/models/mks/rate/chargeable_service_spec.rb +41 -0
  123. data/spec/models/mks/rate/rate_change_request_spec.rb +44 -0
  124. data/spec/models/mks/rate/service_bundle_spec.rb +28 -0
  125. data/spec/models/mks/rate/service_delivery_unit_spec.rb +24 -0
  126. data/spec/models/mks/rate/service_rate_spec.rb +21 -0
  127. data/spec/models/mks/rate/service_type_spec.rb +29 -0
  128. data/spec/models/mks/rate/unit_of_charge_spec.rb +24 -0
  129. data/spec/rails_helper.rb +57 -0
  130. data/spec/services/mks/rate/rate_change_request_service_spec.rb +53 -0
  131. data/spec/services/mks/rate/service_bundle_service_spec.rb +58 -0
  132. data/spec/spec_helper.rb +108 -0
  133. data/spec/support/factory_bot.rb +5 -0
  134. metadata +405 -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
File without changes
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :application_module, class: 'Mks::Auth::ApplicationModule' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ FactoryBot.define do
2
+ factory :chargeable_service, class: 'Mks::Rate::ChargeableService' do
3
+ code { FFaker::Name.unique.name }
4
+ name { FFaker::Name.name }
5
+ association :service_type
6
+ association :base_unit, factory: :unit_of_charge
7
+ association :utilization_unit, factory: :unit_of_charge
8
+ association :service_delivery_unit
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :equipment_category, class: 'Mks::Edm::EquipmentCategory' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ description { FFaker::Lorem.paragraph }
6
+ association :equipment_type
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ FactoryBot.define do
2
+ factory :equipment_item, class: 'Mks::Edm::EquipmentItem' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ description { FFaker::Name.name }
6
+ serial_number { FFaker::Name.name }
7
+ brand { FFaker::Name.name }
8
+ item_model { FFaker::Name.name }
9
+ purchase_price { 1.5 }
10
+ purchase_date { Date.new }
11
+ association :equipment
12
+ association :current_location, factory: :equipment_location
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :equipment_location, class: 'Mks::Edm::EquipmentLocation' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ association :location_type
6
+ description { FFaker::Name.name }
7
+ address { FFaker::Name.name }
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :equipment_type, class: 'Mks::Edm::EquipmentType' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ description { FFaker::Lorem.paragraph }
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :equipment, class: 'Mks::Edm::Equipment' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ description { FFaker::Name.name }
6
+ minimum_acquisition_time { 1.5 }
7
+ association :equipment_category
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :location_type, class: 'Mks::Edm::LocationType' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ description { FFaker::Name.name }
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ FactoryBot.define do
2
+ factory :menu, class: 'Mks::Auth::Menu' do
3
+ text { FFaker::Name.name }
4
+ icon_cls { FFaker::Name.name }
5
+ class_name { FFaker::Name.name }
6
+ location { FFaker::Name.name }
7
+ parent { nil }
8
+ association :application_module
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ FactoryBot.define do
2
+ factory :rate_change_request, class: 'Mks::Rate::RateChangeRequest' do
3
+ reference_number { FFaker::Name.unique.name }
4
+ authorized_by { FFaker::Name.name }
5
+ effective_on { Date.today }
6
+ authorized_on { Date.today }
7
+ rates {
8
+ [{ 'chargeable_service_id': 1, 'base_rate': 100, 'utilization_rate': 50 },
9
+ { 'chargeable_service_id': 2, 'base_rate': 100, 'utilization_rate': 25 }]
10
+ }
11
+ status { 'SUBMITTED' }
12
+ association :created_by, factory: :user
13
+ association :approved_by, factory: :user
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :service_bundle, class: 'Mks::Rate::ServiceBundle' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ description { FFaker::Name.name }
6
+ percent_discount { 100 }
7
+ association :service_delivery_unit
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :service_delivery_unit, class: 'Mks::Rate::ServiceDeliveryUnit' do
3
+ code { FFaker::Name.unique.name }
4
+ name { FFaker::Name.name }
5
+ address { FFaker::Name.name }
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :service_rate, class: 'Mks::Rate::ServiceRate' do
3
+ base_rate { 0 }
4
+ utilization_rate { 0 }
5
+ association :equipment_item
6
+ association :chargeable_service
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :service_type, class: 'Mks::Rate::ServiceType' do
3
+ code { FFaker::Name.name }
4
+ name { FFaker::Name.name }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :unit_of_charge, class: 'Mks::Rate::UnitOfCharge' do
3
+ name { FFaker::Name.unique.name }
4
+ unit_variables { { 'meter': 'float', 'day': 'float' } }
5
+ end
6
+ end
@@ -0,0 +1,18 @@
1
+ FactoryBot.define do
2
+ factory :user_role, class: 'Mks::Auth::UserRole' do
3
+ name { FFaker::Name.name }
4
+ association :application_module
5
+
6
+ trait :with_menu do
7
+ after(:create) do |role|
8
+ role.menus << create(:menu, text: 'menu1')
9
+ end
10
+ end
11
+
12
+ trait :with_menus do
13
+ after(:create) do |role|
14
+ role.menus = [create(:menu, text: 'menu1'), create(:menu, text: 'menu2'), create(:menu, text: 'menu3')]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ FactoryBot.define do
2
+ factory :user, class: 'Mks::Auth::User' do
3
+ first_name { FFaker::Name.name }
4
+ last_name { FFaker::Name.name }
5
+ email { FFaker::Internet.email }
6
+ active { true }
7
+ password { FFaker::Internet.password(min_length=6) }
8
+
9
+ trait :with_role do
10
+ after(:create) do |user|
11
+ user.roles << create(:user_role, name: 'role1')
12
+ end
13
+ end
14
+
15
+ trait :with_role_and_menus do
16
+ after(:create) do |user|
17
+ user.roles << create(:user_role, :with_menus)
18
+ end
19
+ end
20
+
21
+ trait :with_roles do
22
+ after(:create) do |user|
23
+ user.roles = [create(:user_role, name: 'role1'), create(:user_role, name: 'role2'), create(:user_role, name: 'role3')]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ require 'rails_helper'
2
+
3
+ module Mks
4
+ module Rate
5
+ RSpec.describe ChargeableService, type: :model do
6
+ it 'has a valid factory' do
7
+ expect(create(:chargeable_service)).to be_valid
8
+ end
9
+
10
+ it 'is invalid without code' do
11
+ expect(build(:chargeable_service, code: nil)).not_to be_valid
12
+ end
13
+
14
+ it 'is invalid without name' do
15
+ expect(build(:chargeable_service, name: nil)).not_to be_valid
16
+ end
17
+
18
+ it 'is invalid with without base unit' do
19
+ expect(build(:chargeable_service, base_unit: nil)).not_to be_valid
20
+ end
21
+
22
+ it 'is invalid without service delivery unit' do
23
+ expect(build(:chargeable_service, service_delivery_unit_id: nil)).not_to be_valid
24
+ end
25
+
26
+ it 'can not have chargeable services with same code' do
27
+ cs = create(:chargeable_service)
28
+ expect(build(:chargeable_service, code: cs.code, service_delivery_unit_id: cs.service_delivery_unit_id)).not_to be_valid
29
+ end
30
+
31
+ it 'can create default service bundle upon save' do
32
+ cs = create(:chargeable_service)
33
+ expect(ServiceBundle.count).to eq 1
34
+ sb = ServiceBundle.first
35
+ expect(sb.name).to eq cs.name
36
+ expect(sb.code).to eq cs.code
37
+ expect(sb.chargeable_services.count).to eq 1
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ require 'rails_helper'
2
+
3
+ module Mks
4
+ module Rate
5
+ RSpec.describe RateChangeRequest, type: :model do
6
+ it 'has valid factory' do
7
+ expect(create(:rate_change_request)).to be_valid
8
+ end
9
+
10
+ it 'is invalid without authorization date' do
11
+ expect(build(:rate_change_request, authorized_on: nil)).not_to be_valid
12
+ end
13
+
14
+ it 'is invalid without reference number' do
15
+ expect(build(:rate_change_request, reference_number: nil)).not_to be_valid
16
+ end
17
+
18
+ it 'is invalid with duplicate reference number' do
19
+ rcr = create(:rate_change_request)
20
+ expect(build(:rate_change_request, reference_number: rcr.reference_number)).not_to be_valid
21
+ end
22
+
23
+ it 'is invalid without authorized by' do
24
+ expect(build(:rate_change_request, authorized_by: nil)).not_to be_valid
25
+ end
26
+
27
+ it 'is invalid without effective date' do
28
+ expect(build(:rate_change_request, effective_on: nil)).not_to be_valid
29
+ end
30
+
31
+ it 'is invalid without rate' do
32
+ expect(build(:rate_change_request, rates: {})).not_to be_valid
33
+ end
34
+
35
+ it 'is invalid without status' do
36
+ expect(build(:rate_change_request, status: nil)).not_to be_valid
37
+ end
38
+
39
+ it 'is valid without approved by' do
40
+ expect(create(:rate_change_request, approved_by: nil)).to be_valid
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,28 @@
1
+ require 'rails_helper'
2
+
3
+ module Mks
4
+ module Rate
5
+ RSpec.describe ServiceBundle, type: :model do
6
+ it 'has a valid factory' do
7
+ expect(create(:service_bundle)).to be_valid
8
+ end
9
+
10
+ it 'is invalid with no code' do
11
+ expect(build(:service_bundle, code: nil)).not_to be_valid
12
+ end
13
+
14
+ it 'is invalid with no name' do
15
+ expect(build(:service_bundle, name: nil)).not_to be_valid
16
+ end
17
+
18
+ it 'is invalid with no percent discount' do
19
+ expect(build(:service_bundle, percent_discount: nil)).not_to be_valid
20
+ end
21
+
22
+ it 'is invalid with duplicate code' do
23
+ sb = create(:service_bundle)
24
+ expect(build(:service_bundle, code: sb.code)).not_to be_valid
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ require 'rails_helper'
2
+
3
+ module Mks
4
+ module Rate
5
+ RSpec.describe ServiceDeliveryUnit, type: :model do
6
+ it 'has valid factory' do
7
+ expect(create(:service_delivery_unit)).to be_valid
8
+ end
9
+
10
+ it 'is invalid without code' do
11
+ expect(build(:service_delivery_unit, code: nil)).not_to be_valid
12
+ end
13
+
14
+ it 'is invalid without name' do
15
+ expect(build(:service_delivery_unit, name: nil)).not_to be_valid
16
+ end
17
+
18
+ it 'can not have two service delivery units with same code' do
19
+ sdu = create(:service_delivery_unit)
20
+ expect(build(:service_delivery_unit, code: sdu.code)).not_to be_valid
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails_helper'
2
+
3
+ module Mks
4
+ module Rate
5
+ RSpec.describe ServiceRate, type: :model do
6
+ it 'has valid factory' do
7
+ expect(create(:service_rate)).to be_valid
8
+ end
9
+ it 'is invalid without utilization rate' do
10
+ expect(build(:service_rate, utilization_rate: nil)).not_to be_valid
11
+ end
12
+ it 'is invalid without base rate' do
13
+ expect(build(:service_rate, base_rate: nil)).not_to be_valid
14
+ end
15
+
16
+ it 'is invalid without chargeable service' do
17
+ expect(build(:service_rate, chargeable_service_id: nil)).not_to be_valid
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require 'rails_helper'
2
+
3
+ module Mks
4
+ module Rate
5
+ RSpec.describe ServiceType, type: :model do
6
+ it 'has a valid factory' do
7
+ expect(create(:service_type)).to be_valid
8
+ end
9
+
10
+ it 'is invalid with no code' do
11
+ expect(build(:service_type, code: nil)).not_to be_valid
12
+ end
13
+
14
+ it 'is invalid with no name' do
15
+ expect(build(:service_type, name: nil)).not_to be_valid
16
+ end
17
+
18
+ it 'is invalid with duplicate code' do
19
+ st = create(:service_type)
20
+ expect(build(:service_type, code: st.code)).not_to be_valid
21
+ end
22
+
23
+ it 'is invalid with duplicate name' do
24
+ st = create(:service_type)
25
+ expect(build(:service_type, name: st.name)).not_to be_valid
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ require 'rails_helper'
2
+
3
+ module Mks
4
+ module Rate
5
+ RSpec.describe UnitOfCharge, type: :model do
6
+ it 'has valid factory' do
7
+ expect(build(:unit_of_charge)).to be_valid
8
+ end
9
+
10
+ it 'is invalid without name' do
11
+ expect(build(:unit_of_charge, name: nil)).not_to be_valid
12
+ end
13
+
14
+ it 'is invalid without unit variables' do
15
+ expect(build(:unit_of_charge, unit_variables: {})).not_to be_valid
16
+ end
17
+
18
+ it 'can not have same name' do
19
+ uoc = create(:unit_of_charge)
20
+ expect(build(:unit_of_charge, name: uoc.name)).not_to be_valid
21
+ end
22
+ end
23
+ end
24
+ end