mno-enterprise-core 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -0
  3. data/Rakefile +12 -0
  4. data/app/assets/images/mno_enterprise/main-logo.png +0 -0
  5. data/app/controllers/mno_enterprise/application_controller.rb +116 -0
  6. data/app/helpers/mno_enterprise/application_helper.rb +67 -0
  7. data/app/helpers/mno_enterprise/impersonate_helper.rb +27 -0
  8. data/app/models/mno_enterprise/ability.rb +6 -0
  9. data/app/models/mno_enterprise/app.rb +72 -0
  10. data/app/models/mno_enterprise/app_instance.rb +36 -0
  11. data/app/models/mno_enterprise/app_instances_sync.rb +6 -0
  12. data/app/models/mno_enterprise/arrears_situation.rb +6 -0
  13. data/app/models/mno_enterprise/audit_event.rb +21 -0
  14. data/app/models/mno_enterprise/base_resource.rb +228 -0
  15. data/app/models/mno_enterprise/credit_card.rb +40 -0
  16. data/app/models/mno_enterprise/deletion_request.rb +35 -0
  17. data/app/models/mno_enterprise/impac/dashboard.rb +36 -0
  18. data/app/models/mno_enterprise/impac/dashboard_provisioner.rb +5 -0
  19. data/app/models/mno_enterprise/impac/kpi.rb +9 -0
  20. data/app/models/mno_enterprise/impac/widget.rb +13 -0
  21. data/app/models/mno_enterprise/invoice.rb +53 -0
  22. data/app/models/mno_enterprise/org_invite.rb +50 -0
  23. data/app/models/mno_enterprise/organization.rb +33 -0
  24. data/app/models/mno_enterprise/team.rb +50 -0
  25. data/app/models/mno_enterprise/tenant.rb +5 -0
  26. data/app/models/mno_enterprise/tenant_invoice.rb +5 -0
  27. data/app/models/mno_enterprise/user.rb +183 -0
  28. data/app/pdf/mno_enterprise/invoice_pdf.rb +516 -0
  29. data/config/initializers/audit_log.rb +5 -0
  30. data/config/locales/devise.en.yml +60 -0
  31. data/config/routes.rb +2 -0
  32. data/config/styleguide.yml +106 -0
  33. data/lib/accountingjs_serializer.rb +51 -0
  34. data/lib/devise/controllers/extension_helpers.rb +52 -0
  35. data/lib/devise/extension_routes.rb +11 -0
  36. data/lib/devise/hooks/password_expirable.rb +5 -0
  37. data/lib/devise/models/password_expirable.rb +28 -0
  38. data/lib/devise/models/remote_authenticatable.rb +48 -0
  39. data/lib/devise/strategies/remote_authenticatable.rb +44 -0
  40. data/lib/devise_extension.rb +36 -0
  41. data/lib/faraday/adapter/net_http_no_proxy.rb +19 -0
  42. data/lib/generators/mno_enterprise/database_extension/USAGE +11 -0
  43. data/lib/generators/mno_enterprise/database_extension/database_extension_generator.rb +36 -0
  44. data/lib/generators/mno_enterprise/database_extension/templates/model.rb +9 -0
  45. data/lib/generators/mno_enterprise/dummy/dummy_generator.rb +98 -0
  46. data/lib/generators/mno_enterprise/dummy/templates/rails/application.rb.erb +9 -0
  47. data/lib/generators/mno_enterprise/dummy/templates/rails/boot.rb.erb +6 -0
  48. data/lib/generators/mno_enterprise/dummy/templates/rails/database.yml +22 -0
  49. data/lib/generators/mno_enterprise/dummy/templates/rails/routes.rb +8 -0
  50. data/lib/generators/mno_enterprise/dummy/templates/rails/test-env.rb +45 -0
  51. data/lib/generators/mno_enterprise/install/install_generator.rb +140 -0
  52. data/lib/generators/mno_enterprise/install/templates/Procfile +1 -0
  53. data/lib/generators/mno_enterprise/install/templates/config/initializers/mno_enterprise.rb +135 -0
  54. data/lib/generators/mno_enterprise/install/templates/config/mno_enterprise_styleguide.yml +104 -0
  55. data/lib/generators/mno_enterprise/install/templates/javascripts/mno_enterprise_extensions.js +7 -0
  56. data/lib/generators/mno_enterprise/install/templates/stylesheets/main.less_erb +25 -0
  57. data/lib/generators/mno_enterprise/install/templates/stylesheets/theme.less_erb +59 -0
  58. data/lib/generators/mno_enterprise/install/templates/stylesheets/variables.less +337 -0
  59. data/lib/generators/mno_enterprise/install/templates/tasks/sprites.rake +14 -0
  60. data/lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb +58 -0
  61. data/lib/generators/mno_enterprise/templates/scripts/monit/app-server.conf +8 -0
  62. data/lib/generators/mno_enterprise/templates/scripts/nginx/app +51 -0
  63. data/lib/generators/mno_enterprise/templates/scripts/puma.rb +25 -0
  64. data/lib/generators/mno_enterprise/templates/scripts/setup.sh +27 -0
  65. data/lib/generators/mno_enterprise/templates/scripts/upstart/app-web-hotrestart.conf +26 -0
  66. data/lib/generators/mno_enterprise/templates/scripts/upstart/app-web-server.conf +34 -0
  67. data/lib/generators/mno_enterprise/templates/scripts/upstart/app-web.conf +2 -0
  68. data/lib/generators/mno_enterprise/templates/scripts/upstart/app.conf +11 -0
  69. data/lib/her_extension/her_orm_adapter.rb +54 -0
  70. data/lib/her_extension/middleware/mnoe_api_v1_parse_json.rb +54 -0
  71. data/lib/her_extension/model/associations/association.rb +61 -0
  72. data/lib/her_extension/model/associations/association_proxy.rb +34 -0
  73. data/lib/her_extension/model/associations/has_many_association.rb +115 -0
  74. data/lib/her_extension/model/attributes.rb +43 -0
  75. data/lib/her_extension/model/orm.rb +59 -0
  76. data/lib/her_extension/model/parse.rb +40 -0
  77. data/lib/her_extension/model/relation.rb +92 -0
  78. data/lib/her_extension/validations/remote_uniqueness_validation.rb +33 -0
  79. data/lib/html_processor.rb +106 -0
  80. data/lib/mandrill_client.rb +58 -0
  81. data/lib/mno-enterprise-core.rb +1 -0
  82. data/lib/mno_enterprise/concerns.rb +4 -0
  83. data/lib/mno_enterprise/concerns/controllers.rb +6 -0
  84. data/lib/mno_enterprise/concerns/controllers/angular_csrf.rb +59 -0
  85. data/lib/mno_enterprise/concerns/controllers/auth.rb +9 -0
  86. data/lib/mno_enterprise/concerns/controllers/auth/confirmations_controller.rb +187 -0
  87. data/lib/mno_enterprise/concerns/controllers/auth/passwords_controller.rb +54 -0
  88. data/lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb +136 -0
  89. data/lib/mno_enterprise/concerns/controllers/auth/sessions_controller.rb +54 -0
  90. data/lib/mno_enterprise/concerns/controllers/auth/unlocks_controller.rb +50 -0
  91. data/lib/mno_enterprise/concerns/models.rb +6 -0
  92. data/lib/mno_enterprise/concerns/models/ability.rb +108 -0
  93. data/lib/mno_enterprise/concerns/models/app_instance.rb +100 -0
  94. data/lib/mno_enterprise/concerns/models/organization.rb +102 -0
  95. data/lib/mno_enterprise/core.rb +279 -0
  96. data/lib/mno_enterprise/database_extendable.rb +57 -0
  97. data/lib/mno_enterprise/engine.rb +33 -0
  98. data/lib/mno_enterprise/testing_support/ability_test_helper.rb +10 -0
  99. data/lib/mno_enterprise/testing_support/common_rake.rb +19 -0
  100. data/lib/mno_enterprise/testing_support/factories.rb +13 -0
  101. data/lib/mno_enterprise/testing_support/factories/app_instances.rb +30 -0
  102. data/lib/mno_enterprise/testing_support/factories/apps.rb +45 -0
  103. data/lib/mno_enterprise/testing_support/factories/arrears_situation.rb +14 -0
  104. data/lib/mno_enterprise/testing_support/factories/audit_event.rb +15 -0
  105. data/lib/mno_enterprise/testing_support/factories/credit_card.rb +33 -0
  106. data/lib/mno_enterprise/testing_support/factories/deletion_request.rb +17 -0
  107. data/lib/mno_enterprise/testing_support/factories/impac/dashboards.rb +15 -0
  108. data/lib/mno_enterprise/testing_support/factories/impac/kpis.rb +20 -0
  109. data/lib/mno_enterprise/testing_support/factories/impac/widgets.rb +15 -0
  110. data/lib/mno_enterprise/testing_support/factories/invoices.rb +51 -0
  111. data/lib/mno_enterprise/testing_support/factories/org_invite.rb +24 -0
  112. data/lib/mno_enterprise/testing_support/factories/organizations.rb +25 -0
  113. data/lib/mno_enterprise/testing_support/factories/team.rb +17 -0
  114. data/lib/mno_enterprise/testing_support/factories/tenant.rb +12 -0
  115. data/lib/mno_enterprise/testing_support/factories/tenant_invoice.rb +29 -0
  116. data/lib/mno_enterprise/testing_support/factories/users.rb +48 -0
  117. data/lib/mno_enterprise/testing_support/jpi_v1_test_helper.rb +49 -0
  118. data/lib/mno_enterprise/testing_support/mno_enterprise_api_test_helper.rb +167 -0
  119. data/lib/mno_enterprise/testing_support/mnoe_faraday_test_adapter.rb +173 -0
  120. data/lib/mno_enterprise/testing_support/organizations_shared_helpers.rb +175 -0
  121. data/lib/mno_enterprise/testing_support/user_action_shared.rb +47 -0
  122. data/lib/mno_enterprise/version.rb +3 -0
  123. data/lib/tasks/mno_enterprise_tasks.rake +22 -0
  124. data/spec/controllers/mno_enterprise/angular_csrf_spec.rb +42 -0
  125. data/spec/lib/her_extension/her_orm_adapter.rb +7 -0
  126. data/spec/lib/her_extension/model/relation_spec.rb +7 -0
  127. data/spec/lib/mandrill_client_spec.rb +64 -0
  128. data/spec/mno_enterprise_spec.rb +79 -0
  129. data/spec/models/mno_enterprise/app_instance_spec.rb +7 -0
  130. data/spec/models/mno_enterprise/app_spec.rb +62 -0
  131. data/spec/models/mno_enterprise/base_resource_spec.rb +28 -0
  132. data/spec/models/mno_enterprise/deletion_request_spec.rb +26 -0
  133. data/spec/models/mno_enterprise/invoice_spec.rb +7 -0
  134. data/spec/models/mno_enterprise/organization_spec.rb +7 -0
  135. data/spec/models/mno_enterprise/user_spec.rb +44 -0
  136. data/spec/rails_helper.rb +73 -0
  137. data/spec/spec_helper.rb +78 -0
  138. metadata +421 -0
