mas-rad_core 0.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 (126) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +3 -0
  4. data/Rakefile +14 -0
  5. data/app/models/accreditation.rb +5 -0
  6. data/app/models/adviser.rb +61 -0
  7. data/app/models/allowed_payment_method.rb +7 -0
  8. data/app/models/authentication.rb +19 -0
  9. data/app/models/firm.rb +143 -0
  10. data/app/models/in_person_advice_method.rb +7 -0
  11. data/app/models/initial_advice_fee_structure.rb +7 -0
  12. data/app/models/initial_meeting_duration.rb +7 -0
  13. data/app/models/investment_size.rb +7 -0
  14. data/app/models/lookup/adviser.rb +10 -0
  15. data/app/models/lookup/firm.rb +17 -0
  16. data/app/models/lookup/subsidiary.rb +11 -0
  17. data/app/models/ongoing_advice_fee_structure.rb +7 -0
  18. data/app/models/other_advice_method.rb +7 -0
  19. data/app/models/principal.rb +94 -0
  20. data/app/models/professional_body.rb +3 -0
  21. data/app/models/professional_standing.rb +3 -0
  22. data/app/models/qualification.rb +5 -0
  23. data/app/models/travel_distance.rb +15 -0
  24. data/config/routes.rb +2 -0
  25. data/db/migrate/20141211110031_create_lookup_firms.rb +11 -0
  26. data/db/migrate/20141221140208_create_principals.rb +23 -0
  27. data/db/migrate/20141222150416_add_last_sign_in_at_to_principal.rb +5 -0
  28. data/db/migrate/20141230112136_create_lookup_subsidiaries.rb +10 -0
  29. data/db/migrate/20150106115732_remove_last_sign_in_at_from_principals.rb +5 -0
  30. data/db/migrate/20150114144343_create_lookup_advisers.rb +10 -0
  31. data/db/migrate/20150114151447_create_firms.rb +13 -0
  32. data/db/migrate/20150115130949_add_address_to_firm.rb +9 -0
  33. data/db/migrate/20150119102735_create_in_person_advice_methods.rb +15 -0
  34. data/db/migrate/20150119111754_create_other_advice_methods.rb +15 -0
  35. data/db/migrate/20150119114218_add_free_initial_meeting_to_firm.rb +5 -0
  36. data/db/migrate/20150119125208_create_initial_meeting_durations.rb +11 -0
  37. data/db/migrate/20150119152325_create_initial_advice_fee_structures.rb +15 -0
  38. data/db/migrate/20150119152336_create_ongoing_advice_fee_structures.rb +15 -0
  39. data/db/migrate/20150120133717_create_allowed_payment_methods.rb +15 -0
  40. data/db/migrate/20150120141928_add_minimum_fixed_fee_to_firm.rb +5 -0
  41. data/db/migrate/20150120150738_create_investment_sizes.rb +15 -0
  42. data/db/migrate/20150121110757_create_advisers.rb +11 -0
  43. data/db/migrate/20150121123437_add_business_income_breakdown_fields_to_firm.rb +11 -0
  44. data/db/migrate/20150121134845_create_qualifications.rb +15 -0
  45. data/db/migrate/20150121154458_create_accreditations.rb +15 -0
  46. data/db/migrate/20150121173015_create_professional_standings.rb +15 -0
  47. data/db/migrate/20150121181341_create_professional_bodies.rb +15 -0
  48. data/db/migrate/20150121183728_add_confirmed_disclaimer_to_advisers.rb +5 -0
  49. data/db/migrate/20150124124350_add_geographical_fields_to_adviser.rb +7 -0
  50. data/db/migrate/20150125145457_add_parent_id_to_firms.rb +5 -0
  51. data/db/migrate/20150125164156_remove_unique_constraint_from_firms_fca_number.rb +5 -0
  52. data/db/migrate/20150127084858_add_ordering_on_reference_data.rb +31 -0
  53. data/db/migrate/20150209144836_remove_covers_whole_of_uk_from_advisers.rb +17 -0
  54. data/lib/mas/rad_core.rb +4 -0
  55. data/lib/mas/rad_core/engine.rb +21 -0
  56. data/lib/mas/rad_core/version.rb +5 -0
  57. data/lib/mas/stats.rb +19 -0
  58. data/lib/mas/tasks/rad_core_tasks.rake +4 -0
  59. data/spec/dummy/Rakefile +6 -0
  60. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  61. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  62. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  63. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  64. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  65. data/spec/dummy/bin/bundle +3 -0
  66. data/spec/dummy/bin/rails +4 -0
  67. data/spec/dummy/bin/rake +4 -0
  68. data/spec/dummy/bin/setup +29 -0
  69. data/spec/dummy/config.ru +4 -0
  70. data/spec/dummy/config/application.rb +26 -0
  71. data/spec/dummy/config/boot.rb +5 -0
  72. data/spec/dummy/config/database.example.yml +14 -0
  73. data/spec/dummy/config/database.yml +13 -0
  74. data/spec/dummy/config/environment.rb +5 -0
  75. data/spec/dummy/config/environments/development.rb +41 -0
  76. data/spec/dummy/config/environments/production.rb +79 -0
  77. data/spec/dummy/config/environments/test.rb +42 -0
  78. data/spec/dummy/config/initializers/assets.rb +11 -0
  79. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  80. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  81. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  82. data/spec/dummy/config/initializers/inflections.rb +16 -0
  83. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  84. data/spec/dummy/config/initializers/session_store.rb +3 -0
  85. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  86. data/spec/dummy/config/locales/en.yml +23 -0
  87. data/spec/dummy/config/routes.rb +3 -0
  88. data/spec/dummy/config/secrets.yml +22 -0
  89. data/spec/dummy/db/schema.rb +246 -0
  90. data/spec/dummy/log/test.log +13097 -0
  91. data/spec/dummy/public/404.html +67 -0
  92. data/spec/dummy/public/422.html +67 -0
  93. data/spec/dummy/public/500.html +66 -0
  94. data/spec/dummy/public/favicon.ico +0 -0
  95. data/spec/factories/accreditation.rb +5 -0
  96. data/spec/factories/adviser.rb +21 -0
  97. data/spec/factories/allowed_payment_method.rb +5 -0
  98. data/spec/factories/firm.rb +34 -0
  99. data/spec/factories/in_person_advice_method.rb +5 -0
  100. data/spec/factories/initial_advice_fee_structure.rb +5 -0
  101. data/spec/factories/initial_meeting_duration.rb +5 -0
  102. data/spec/factories/investment_size.rb +5 -0
  103. data/spec/factories/lookup_firm.rb +6 -0
  104. data/spec/factories/ongoing_advice_fee_structure.rb +5 -0
  105. data/spec/factories/other_advice_method.rb +5 -0
  106. data/spec/factories/principal.rb +15 -0
  107. data/spec/factories/professional_body.rb +5 -0
  108. data/spec/factories/professional_standing.rb +5 -0
  109. data/spec/factories/qualification.rb +5 -0
  110. data/spec/models/accreditation_spec.rb +3 -0
  111. data/spec/models/adviser_spec.rb +93 -0
  112. data/spec/models/allowed_payment_method_spec.rb +3 -0
  113. data/spec/models/firm_spec.rb +188 -0
  114. data/spec/models/in_person_advice_method_spec.rb +3 -0
  115. data/spec/models/initial_advice_fee_structure_spec.rb +3 -0
  116. data/spec/models/initial_meeting_duration_spec.rb +3 -0
  117. data/spec/models/investment_size_spec.rb +3 -0
  118. data/spec/models/lookup/adviser_spec.rb +21 -0
  119. data/spec/models/lookup/firm_spec.rb +19 -0
  120. data/spec/models/ongoing_advice_fee_structure_spec.rb +3 -0
  121. data/spec/models/other_advice_method_spec.rb +3 -0
  122. data/spec/models/principal_spec.rb +185 -0
  123. data/spec/models/qualification_spec.rb +3 -0
  124. data/spec/spec_helper.rb +24 -0
  125. data/spec/support/shared_examples/reference_data.rb +14 -0
  126. metadata +361 -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,5 @@
