paid_up 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,41 +124,82 @@ RSpec.describe PaidUp::SubscriptionsController do
124
124
  end
125
125
  context "when the user is signed in" do
126
126
  context "upgrading from the free plan" do
127
- before do
128
- sign_in free_subscriber
129
- token = working_stripe_token free_subscriber
130
- post :create, plan_id: professional_plan.id, stripeToken: token
131
- end
132
- after do
133
- free_subscriber.subscribe_to_plan free_plan
134
- end
135
- context "redirects to the subscriptions index page" do
136
- subject { response }
137
- it { should redirect_to subscriptions_path }
138
- it { should have_http_status(302) }
127
+ context 'without a coupon code' do
128
+ before do
129
+ sign_in free_subscriber
130
+ token = working_stripe_token free_subscriber
131
+ post :create, plan_id: professional_plan.id, stripeToken: token
132
+ end
133
+ after do
134
+ free_subscriber.subscribe_to_plan free_plan
135
+ end
136
+ context "redirects to the subscriptions index page" do
137
+ subject { response }
138
+ it { should redirect_to subscriptions_path }
139
+ it { should have_http_status(302) }
140
+ end
141
+ context "sets a flash message" do
142
+ subject { flash[:notice] }
143
+ it { should match /You are now subscribed to the #{professional_plan.title} Plan/ }
144
+ end
139
145
  end
140
- context "sets a flash message" do
141
- subject { flash[:notice] }
142
- it { should match /You are now subscribed to the #{professional_plan.title} Plan/ }
146
+ context 'with a coupon code' do
147
+ before do
148
+ sign_in free_subscriber
149
+ token = working_stripe_token free_subscriber
150
+ post :create, plan_id: professional_plan.id, stripeToken: token, coupon_code: '25OFF'
151
+ end
152
+ after do
153
+ free_subscriber.subscribe_to_plan free_plan
154
+ end
155
+ context "redirects to the subscriptions index page" do
156
+ subject { response }
157
+ it { should redirect_to subscriptions_path }
158
+ it { should have_http_status(302) }
159
+ end
160
+ context "sets a flash message" do
161
+ subject { flash[:notice] }
162
+ it { should match /You are now subscribed to the #{professional_plan.title} Plan/ }
163
+ end
143
164
  end
144
165
  end
145
166
 
146
167
  context "upgrading from the no ads plan" do
147
- before do
148
- sign_in no_ads_subscriber
149
- post :create, plan_id: professional_plan.id
150
- end
151
- after do
152
- no_ads_subscriber.subscribe_to_plan no_ads_plan
153
- end
154
- context "redirects to the subscriptions index page" do
155
- subject { response }
156
- it { should redirect_to subscriptions_path }
157
- it { should have_http_status(302) }
168
+ context 'without a coupon code' do
169
+ before do
170
+ sign_in no_ads_subscriber
171
+ post :create, plan_id: professional_plan.id
172
+ end
173
+ after do
174
+ no_ads_subscriber.subscribe_to_plan no_ads_plan
175
+ end
176
+ context "redirects to the subscriptions index page" do
177
+ subject { response }
178
+ it { should redirect_to subscriptions_path }
179
+ it { should have_http_status(302) }
180
+ end
181
+ context "sets a flash message" do
182
+ subject { flash[:notice] }
183
+ it { should match /You are now subscribed to the #{professional_plan.title} Plan/ }
184
+ end
158
185
  end
159
- context "sets a flash message" do
160
- subject { flash[:notice] }
161
- it { should match /You are now subscribed to the #{professional_plan.title} Plan/ }
186
+ context 'with a coupon code' do
187
+ before do
188
+ sign_in no_ads_subscriber
189
+ post :create, plan_id: professional_plan.id, coupon_code: 'MINUS25'
190
+ end
191
+ after do
192
+ no_ads_subscriber.subscribe_to_plan no_ads_plan
193
+ end
194
+ context "redirects to the subscriptions index page" do
195
+ subject { response }
196
+ it { should redirect_to subscriptions_path }
197
+ it { should have_http_status(302) }
198
+ end
199
+ context "sets a flash message" do
200
+ subject { flash[:notice] }
201
+ it { should match /You are now subscribed to the #{professional_plan.title} Plan/ }
202
+ end
162
203
  end
163
204
  end
164
205
  end
@@ -1,6 +1,7 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
3
 
4
+
4
5
  mount PaidUp::Engine => '/', :as => 'paid_up'
5
6
  devise_for :users
6
7
 
Binary file
@@ -0,0 +1,6 @@
1
+ # This migration comes from paid_up (originally 20160210165128)
2
+ class AddCouponCodeColumnToUsers < ActiveRecord::Migration
3
+ def change
4
+ add_column :users, :coupon_code, :string
5
+ end
6
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20160207184114) do
14
+ ActiveRecord::Schema.define(version: 20160210165341) do
15
15
 
16
16
  create_table "doodads", force: :cascade do |t|
17
17
  t.string "user_id"
@@ -73,6 +73,7 @@ ActiveRecord::Schema.define(version: 20160207184114) do
73
73
  t.string "current_sign_in_ip"
74
74
  t.string "last_sign_in_ip"
75
75
  t.string "stripe_id"
76
+ t.string "coupon_code"
76
77
  end
77
78
 
78
79
  add_index "users", ["email"], name: "index_users_on_email", unique: true
Binary file