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,3 @@
1
+ class ProfessionalBody < ActiveRecord::Base
2
+ default_scope { order(:order) }
3
+ end
@@ -0,0 +1,3 @@
1
+ class ProfessionalStanding < ActiveRecord::Base
2
+ default_scope { order(:order) }
3
+ end
@@ -0,0 +1,5 @@
1
+ class Qualification < ActiveRecord::Base
2
+ validates_presence_of :name
3
+
4
+ default_scope { order(:order) }
5
+ end
@@ -0,0 +1,15 @@
1
+ class TravelDistance
2
+ def self.all
3
+ {
4
+ '5 miles' => 5,
5
+ '10 miles' => 10,
6
+ '25 miles' => 25,
7
+ '50 miles' => 50,
8
+ '100 miles' => 100,
9
+ '150 miles' => 150,
10
+ '200 miles' => 200,
11
+ '250 miles' => 250,
12
+ 'UK wide' => 650
13
+ }
14
+ end
15
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ MAS::RadCore::Engine.routes.draw do
2
+ end
@@ -0,0 +1,11 @@
1
+ class CreateLookupFirms < ActiveRecord::Migration
2
+ def change
3
+ create_table :lookup_firms do |t|
4
+ t.integer :fca_number, null: false
5
+ t.string :registered_name, null: false, default: ''
6
+ t.index :fca_number, unique: true
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ class CreatePrincipals < ActiveRecord::Migration
2
+ def change
3
+ create_table :principals do |t|
4
+ with_options null: false do
5
+ t.integer :fca_number, length: 6
6
+ t.index :fca_number, unique: true
7
+
8
+ t.string :token, length: 32
9
+ t.index :token, unique: true
10
+
11
+ t.string :website_address
12
+ t.string :first_name
13
+ t.string :last_name
14
+ t.string :job_title
15
+ t.string :email_address
16
+ t.string :telephone_number
17
+ t.boolean :confirmed_disclaimer, default: false
18
+
19
+ t.timestamps
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ class AddLastSignInAtToPrincipal < ActiveRecord::Migration
2
+ def change
3
+ add_column :principals, :last_sign_in_at, :datetime
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class CreateLookupSubsidiaries < ActiveRecord::Migration
2
+ def change
3
+ create_table :lookup_subsidiaries do |t|
4
+ t.integer :fca_number, null: false, index: true
5
+ t.string :name, null: false, default: ''
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveLastSignInAtFromPrincipals < ActiveRecord::Migration
2
+ def change
3
+ remove_column :principals, :last_sign_in_at
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class CreateLookupAdvisers < ActiveRecord::Migration
2
+ def change
3
+ create_table :lookup_advisers do |t|
4
+ t.string :reference_number, null: false, unique: true, length: 8
5
+ t.string :name, null: false
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class CreateFirms < ActiveRecord::Migration
2
+ def change
3
+ create_table :firms do |t|
4
+ t.integer :fca_number, null: false
5
+ t.string :registered_name, null: false
6
+ t.string :email_address
7
+ t.string :telephone_number
8
+ t.index :fca_number, unique: true
9
+
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class AddAddressToFirm < ActiveRecord::Migration
2
+ def change
3
+ add_column :firms, :address_line_one, :string
4
+ add_column :firms, :address_line_two, :string
5
+ add_column :firms, :address_town, :string
6
+ add_column :firms, :address_county, :string
7
+ add_column :firms, :address_postcode, :string
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class CreateInPersonAdviceMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :in_person_advice_methods do |t|
4
+ t.string :name, null: false, unique: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :firms, :in_person_advice_methods do |t|
10
+ t.index %i(firm_id in_person_advice_method_id),
11
+ name: 'firms_in_person_advice_methods_index',
12
+ unique: true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateOtherAdviceMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :other_advice_methods do |t|
4
+ t.string :name, null: false, unique: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :firms, :other_advice_methods do |t|
10
+ t.index %i(firm_id other_advice_method_id),
11
+ name: 'firms_other_advice_methods_index',
12
+ unique: true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ class AddFreeInitialMeetingToFirm < ActiveRecord::Migration
2
+ def change
3
+ add_column :firms, :free_initial_meeting, :boolean
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class CreateInitialMeetingDurations < ActiveRecord::Migration
2
+ def change
3
+ create_table :initial_meeting_durations do |t|
4
+ t.string :name, null: false, unique: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ add_reference :firms, :initial_meeting_duration, index: true
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ class CreateInitialAdviceFeeStructures < ActiveRecord::Migration
2
+ def change
3
+ create_table :initial_advice_fee_structures do |t|
4
+ t.string :name, null: false, unique: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :firms, :initial_advice_fee_structures do |t|
10
+ t.index %i(firm_id initial_advice_fee_structure_id),
11
+ name: 'firms_initial_advice_fee_structures_index',
12
+ unique: true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateOngoingAdviceFeeStructures < ActiveRecord::Migration
2
+ def change
3
+ create_table :ongoing_advice_fee_structures do |t|
4
+ t.string :name, null: false, unique: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :firms, :ongoing_advice_fee_structures do |t|
10
+ t.index %i(firm_id ongoing_advice_fee_structure_id),
11
+ name: 'firms_ongoing_advice_fee_structures_index',
12
+ unique: true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateAllowedPaymentMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :allowed_payment_methods do |t|
4
+ t.string :name, null: false, unique: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :firms, :allowed_payment_methods do |t|
10
+ t.index %i(firm_id allowed_payment_method_id),
11
+ name: 'firms_allowed_payment_methods_index',
12
+ unique: true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ class AddMinimumFixedFeeToFirm < ActiveRecord::Migration
2
+ def change
3
+ add_column :firms, :minimum_fixed_fee, :integer
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ class CreateInvestmentSizes < ActiveRecord::Migration
2
+ def change
3
+ create_table :investment_sizes do |t|
4
+ t.string :name, null: false, unique: true
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :firms, :investment_sizes do |t|
10
+ t.index %i(firm_id investment_size_id),
11
+ name: 'firms_investment_sizes_index',
12
+ unique: true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ class CreateAdvisers < ActiveRecord::Migration
2
+ def change
3
+ create_table :advisers do |t|
4
+ t.string :reference_number, null: false, unique: true, length: 8
5
+ t.string :name, null: false
6
+ t.belongs_to :firm, null: false
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class AddBusinessIncomeBreakdownFieldsToFirm < ActiveRecord::Migration
2
+ def change
3
+ add_column :firms, :retirement_income_products_percent, :integer
4
+ add_column :firms, :pension_transfer_percent, :integer
5
+ add_column :firms, :long_term_care_percent, :integer
6
+ add_column :firms, :equity_release_percent, :integer
7
+ add_column :firms, :inheritance_tax_and_estate_planning_percent, :integer
8
+ add_column :firms, :wills_and_probate_percent, :integer
9
+ add_column :firms, :other_percent, :integer
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ class CreateQualifications < ActiveRecord::Migration
2
+ def change
3
+ create_table :qualifications do |t|
4
+ t.string :name, null: false
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :advisers, :qualifications do |t|
10
+ t.index %i(adviser_id qualification_id),
11
+ unique: true,
12
+ name: 'advisers_qualifications_index'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateAccreditations < ActiveRecord::Migration
2
+ def change
3
+ create_table :accreditations do |t|
4
+ t.string :name, null: false
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :advisers, :accreditations do |t|
10
+ t.index %i(adviser_id accreditation_id),
11
+ unique: true,
12
+ name: 'advisers_accreditations_index'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateProfessionalStandings < ActiveRecord::Migration
2
+ def change
3
+ create_table :professional_standings do |t|
4
+ t.string :name, null: false
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :advisers, :professional_standings do |t|
10
+ t.index %i(adviser_id professional_standing_id),
11
+ unique: true,
12
+ name: 'advisers_professional_standings_index'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateProfessionalBodies < ActiveRecord::Migration
2
+ def change
3
+ create_table :professional_bodies do |t|
4
+ t.string :name, null: false
5
+
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_join_table :advisers, :professional_bodies do |t|
10
+ t.index %i(adviser_id professional_body_id),
11
+ unique: true,
12
+ name: 'advisers_professional_bodies_index'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ class AddConfirmedDisclaimerToAdvisers < ActiveRecord::Migration
2
+ def change
3
+ add_column :advisers, :confirmed_disclaimer, :boolean, null: false
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class AddGeographicalFieldsToAdviser < ActiveRecord::Migration
2
+ def change
3
+ add_column :advisers, :postcode, :string, null: false, default: ''
4
+ add_column :advisers, :travel_distance, :integer, null: false, default: 0
5
+ add_column :advisers, :covers_whole_of_uk, :boolean, null: false, default: false
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class AddParentIdToFirms < ActiveRecord::Migration
2
+ def change
3
+ add_column :firms, :parent_id, :integer, index: true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveUniqueConstraintFromFirmsFcaNumber < ActiveRecord::Migration
2
+ def change
3
+ remove_index :firms, :fca_number
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ class AddOrderingOnReferenceData < ActiveRecord::Migration
2
+ REFERENCE_TABLES = [
3
+ :accreditations,
4
+ :allowed_payment_methods,
5
+ :in_person_advice_methods,
6
+ :initial_advice_fee_structures,
7
+ :initial_meeting_durations,
8
+ :investment_sizes,
9
+ :ongoing_advice_fee_structures,
10
+ :other_advice_methods,
11
+ :professional_bodies,
12
+ :professional_standings,
13
+ :qualifications
14
+ ]
15
+
16
+ def up
17
+ REFERENCE_TABLES.each do |table|
18
+ add_column table, :order, :integer, null: false, default: 0
19
+
20
+ table.to_s.classify.constantize.unscoped.order(:id).each do |m|
21
+ m.update_attribute(:order, m.id)
22
+ end
23
+ end
24
+ end
25
+
26
+ def down
27
+ REFERENCE_TABLES.each do |table|
28
+ remove_column table, :order
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ class RemoveCoversWholeOfUkFromAdvisers < ActiveRecord::Migration
2
+ WHOLE_OF_UK_MILES = 650
3
+
4
+ def up
5
+ Adviser.where(covers_whole_of_uk: true).find_each do |adviser|
6
+ adviser.postcode = adviser.firm.address_postcode
7
+ adviser.travel_distance = WHOLE_OF_UK_MILES
8
+ adviser.save!
9
+ end
10
+
11
+ remove_column :advisers, :covers_whole_of_uk
12
+ end
13
+
14
+ def down
15
+ raise ActiveRecord::IrreversibleMigration
16
+ end
17
+ end