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.
- checksums.yaml +4 -4
- data/README.md +15 -3
- data/VERSION +1 -1
- data/app/controllers/paid_up/subscriptions_controller.rb +1 -0
- data/app/helpers/paid_up/plans_helper.rb +18 -2
- data/app/views/paid_up/features/_table.html.haml +1 -1
- data/app/views/paid_up/plans/index.html.haml +1 -1
- data/app/views/paid_up/subscriptions/index.html.haml +1 -1
- data/app/views/paid_up/subscriptions/new.html.haml +6 -1
- data/config/locales/en.yml +1 -0
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +126 -59
- data/db/migrate/20160210165128_add_coupon_code_column_to_users.rb +5 -0
- data/lib/paid_up/mixins/subscriber.rb +13 -5
- data/paid_up.gemspec +5 -3
- data/spec/controllers/paid_up/subscriptions_spec.rb +70 -29
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20160210165341_add_coupon_code_column_to_users.paid_up.rb +6 -0
- data/spec/dummy/db/schema.rb +2 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +6751 -0
- metadata +4 -2
@@ -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
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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
|
141
|
-
|
142
|
-
|
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
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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
|
160
|
-
|
161
|
-
|
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
|
data/spec/dummy/config/routes.rb
CHANGED
Binary file
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -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:
|
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
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|