1
+ FactoryGirl.define do
2
+ factory :accreditation do
3
+ sequence(:name) { |n| "Accreditation #{n}" }
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ FactoryGirl.define do
2
+ sequence(:reference_number, 10000) { |n| "ABC#{n}" }
3
+
4
+ factory :adviser do
5
+ reference_number
6
+ name 'Ben Lovell'
7
+ postcode 'RG1 1NN'
8
+ travel_distance '50'
9
+ confirmed_disclaimer true
10
+ firm
11
+
12
+ after(:build) do |a|
13
+ if a.reference_number?
14
+ Lookup::Adviser.create!(
15
+ reference_number: a.reference_number,
16
+ name: a.name
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :allowed_payment_method do
3
+ name { Faker::Lorem.sentence }
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ FactoryGirl.define do
2
+ sequence(:registered_name) { |n| "Financial Advice #{n} Ltd." }
3
+
4
+ factory :firm do
5
+ fca_number
6
+ registered_name
7
+ email_address { Faker::Internet.email }
8
+ telephone_number { Faker::Base.numerify('##### ### ###') }
9
+ address_line_one { Faker::Address.street_address }
10
+ address_line_two { Faker::Address.secondary_address }
11
+ address_town { Faker::Address.city }
12
+ address_county { Faker::Address.state }
13
+ address_postcode 'EC1N 2TD'
14
+ in_person_advice_methods { create_list(:in_person_advice_method, rand(1..3)) }
15
+ other_advice_methods { create_list(:other_advice_method, rand(1..3)) }
16
+ free_initial_meeting { [true, false].sample }
17
+ initial_meeting_duration { create(:initial_meeting_duration) }
18
+ initial_advice_fee_structures { create_list(:initial_advice_fee_structure, rand(1..3)) }
19
+ ongoing_advice_fee_structures { create_list(:ongoing_advice_fee_structure, rand(1..3)) }
20
+ allowed_payment_methods { create_list(:allowed_payment_method, rand(1..3)) }
21
+ investment_sizes { create_list(:investment_size, rand(5..10)) }
22
+ retirement_income_products_percent 15
23
+ pension_transfer_percent 15
24
+ long_term_care_percent 15
25
+ equity_release_percent 15
26
+ inheritance_tax_and_estate_planning_percent 15
27
+ wills_and_probate_percent 15
28
+ other_percent 10
29
+
30
+ factory :subsidiary do
31
+ parent factory: Firm
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :in_person_advice_method do
3
+ name { Faker::Lorem.sentence }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :initial_advice_fee_structure do
3
+ name { Faker::Lorem.sentence }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :initial_meeting_duration do
3
+ sequence(:name) { |n| (n * 15).to_s + ' mins' }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :investment_size do
3
+ name { Faker::Lorem.sentence }
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :lookup_firm, class: Lookup::Firm do
3
+ fca_number
4
+ registered_name { Faker::Company.name }
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :ongoing_advice_fee_structure do
3
+ name { Faker::Lorem.sentence }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :other_advice_method do
3
+ name { Faker::Lorem.sentence }
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ FactoryGirl.define do
2
+ sequence(:fca_number, 100000) { |n| n }
3
+
4
+ factory :principal do
5
+ fca_number
6
+ first_name { Faker::Name.first_name }
7
+ last_name { Faker::Name.last_name }
8
+ email_address { Faker::Internet.email(first_name) }
9
+ job_title { Faker::Name.title }
10
+ telephone_number { Faker::Base.numerify('##### ### ###') }
11
+ confirmed_disclaimer true
12
+
13
+ after(:build) { |p| create(:lookup_firm, fca_number: p.fca_number) }
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :professional_body do
3
+ sequence(:name) { |n| "Professional Body #{n}" }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :professional_standing do
3
+ sequence(:name) { |n| "Professional Standing #{n}" }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :qualification do
3
+ sequence(:name) { |n| "Qualification #{n}" }
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.describe Accreditation do
2
+ it_behaves_like 'reference data'
3
+ end
@@ -0,0 +1,93 @@
1
+ RSpec.describe Adviser do
2
+ describe 'before validation' do
3
+ context 'when a reference number is present' do
4
+ let(:attributes) { attributes_for(:adviser) }
5
+ let(:adviser) { Adviser.new(attributes) }
6
+
7
+ before do
8
+ Lookup::Adviser.create!(
9
+ reference_number: attributes[:reference_number],
10
+ name: 'Mr. Welp'
11
+ )
12
+ end
13
+
14
+ it 'assigns #name from the lookup Adviser data' do
15
+ adviser.validate
16
+
17
+ expect(adviser.name).to eq('Mr. Welp')
18
+ end
19
+ end
20
+ end
21
+
22
+ describe 'validation' do
23
+ it 'is valid with valid attributes' do
24
+ expect(build(:adviser)).to be_valid
25
+ end
26
+
27
+ it 'orders fields correctly for dough' do
28
+ expect(build(:adviser).field_order).not_to be_empty
29
+ end
30
+
31
+ describe 'geographical coverage' do
32
+ describe 'travel distance' do
33
+ it 'must be provided' do
34
+ expect(build(:adviser, travel_distance: nil)).to_not be_valid
35
+ end
36
+
37
+ it 'must be within the allowed options' do
38
+ expect(build(:adviser, travel_distance: 999)).to_not be_valid
39
+ end
40
+ end
41
+
42
+ describe 'postcode' do
43
+ it 'must be provided' do
44
+ expect(build(:adviser, postcode: nil)).to_not be_valid
45
+ end
46
+
47
+ it 'must be a valid format' do
48
+ expect(build(:adviser, postcode: '098abc')).to_not be_valid
49
+ end
50
+ end
51
+ end
52
+
53
+ describe 'statement of truth' do
54
+ it 'must be confirmed' do
55
+ expect(build(:adviser, confirmed_disclaimer: false)).to_not be_valid
56
+ end
57
+ end
58
+
59
+ describe 'reference number' do
60
+ it 'is required' do
61
+ expect(build(:adviser, reference_number: nil)).to_not be_valid
62
+ end
63
+
64
+ it 'must be three characters and five digits exactly' do
65
+ %w(badtimes ABCDEFGH 8008135! 12345678).each do |bad|
66
+ Lookup::Adviser.create!(reference_number: bad, name: 'Mr. Derp')
67
+
68
+ expect(build(:adviser, reference_number: bad)).to_not be_valid
69
+ end
70
+ end
71
+
72
+ it 'must be matched to the lookup data' do
73
+ build(:adviser, reference_number: 'ABC12345').tap do |a|
74
+ Lookup::Adviser.delete_all
75
+
76
+ expect(a).to_not be_valid
77
+ end
78
+ end
79
+
80
+ context 'when an adviser with the same reference number already exists' do
81
+ let(:reference_number) { 'ABC12345' }
82
+
83
+ before do
84
+ create(:adviser, reference_number: reference_number)
85
+ end
86
+
87
+ it 'must not be valid' do
88
+ expect(build(:adviser, reference_number: reference_number)).to_not be_valid
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end