@@ -0,0 +1,57 @@
1
+ require 'active_support/concern'
2
+ require 'active_support/core_ext'
3
+
4
+ # TODO: specs
5
+ module MnoEnterprise::DatabaseExtendable
6
+ extend ActiveSupport::Concern
7
+
8
+ class_methods do
9
+ def database_extendable(*fields)
10
+ fields.each do |field|
11
+ delegate field.to_sym, "#{field}=".to_sym, to: :extension
12
+ end
13
+
14
+ after_save :save_extensions
15
+ after_destroy :delete_extension
16
+
17
+ include MnoEnterprise::DatabaseExtendable::InstanceMethods
18
+ end
19
+ end
20
+
21
+ module InstanceMethods
22
+ def extension
23
+ @extension ||= klass.where(foreign_key => self.uid).first_or_initialize
24
+ end
25
+
26
+ def extension=(extension)
27
+ @extension = extension
28
+ end
29
+
30
+ def klass
31
+ "#{self.class}Extension".constantize
32
+ end
33
+
34
+ def foreign_key
35
+ self.class.to_s.foreign_key.gsub(/_id/, '_uid')
36
+ end
37
+
38
+ protected
39
+ def save_extensions
40
+ # Set extension foreign key
41
+ if extension.send(foreign_key).blank?
42
+ extension.send("#{foreign_key}=", self.uid)
43
+ end
44
+ # Save at all time to 'touch' to expire the cache
45
+ if extension.changed?
46
+ extension.save
47
+ else
48
+ extension.touch
49
+ end
50
+ end
51
+
52
+ def delete_extension
53
+ extension.destroy
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,33 @@
1
+ module MnoEnterprise
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace MnoEnterprise
4
+
5
+ # Autoload all files and sub-directories in
6
+ # lib
7
+ config.autoload_paths += Dir["#{config.root}/lib/**/"]
8
+
9
+ # Remove testing support when not in test
10
+ unless Rails.env.test?
11
+ path_rejector = lambda { |s| s.include?('/testing_support/') }
12
+ config.autoload_paths.reject!(&path_rejector)
13
+ end
14
+
15
+ config.generators do |g|
16
+ g.test_framework :rspec, fixture: true
17
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
18
+ end
19
+
20
+ # Allow class overriding using decorator pattern
21
+ # See: http://edgeguides.rubyonrails.org/engines.html#overriding-models-and-controllers
22
+ config.to_prepare do
23
+ Dir.glob(Rails.root + "app/decorators/**/*_decorator*.rb").each do |c|
24
+ require_dependency(c)
25
+ end
26
+ end
27
+
28
+ # Add responding to JSON to Devise
29
+ config.to_prepare do
30
+ DeviseController.respond_to :html, :json
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ module AbilityTestHelper
2
+
3
+ def stub_ability
4
+ ability = Object.new
5
+ ability.extend(::CanCan::Ability)
6
+ allow(controller).to receive(:current_ability).and_return(ability)
7
+ ability
8
+ end
9
+
10
+ end
@@ -0,0 +1,19 @@
1
+ unless defined?(MnoEnterprise::Generators::InstallGenerator)
2
+ require 'generators/mno_enterprise/install/install_generator'
3
+ end
4
+
5
+ require 'generators/mno_enterprise/dummy/dummy_generator'
6
+
7
+ namespace :mno_enterprise do
8
+ namespace :testing do
9
+ desc "Generate a dummy app for testing"
10
+ task :create_dummy_app do
11
+ require "#{ENV['LIB_NAME']}"
12
+
13
+ ENV["RAILS_ENV"] = 'test'
14
+
15
+ MnoEnterprise::DummyGenerator.start %W[--quiet --lib_name=#{ENV['LIB_NAME']} --database=#{ENV['DB'].presence || 'sqlite3'}]
16
+ MnoEnterprise::Generators::InstallGenerator.start %w[--quiet --skip-rspec --skip-sprite --skip-factory-girl]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ require 'factory_girl'
2
+
3
+ Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each do |f|
4
+ load File.expand_path(f)
5
+ end
6
+
7
+ # FactoryGirl.define do
8
+ # sequence(:random_string) { FFaker::Lorem.sentence }
9
+ # sequence(:random_description) { FFaker::Lorem.paragraphs(1 + Kernel.rand(5)).join("\n") }
10
+ # sequence(:random_email) { FFaker::Internet.email }
11
+
12
+ # sequence(:sku) { |n| "SKU-#{n}" }
13
+ # end
@@ -0,0 +1,30 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mno_enterprise_app_instance, :class => 'AppInstance' do
5
+
6
+ factory :app_instance, class: MnoEnterprise::AppInstance do
7
+ sequence(:id)
8
+ sequence(:uid) { |n| "bla#{1}.mcube.co" }
9
+ name "SomeApp"
10
+ status "running"
11
+ created_at 3.days.ago
12
+ updated_at 1.hour.ago
13
+ started_at 3.days.ago
14
+ stack "cube"
15
+ terminated_at nil
16
+ stopped_at nil
17
+ billing_type "hourly"
18
+ autostop_at nil
19
+ autostop_interval nil
20
+ next_status nil
21
+ soa_enabled true
22
+
23
+ app { build(:app).attributes }
24
+ owner { build(:organization).attributes }
25
+
26
+ # Properly build the resource with Her
27
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :app, class: MnoEnterprise::App do
5
+ sequence(:id) { |n| n }
6
+ sequence(:name) { |n| "TestApp#{n}" }
7
+ nid { name.parameterize }
8
+
9
+ description "This is a description"
10
+ created_at 1.day.ago
11
+ updated_at 2.hours.ago
12
+ logo "https://cdn.somedomain.com/app/2f4g2r474.jpg"
13
+ website "https://www.testapp.com"
14
+ slug { "#{id}-myapp" }
15
+ categories ["CRM"]
16
+ tags ['Foo', 'Bar']
17
+ key_benefits ['Super','Hyper','Good']
18
+ key_features ['Super','Hyper','Good']
19
+ testimonials [{text:'Bla', company:'Doe Pty Ltd', author: 'John'}]
20
+ worldwide_usage 120000
21
+ tiny_description "A great app"
22
+ stack 'cube'
23
+ terms_url "http://opensource.org/licenses/MIT"
24
+ appinfo { {} }
25
+
26
+ pricing_plans {{
27
+ 'default' =>[{name: 'Monthly Plan', price: '20.0', currency: 'AUD', factor: '/month'}]
28
+ }}
29
+
30
+ trait :cloud do
31
+ stack 'cloud'
32
+ end
33
+
34
+ trait :connector do
35
+ stack 'connector'
36
+ end
37
+
38
+ factory :cloud_app, traits: [:cloud]
39
+ factory :connector_app, traits: [:connector]
40
+
41
+ # Properly build the resource with Her
42
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
43
+ end
44
+
45
+ end
@@ -0,0 +1,14 @@
1
+ FactoryGirl.define do
2
+ factory :mno_enterprise_arrears_situation, :class => 'MnoEnterprise::ArrearsSituation' do
3
+
4
+ factory :arrears_situation, class: MnoEnterprise::ArrearsSituation do
5
+ sequence(:name) { |n| "Team#{n}" }
6
+ payment Money.new(5680,'AUD')
7
+ category 'payment_failed'
8
+ status 'pending'
9
+
10
+ # Properly build the resource with Her
11
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ FactoryGirl.define do
2
+ factory :mno_enterprise_audit_event, :class => 'AuditEvent' do
3
+
4
+ factory :audit_event, class: MnoEnterprise::AuditEvent do
5
+ sequence(:key) { |n| "event-fab3#{n}" }
6
+ user_id 1
7
+ description 'Blabla'
8
+ details 'Details'
9
+ user { {name: 'John', surname: 'Doe'} }
10
+
11
+ # Properly build the resource with Her
12
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,33 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mno_enterprise_credit_card, :class => 'CreditCard' do
5
+
6
+
7
+ factory :credit_card, class: MnoEnterprise::CreditCard do
8
+ sequence(:id)
9
+ organization_id 265
10
+ created_at 3.days.ago
11
+ updated_at 1.hour.ago
12
+
13
+ title 'Mr.'
14
+ first_name 'John'
15
+ last_name 'Doe'
16
+ country 'AU'
17
+ masked_number 'XXXX-XXXX-XXXX-4242'
18
+ number nil
19
+ month 3
20
+ year 2025
21
+ billing_address '102 Somewhere Street'
22
+ billing_city 'Sydney'
23
+ billing_postcode '2010'
24
+ billing_country 'AU'
25
+ verification_value 'CVV'
26
+
27
+ # Properly build the resource with Her
28
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
29
+ end
30
+
31
+
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ # This is an API resource factory generating a Hash to be used in API stubs
4
+ # Use as such: build(:api_user)
5
+ # See http://stackoverflow.com/questions/10032760/how-to-define-an-array-hash-in-factory-girl
6
+ FactoryGirl.define do
7
+
8
+ factory :deletion_request, class: MnoEnterprise::DeletionRequest do
9
+ sequence(:id)
10
+ sequence(:token) { |n| "1dfg567fda44f87ds89F7DS8#{n}" }
11
+ status 'pending'
12
+
13
+ # Properly build the resource with Her
14
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
15
+ end
16
+
17
+ end
@@ -0,0 +1,15 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :mno_enterprise_impac_dashboard, :class => 'Impac::Dashboard' do
4
+ factory :impac_dashboard, class: MnoEnterprise::Impac::Dashboard do
5
+ sequence(:id) { |n| n }
6
+ sequence(:name) { |n| "Random Dashboard #{n}" }
7
+
8
+ # Problem with polymorphic association ?...
9
+ # owner { build(:user).attributes }
10
+
11
+ # Properly build the resource with Her
12
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :mno_enterprise_impac_kpi, :class => 'Impac::Kpi' do
4
+ factory :impac_kpi, class: MnoEnterprise::Impac::Kpi do
5
+
6
+ sequence(:id) { |n| n }
7
+ sequence(:name) { |n| "Random Kpi #{n}" }
8
+ dashboard { build(:impac_dashboard).attributes }
9
+ endpoint "an/endpoint"
10
+ element_watched "a_watchable"
11
+ source "impac"
12
+ targets {}
13
+ settings {}
14
+ extra_params {}
15
+
16
+ # Properly build the resource with Her
17
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :mno_enterprise_impac_widget, :class => 'Impac::Widget' do
4
+ factory :impac_widget, class: MnoEnterprise::Impac::Widget do
5
+ sequence(:id) { |n| n }
6
+ sequence(:name) { |n| "Random Widget #{n}" }
7
+ widget_category "widget_endpoint"
8
+ width 3
9
+ dashboard { build(:impac_dashboard).attributes }
10
+
11
+ # Properly build the resource with Her
12
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,51 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mno_enterprise_invoice, :class => 'Invoice' do
5
+
6
+
7
+ factory :invoice, class: MnoEnterprise::Invoice do
8
+ sequence(:id)
9
+ sequence(:slug) { |n| "201504-NU#{n}" }
10
+ organization_id 265
11
+
12
+ started_at 28.days.ago
13
+ ended_at 3.days.ago
14
+ created_at 3.days.ago
15
+ updated_at 1.hour.ago
16
+ paid_at nil
17
+
18
+ price Money.new(7980,'AUD')
19
+ billing_address "205 Bla Street, Sydney"
20
+ total_due Money.new(7980,'AUD')
21
+ total_payable Money.new(7980,'AUD')
22
+ total_due_remaining Money.new(7980,'AUD')
23
+ credit_paid Money.new(0,'AUD')
24
+
25
+ tax_payable Money.new(590,'AUD')
26
+ tax_due_remaining Money.new(590,'AUD')
27
+
28
+ previous_total_due Money.new(0,'AUD')
29
+ previous_total_paid Money.new(0,'AUD')
30
+
31
+ tax_pips_applied 5000
32
+
33
+ billing_summary [
34
+ {
35
+ "name"=>"vTiger 5.4",
36
+ "usage"=>"499h",
37
+ "label"=>"vTiger",
38
+ "price_tag"=>"$19.95",
39
+ "lines"=>[
40
+ {"label"=>"Application plan", "price_tag"=>"$19.95"}
41
+ ]
42
+ }
43
+ ]
44
+
45
+ # Properly build the resource with Her
46
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
47
+ end
48
+
49
+
50
+ end
51
+ end
@@ -0,0 +1,24 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mno_enterprise_org_invite, :class => 'MnoEnterprise::OrgInvite' do
5
+
6
+ factory :org_invite, class: MnoEnterprise::OrgInvite do
7
+ sequence(:id)
8
+ sequence(:token) { |n| "dfhsohflsklddfdsJDasldnjsaHsnjdlsa#{n}" }
9
+ sequence(:user_email) { |n| "jack.doe#{n}@maestrano.com" }
10
+ status "pending"
11
+ user { build(:user).attributes }
12
+ organization { build(:organization).attributes }
13
+ referrer { build(:user).attributes }
14
+ team { build(:team).attributes }
15
+ user_role 'Member'
16
+
17
+ created_at 3.days.ago
18
+ updated_at 1.hour.ago
19
+
20
+ # Properly build the resource with Her
21
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :mno_enterprise_organization, :class => 'Organization' do
5
+
6
+ factory :organization, class: MnoEnterprise::Organization do
7
+ sequence(:id)
8
+ sequence(:uid) { |n| "org-fab3#{n}" }
9
+ name "Doe Inc"
10
+ role "Admin"
11
+ created_at 3.days.ago
12
+ updated_at 1.hour.ago
13
+ in_arrears? false
14
+ billing_currency 'AUD'
15
+
16
+ trait :with_org_invites do
17
+ org_invites { [build(:org_invite).attributes] }
18
+ end
19
+
20
+ # Properly build the resource with Her
21
+ initialize_with { new(attributes).tap { |e| e.clear_attribute_changes! } }
22
+ end
23
+
24
+ end
25
+ end