susply 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 (95) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +8 -0
  4. data/Rakefile +30 -0
  5. data/app/assets/javascripts/susply/application.js +13 -0
  6. data/app/assets/stylesheets/susply/application.css +15 -0
  7. data/app/controllers/susply/application_controller.rb +4 -0
  8. data/app/helpers/susply/application_helper.rb +4 -0
  9. data/app/models/susply/payment.rb +19 -0
  10. data/app/models/susply/plan.rb +16 -0
  11. data/app/models/susply/subscription.rb +23 -0
  12. data/app/services/susply/calculations.rb +15 -0
  13. data/app/services/susply/cancel_subscription.rb +11 -0
  14. data/app/services/susply/change_subscription.rb +14 -0
  15. data/app/services/susply/close_subscription.rb +10 -0
  16. data/app/services/susply/create_payment.rb +30 -0
  17. data/app/services/susply/create_subscription.rb +21 -0
  18. data/app/services/susply/owner_methods.rb +28 -0
  19. data/app/services/susply/prorate.rb +22 -0
  20. data/app/services/susply/renews_subscription.rb +25 -0
  21. data/app/views/layouts/susply/application.html.erb +14 -0
  22. data/config/initializers/susply.rb +3 -0
  23. data/config/routes.rb +2 -0
  24. data/db/migrate/20150513155547_create_susply_plans.rb +14 -0
  25. data/db/migrate/20150513161513_add_status_to_plans.rb +6 -0
  26. data/db/migrate/20150513180124_create_susply_subscriptions.rb +17 -0
  27. data/db/migrate/20150521222634_create_susply_payments.rb +19 -0
  28. data/lib/generators/susply/install_generator.rb +20 -0
  29. data/lib/generators/templates/config/initializers/susply.rb +3 -0
  30. data/lib/susply/engine.rb +24 -0
  31. data/lib/susply/version.rb +3 -0
  32. data/lib/susply.rb +10 -0
  33. data/lib/tasks/susply_tasks.rake +4 -0
  34. data/spec/dummy/README.rdoc +28 -0
  35. data/spec/dummy/Rakefile +6 -0
  36. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  37. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  38. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  39. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  40. data/spec/dummy/app/models/organization.rb +5 -0
  41. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  42. data/spec/dummy/bin/bundle +3 -0
  43. data/spec/dummy/bin/rails +4 -0
  44. data/spec/dummy/bin/rake +4 -0
  45. data/spec/dummy/bin/setup +29 -0
  46. data/spec/dummy/config/application.rb +32 -0
  47. data/spec/dummy/config/boot.rb +5 -0
  48. data/spec/dummy/config/database.yml +25 -0
  49. data/spec/dummy/config/environment.rb +5 -0
  50. data/spec/dummy/config/environments/development.rb +41 -0
  51. data/spec/dummy/config/environments/production.rb +79 -0
  52. data/spec/dummy/config/environments/test.rb +42 -0
  53. data/spec/dummy/config/initializers/assets.rb +11 -0
  54. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  55. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  56. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  57. data/spec/dummy/config/initializers/inflections.rb +16 -0
  58. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  59. data/spec/dummy/config/initializers/session_store.rb +3 -0
  60. data/spec/dummy/config/initializers/susply.rb +3 -0
  61. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/spec/dummy/config/locales/en.yml +23 -0
  63. data/spec/dummy/config/routes.rb +4 -0
  64. data/spec/dummy/config/secrets.yml +22 -0
  65. data/spec/dummy/config.ru +4 -0
  66. data/spec/dummy/db/development.sqlite3 +0 -0
  67. data/spec/dummy/db/migrate/20150513183555_create_organizations.rb +11 -0
  68. data/spec/dummy/db/production.sqlite3 +0 -0
  69. data/spec/dummy/db/schema.rb +67 -0
  70. data/spec/dummy/db/test.sqlite3 +0 -0
  71. data/spec/dummy/log/development.log +950 -0
  72. data/spec/dummy/log/test.log +40824 -0
  73. data/spec/dummy/public/404.html +67 -0
  74. data/spec/dummy/public/422.html +67 -0
  75. data/spec/dummy/public/500.html +66 -0
  76. data/spec/dummy/public/favicon.ico +0 -0
  77. data/spec/dummy/spec/factories/organizations.rb +8 -0
  78. data/spec/dummy/spec/models/organization_spec.rb +4 -0
  79. data/spec/factories/susply_payments.rb +13 -0
  80. data/spec/factories/susply_plans.rb +15 -0
  81. data/spec/factories/susply_subscriptions.rb +19 -0
  82. data/spec/models/susply/payment_spec.rb +135 -0
  83. data/spec/models/susply/plan_spec.rb +106 -0
  84. data/spec/models/susply/subscription_spec.rb +102 -0
  85. data/spec/services/susply/calculations_spec.rb +29 -0
  86. data/spec/services/susply/cancel_subscription_spec.rb +20 -0
  87. data/spec/services/susply/change_subscription_spec.rb +68 -0
  88. data/spec/services/susply/close_subscription_spec.rb +36 -0
  89. data/spec/services/susply/create_payment_spec.rb +84 -0
  90. data/spec/services/susply/create_subscription_spec.rb +22 -0
  91. data/spec/services/susply/owner_methods_spec.rb +99 -0
  92. data/spec/services/susply/prorate_spec.rb +92 -0
  93. data/spec/services/susply/renews_subscription_spec.rb +98 -0
  94. data/spec/spec_helper.rb +19 -0
  95. metadata +282 -0
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ module Susply
4
+ describe ChangeSubscription do
5
+ let(:owner_class) { Susply.subscription_owner_class.constantize }
6
+ let(:time) {Time.zone.today}
7
+
8
+ context "when owner has an active subscription" do
9
+ it "closes the active subscription when present" do
10
+ owner = owner_class.create()
11
+ plan = create(:susply_plan)
12
+ subscription = create(:susply_subscription, :active, owner: owner)
13
+
14
+ new_subscription = Susply::ChangeSubscription.call(owner, plan)
15
+ subscription.reload
16
+
17
+ expect(subscription).not_to be_active
18
+ expect(new_subscription).to be_active
19
+ end
20
+
21
+ it "creates a plan_changed prorate payment" do
22
+ owner = owner_class.create()
23
+ plan = create(:susply_plan, interval: 'monthly', price: 100)
24
+ subscription = create(:susply_subscription, :active,owner: owner,
25
+ current_period_start: time - 15.days)
26
+
27
+ Susply::ChangeSubscription.call(owner, plan)
28
+
29
+ payment = owner.payments.last
30
+ expect(payment.generated_type).to eq 'plan_change'
31
+ end
32
+
33
+ it "creates a new subscription" do
34
+ owner = owner_class.create()
35
+ plan = create(:susply_plan)
36
+ subscription = create(:susply_subscription, :active, owner: owner)
37
+ new_subscription = Susply::ChangeSubscription.call(owner, plan)
38
+
39
+ expect(new_subscription.owner).to eq owner
40
+ expect(new_subscription.plan).to eq plan
41
+ expect(new_subscription).to be_active
42
+ expect(owner.subscriptions.count).to eq 2
43
+ end
44
+ end
45
+
46
+ context "when owner does not have active subscription" do
47
+ it "does not creates a payment" do
48
+ owner = owner_class.create()
49
+ plan = create(:susply_plan)
50
+
51
+ new_subscription = Susply::ChangeSubscription.call(owner, plan)
52
+
53
+ expect(owner.payments.count).to eq 0
54
+ end
55
+
56
+ it "creates a new subscription" do
57
+ owner = owner_class.create()
58
+ plan = create(:susply_plan)
59
+
60
+ new_subscription = Susply::ChangeSubscription.call(owner, plan)
61
+
62
+ expect(new_subscription.owner).to eq owner
63
+ expect(new_subscription.plan).to eq plan
64
+ expect(new_subscription).to be_active
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ module Susply
4
+ describe CloseSubscription do
5
+ let(:owner_class) { Susply.subscription_owner_class.constantize }
6
+ let(:time) {Time.zone.today}
7
+
8
+ context "when owner has an active subscription" do
9
+ it "closes the active subscription when present" do
10
+ owner = owner_class.create()
11
+ plan = create(:susply_plan)
12
+ subscription = create(:susply_subscription, :active, owner: owner)
13
+
14
+ expect(owner.has_active_subscription?).to be true
15
+ Susply::CloseSubscription.call(owner)
16
+ subscription.reload
17
+
18
+ expect(subscription).not_to be_active
19
+ expect(owner.has_active_subscription?).to be false
20
+ end
21
+
22
+ it "creates a plan_close prorate payment" do
23
+ owner = owner_class.create()
24
+ plan = create(:susply_plan, interval: 'monthly', price: 100)
25
+ subscription = create(:susply_subscription, :active,owner: owner,
26
+ current_period_start: time - 15.days)
27
+
28
+ Susply::CloseSubscription.call(owner)
29
+
30
+ payment = owner.payments.last
31
+ expect(payment.generated_type).to eq 'plan_close'
32
+ expect(owner.has_active_subscription?).to be false
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ module Susply
4
+ describe CreatePayment do
5
+ let(:owner_class) { Susply.subscription_owner_class.constantize }
6
+ it "returns nil when its passes a closed subscription" do
7
+ s = create(:susply_subscription, :inactive)
8
+ payment = Susply::CreatePayment.call(s, 'my_type')
9
+
10
+ expect(payment).to be_nil
11
+ end
12
+
13
+ context "when passes an active subscription" do
14
+ let(:owner) {owner_class.create(name: 'iokero')}
15
+ it "sets the payment owner to the subscription owner" do
16
+ s = create(:susply_subscription, :active, owner: owner)
17
+ payment = Susply::CreatePayment.call(s, 'plan_change')
18
+
19
+ expect(payment.owner).to be owner
20
+ end
21
+
22
+ it "sets the payment plan to the subscription plan" do
23
+ plan = create(:susply_plan, sku: 'awea')
24
+ s = create(:susply_subscription, :active, owner: owner, plan: plan)
25
+ payment = Susply::CreatePayment.call(s, 'plan_change')
26
+
27
+ expect(payment.plan).to be plan
28
+ end
29
+
30
+ it "sets the payment subscription to the passed subscription" do
31
+ s = create(:susply_subscription, :active, owner: owner)
32
+ payment = Susply::CreatePayment.call(s, 'plan_change')
33
+
34
+ expect(payment.subscription).to be s
35
+ end
36
+
37
+ it "sets the payment amount proratated for no renovation type" do
38
+ allow(Susply::Prorate).to receive(:call) {5}
39
+ s = create(:susply_subscription, :active, owner: owner)
40
+ payment = Susply::CreatePayment.call(s, 'plan_change')
41
+
42
+ expect(payment.amount).to be 5
43
+ end
44
+
45
+ it "sets the payment mount as full plan price for renovation type" do
46
+ plan = create(:susply_plan, price: 25)
47
+ s = create(:susply_subscription, :active, owner: owner, plan: plan)
48
+ payment = Susply::CreatePayment.call(s, 'plan_renovation')
49
+
50
+ expect(payment.amount).to be 25
51
+ end
52
+
53
+ it "sets the payment type to the passed generated type" do
54
+ s = create(:susply_subscription, :active, owner: owner)
55
+ payment = Susply::CreatePayment.call(s, 'plan_change')
56
+
57
+ expect(payment.generated_type).to eq 'plan_change'
58
+ end
59
+
60
+ it "sets the payment period start" do
61
+ s = create(:susply_subscription, :active, owner: owner,
62
+ current_period_start: Time.zone.now - 3.hours)
63
+ payment = Susply::CreatePayment.call(s, 'plan_change')
64
+
65
+ expect(payment.period_start).to eq s.current_period_start
66
+ end
67
+
68
+ it "sets the payment period end" do
69
+ s = create(:susply_subscription, :active, owner: owner,
70
+ current_period_end: Time.zone.now + 3.hours)
71
+ payment = Susply::CreatePayment.call(s, 'plan_change')
72
+
73
+ expect(payment.period_end).to eq s.current_period_end
74
+ end
75
+
76
+ it "sets the status to generated" do
77
+ s = create(:susply_subscription, :active, owner: owner)
78
+ payment = Susply::CreatePayment.call(s, 'plan_change')
79
+
80
+ expect(payment.status).to eq 'generated'
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Susply
4
+ describe CreateSubscription do
5
+ it "creates the subscription" do
6
+ owner = Organization.create(name: "Iokero", subdomain: 'iokero')
7
+ plan = create(:susply_plan, interval: 'monthly')
8
+
9
+ subscription = Susply::CreateSubscription.call(owner, plan)
10
+
11
+ expect(subscription.id).not_to be_nil
12
+ expect(subscription.owner).to eq owner
13
+ expect(subscription.plan).to eq plan
14
+ expect(subscription.quantity).to eq 1
15
+ expect(subscription.start).to be_within(1.second).of(Time.zone.now)
16
+ expect(subscription.current_period_start).
17
+ to be_within(2.second).of(Time.zone.now)
18
+ expect(subscription.current_period_end).
19
+ to be_within(2.second).of(Time.zone.now + 1.month)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+ require 'byebug'
3
+
4
+ module Susply
5
+ describe OwnerMethods do
6
+ let(:owner_class) { Susply.subscription_owner_class.constantize }
7
+
8
+ describe "sets the has many relationship for subscriptions" do
9
+ it "has many subscriptions" do
10
+ a = owner_class.reflect_on_association(:subscriptions)
11
+ expect(a.macro).to eq :has_many
12
+ end
13
+
14
+ it "sets subscriptions class" do
15
+ a = owner_class.reflect_on_association(:subscriptions)
16
+ expect(a.options[:class_name]).to eq 'Susply::Subscription'
17
+ end
18
+
19
+ it "sets subscriptions foreign key" do
20
+ a = owner_class.reflect_on_association(:subscriptions)
21
+ expect(a.options[:foreign_key]).to eq 'owner_id'
22
+ end
23
+ end
24
+
25
+ describe "sets the has many relationship for payments" do
26
+ it "has many payments" do
27
+ a = owner_class.reflect_on_association(:payments)
28
+ expect(a.macro).to eq :has_many
29
+ end
30
+
31
+ it "sets payments class" do
32
+ a = owner_class.reflect_on_association(:payments)
33
+ expect(a.options[:class_name]).to eq 'Susply::Payment'
34
+ end
35
+
36
+ it "sets payments foreign key" do
37
+ a = owner_class.reflect_on_association(:payments)
38
+ expect(a.options[:foreign_key]).to eq 'owner_id'
39
+ end
40
+ end
41
+
42
+
43
+ describe "#active_subscription" do
44
+ it "returns nil when the is no subscrition" do
45
+ o = owner_class.create
46
+
47
+ expect(o.active_subscription).to be_nil
48
+ end
49
+
50
+ it "returns nil when the is no active subscription" do
51
+ o = owner_class.create
52
+ s = create(:susply_subscription, :inactive, owner: o)
53
+
54
+ expect(o.active_subscription).to be_nil
55
+ end
56
+
57
+ it "returns the active subscription when presente" do
58
+ o = owner_class.create
59
+ s = create(:susply_subscription, :active, owner: o)
60
+
61
+ expect(o.active_subscription).to eq s
62
+ end
63
+ end
64
+
65
+ describe "#has_active_subscription?" do
66
+ it "returns true when there is an active subscription" do
67
+ o = owner_class.create
68
+ s = create(:susply_subscription, :active, owner: o)
69
+
70
+ expect(o.has_active_subscription?).to eq true
71
+ end
72
+
73
+ it "returns false when there is not an active subscription" do
74
+ o = owner_class.create
75
+ s = create(:susply_subscription, :inactive, owner: o)
76
+
77
+ expect(o.has_active_subscription?).to eq false
78
+ end
79
+ end
80
+
81
+ describe "#most_recentry_deactivated_subscription" do
82
+ it "returns nil when there is no inactive subscription" do
83
+ o = owner_class.create
84
+ s = create(:susply_subscription, :active, owner: o)
85
+
86
+ expect(o.most_recently_deactivated_subscription).to be_nil
87
+ end
88
+
89
+ it "returns the most recently deactivated usbscription" do
90
+ o = owner_class.create
91
+ mr = create(:susply_subscription, :inactive, owner: o)
92
+ nr = create(:susply_subscription, :inactive, owner: o,
93
+ deactivated_at: Time.zone.now - 5.days)
94
+
95
+ expect(o.most_recently_deactivated_subscription).to eq mr
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ module Susply
4
+ describe Prorate do
5
+ let(:time) {Time.zone.now}
6
+
7
+ describe ".call" do
8
+ it "returns 0 when subscription is not active" do
9
+ time = Time.zone.now - 3.days
10
+ subscription = create(:susply_subscription, deactivated_at: time)
11
+
12
+ expect(Susply::Prorate.call(subscription)).to be 0
13
+ end
14
+
15
+ it "returns the calculated amount for montly" do
16
+ plan = build(:susply_plan, price: 100, interval: 'monthly')
17
+ s = build(:susply_subscription, current_period_start: time - 7.days,
18
+ plan: plan )
19
+
20
+ expect(Susply::Prorate.call(s)).to be 24
21
+ end
22
+
23
+ it "returns the calculated amount for yearly" do
24
+ plan = build(:susply_plan, price: 1000, interval: 'yearly')
25
+ s = build(:susply_subscription, current_period_start: time - 304.days,
26
+ plan: plan )
27
+
28
+ expect(Susply::Prorate.call(s)).to be 1000
29
+ end
30
+ end
31
+
32
+ describe ".used_days" do
33
+ it "returns the number of days in a month" do
34
+ s = build(:susply_subscription, current_period_start: time - 7.days )
35
+
36
+ expect(Susply::Prorate.used_days(s)).to be 7
37
+ end
38
+
39
+ it "returns the number of days in a year" do
40
+ s = build(:susply_subscription, current_period_start: time - 102.days )
41
+
42
+ expect(Susply::Prorate.used_days(s)).to be 102
43
+ end
44
+ end
45
+
46
+ describe ".calculate_used_amount" do
47
+ context "when plan interval is yearly" do
48
+ it "returns the prorate amount with price + 2 months" do
49
+ plan = build(:susply_plan, price: 40, interval: 'yearly')
50
+ used_days = 182
51
+ amount = Susply::Prorate.calculate_used_amount(plan, used_days)
52
+
53
+ expect(amount).to be 24
54
+ end
55
+
56
+ it "always return an integer value" do
57
+ plan = build(:susply_plan, price: 100, interval: 'yearly')
58
+ used_days = 91
59
+ amount = Susply::Prorate.calculate_used_amount(plan, used_days)
60
+
61
+ expect(amount).to be 30
62
+ end
63
+ end
64
+
65
+ context "when plan interval is monthly" do
66
+ it "returns the prorate amount based on 30 days use" do
67
+ plan = build(:susply_plan, price: 100, interval: 'monthly')
68
+ used_days = 91
69
+ amount = Susply::Prorate.calculate_used_amount(plan, used_days)
70
+
71
+ expect(amount).to be 304
72
+ end
73
+
74
+ it "returns the prorate amount based on 30 days use" do
75
+ plan = build(:susply_plan, price: 49, interval: 'monthly')
76
+ used_days = 15
77
+ amount = Susply::Prorate.calculate_used_amount(plan, used_days)
78
+
79
+ expect(amount).to be 25
80
+ end
81
+
82
+ it "returns the exact amount used" do
83
+ plan = build(:susply_plan, price: 99, interval: 'monthly')
84
+ used_days = 10
85
+ amount = Susply::Prorate.calculate_used_amount(plan, used_days)
86
+
87
+ expect(amount).to be 33
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ module Susply
4
+ describe RenewsSubscription do
5
+ let(:owner_class) { Susply.subscription_owner_class.constantize }
6
+ let(:time) {Time.zone.today}
7
+
8
+ context "when owner does not has an active subscription" do
9
+ it "returns nil" do
10
+ owner = owner_class.create()
11
+ plan = create(:susply_plan)
12
+ subscription = create(:susply_subscription, :inactive, owner: owner)
13
+
14
+ s = Susply::RenewsSubscription.call(owner)
15
+
16
+ expect(s).to be_nil
17
+ end
18
+ end
19
+
20
+ context "when owner has an active subscription" do
21
+ it "creates a payment of renovation type" do
22
+ owner = owner_class.create()
23
+ plan = create(:susply_plan, interval: 'monthly', price: 101)
24
+ subscription = create(:susply_subscription, :active,
25
+ owner: owner, plan: plan)
26
+
27
+ s = Susply::RenewsSubscription.call(owner)
28
+ payment = owner.payments.last
29
+
30
+ expect(payment.generated_type).to eq 'plan_renovation'
31
+ expect(payment.amount).to eq 101
32
+ end
33
+
34
+ it "does not creates an extra subscription" do
35
+ owner = owner_class.create()
36
+ subscription = create(:susply_subscription, :active, owner: owner)
37
+
38
+ Susply::RenewsSubscription.call(owner)
39
+
40
+ expect(owner.subscriptions.count).to be 1
41
+ end
42
+
43
+ it "return a subscription with updated attributes" do
44
+ owner = owner_class.create()
45
+ subscription = create(:susply_subscription, :active, owner: owner,
46
+ current_period_start: time - 5.days)
47
+ s = Susply::RenewsSubscription.call(owner)
48
+
49
+ expect(s.quantity).not_to eq subscription.quantity
50
+ expect(s.current_period_start).
51
+ not_to eq subscription.current_period_start
52
+ expect(s.current_period_end).
53
+ not_to eq subscription.current_period_end
54
+ end
55
+
56
+ it "returns updates by one the subscriptions" do
57
+ owner = owner_class.create()
58
+ subscription = create(:susply_subscription, :active, owner: owner,
59
+ current_period_start: time - 5.days,
60
+ quantity: 5)
61
+ s = Susply::RenewsSubscription.call(owner)
62
+
63
+ expect(s.quantity).to eq 6
64
+ end
65
+
66
+ it "sets the subscription initial date o past end" do
67
+ owner = owner_class.create()
68
+ end_time = time + 6.hours
69
+ subscription = create(:susply_subscription, :active, owner: owner,
70
+ current_period_start: time - 5.days,
71
+ current_period_end: end_time)
72
+ s = Susply::RenewsSubscription.call(owner)
73
+
74
+ expect(s.current_period_start).to eq end_time
75
+ end
76
+
77
+ it "sets the end period to the given month calculation" do
78
+ owner = owner_class.create()
79
+ end_time = time + 6.hours
80
+ plan = create(:susply_plan, interval: 'monthly')
81
+ subscription = create(:susply_subscription, :active, owner: owner,
82
+ plan: plan, current_period_end: end_time)
83
+ s = Susply::RenewsSubscription.call(owner)
84
+ expect(s.current_period_end).to eq(end_time + 1.month)
85
+ end
86
+
87
+ it "sets the end period to the given yearly calculation" do
88
+ owner = owner_class.create()
89
+ end_time = time + 2.hours
90
+ plan = create(:susply_plan, interval: 'yearly')
91
+ subscription = create(:susply_subscription, :active, owner: owner,
92
+ plan: plan, current_period_end: end_time)
93
+ s = Susply::RenewsSubscription.call(owner)
94
+ expect(s.current_period_end).to eq(end_time + 1.year)
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,19 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path("../dummy/config/environment", __FILE__)
3
+ require 'rspec/rails'
4
+ require 'factory_girl_rails'
5
+ require "codeclimate-test-reporter"
6
+ CodeClimate::TestReporter.start
7
+
8
+ Rails.backtrace_cleaner.remove_silencers!
9
+
10
+ # Load support files
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
+
13
+ RSpec.configure do |config|
14
+ config.mock_with :rspec
15
+ config.use_transactional_fixtures = true
16
+ config.infer_base_class_for_anonymous_controllers = false
17
+ config.order = "random"
18
+ config.include FactoryGirl::Syntax::Methods
19
+ end