effective_orders 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/effective_orders/version.rb +1 -1
- metadata +10 -258
- data/spec/controllers/admin/orders_controller_spec.rb +0 -243
- data/spec/controllers/carts_controller_spec.rb +0 -143
- data/spec/controllers/ccbill_orders_controller_spec.rb +0 -103
- data/spec/controllers/moneris_orders_controller_spec.rb +0 -133
- data/spec/controllers/orders_controller_spec.rb +0 -500
- data/spec/controllers/stripe_orders_controller_spec.rb +0 -128
- data/spec/controllers/webhooks_controller_spec.rb +0 -170
- data/spec/dummy/README.rdoc +0 -8
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/product.rb +0 -9
- data/spec/dummy/app/models/product_with_float_price.rb +0 -9
- data/spec/dummy/app/models/user.rb +0 -11
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -32
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -80
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/devise.rb +0 -254
- data/spec/dummy/config/initializers/effective_addresses.rb +0 -15
- data/spec/dummy/config/initializers/effective_orders.rb +0 -269
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/simple_form.rb +0 -189
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/schema.rb +0 -158
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -164
- data/spec/dummy/log/test.log +0 -60
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/fixtures/stripe_webhooks/invoice.payment_succeeded.without_renewals.json +0 -76
- data/spec/helpers/effective_orders_helper_spec.rb +0 -21
- data/spec/models/acts_as_purchasable_spec.rb +0 -75
- data/spec/models/customer_spec.rb +0 -72
- data/spec/models/factories_spec.rb +0 -35
- data/spec/models/order_item_spec.rb +0 -35
- data/spec/models/order_spec.rb +0 -445
- data/spec/models/stripe_charge_spec.rb +0 -39
- data/spec/models/subscription_spec.rb +0 -103
- data/spec/spec_helper.rb +0 -46
- data/spec/support/factories.rb +0 -139
data/spec/dummy/public/404.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/404.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/422.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/422.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The change you wanted was rejected.</h1>
|
62
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/500.html
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/500.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>We're sorry, but something went wrong.</h1>
|
62
|
-
</div>
|
63
|
-
<p>If you are the application owner check the logs for more information.</p>
|
64
|
-
</div>
|
65
|
-
</body>
|
66
|
-
</html>
|
File without changes
|
@@ -1,76 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"created": 1326853478,
|
3
|
-
"livemode": false,
|
4
|
-
"id": "evt_00000000000000",
|
5
|
-
"type": "invoice.payment_succeeded",
|
6
|
-
"object": "event",
|
7
|
-
"data": {
|
8
|
-
"object": {
|
9
|
-
"date": 1394018368,
|
10
|
-
"id": "in_00000000000000",
|
11
|
-
"period_start": 1394018368,
|
12
|
-
"period_end": 1394018368,
|
13
|
-
"lines": {
|
14
|
-
"object": "list",
|
15
|
-
"count": 3,
|
16
|
-
"url": "/v1/invoices/in_00000000000000/lines",
|
17
|
-
"data": [
|
18
|
-
{
|
19
|
-
"id": "ii_00000000000000",
|
20
|
-
"object": "line_item",
|
21
|
-
"type": "invoiceitem",
|
22
|
-
"livemode": false,
|
23
|
-
"amount": 19000,
|
24
|
-
"currency": "usd",
|
25
|
-
"proration": true,
|
26
|
-
"period": {
|
27
|
-
"start": 1393765661,
|
28
|
-
"end": 1393765661
|
29
|
-
},
|
30
|
-
"quantity": null,
|
31
|
-
"plan": null,
|
32
|
-
"description": "Remaining time on Platinum after 02 Mar 2014",
|
33
|
-
"metadata": {}
|
34
|
-
},
|
35
|
-
{
|
36
|
-
"id": "ii_00000000000001",
|
37
|
-
"object": "line_item",
|
38
|
-
"type": "invoiceitem",
|
39
|
-
"livemode": false,
|
40
|
-
"amount": -9000,
|
41
|
-
"currency": "usd",
|
42
|
-
"proration": true,
|
43
|
-
"period": {
|
44
|
-
"start": 1393765661,
|
45
|
-
"end": 1393765661
|
46
|
-
},
|
47
|
-
"quantity": null,
|
48
|
-
"plan": null,
|
49
|
-
"description": "Unused time on Gold after 05 Mar 2014",
|
50
|
-
"metadata": {}
|
51
|
-
}
|
52
|
-
]
|
53
|
-
},
|
54
|
-
"subtotal": 30000,
|
55
|
-
"total": 30000,
|
56
|
-
"customer": "cus_00000000000000",
|
57
|
-
"object": "invoice",
|
58
|
-
"attempted": true,
|
59
|
-
"closed": true,
|
60
|
-
"paid": true,
|
61
|
-
"livemode": false,
|
62
|
-
"attempt_count": 1,
|
63
|
-
"amount_due": 0,
|
64
|
-
"currency": "usd",
|
65
|
-
"starting_balance": 0,
|
66
|
-
"ending_balance": 0,
|
67
|
-
"next_payment_attempt": null,
|
68
|
-
"charge": "ch_00000000000000",
|
69
|
-
"discount": null,
|
70
|
-
"application_fee": null,
|
71
|
-
"subscription": "su_00000000000000",
|
72
|
-
"metadata": {},
|
73
|
-
"description": null
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EffectiveOrdersHelper, :type => :helper do
|
4
|
-
describe '#price_to_currency' do
|
5
|
-
it 'converts an integer number of cents to a currency formatted string' do
|
6
|
-
price_to_currency(1050).should eq '$10.50'
|
7
|
-
price_to_currency(10050).should eq '$100.50'
|
8
|
-
price_to_currency(1).should eq '$0.01'
|
9
|
-
price_to_currency(99).should eq '$0.99'
|
10
|
-
price_to_currency(0).should eq '$0.00'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'raises an error when passed a decimal' do
|
14
|
-
expect { price_to_currency(10.00) }.to raise_exception(Exception)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'raises an error when passed nil' do
|
18
|
-
expect { price_to_currency(nil) }.to raise_exception(Exception)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# # Attributes
|
4
|
-
describe Product do
|
5
|
-
let(:user) { FactoryGirl.create(:user) }
|
6
|
-
let(:order) { FactoryGirl.create(:order) }
|
7
|
-
let(:product) { order.order_items.first.purchasable }
|
8
|
-
let(:product_with_float_price) { FactoryGirl.create(:product_with_float_price) }
|
9
|
-
|
10
|
-
describe 'assumptions' do
|
11
|
-
it 'should be effectively purchasable' do
|
12
|
-
product.kind_of?(ActsAsPurchasable).should eq true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'purchased' do
|
17
|
-
it 'is purchased? when in a purchased Order' do
|
18
|
-
order.purchase!
|
19
|
-
|
20
|
-
product.purchased?.should eq true
|
21
|
-
product.purchased_orders.include?(order).should eq true
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'is purchased? in the after_purchase callback' do
|
25
|
-
instance_order = nil
|
26
|
-
instance_product = nil
|
27
|
-
instance_purchased = nil
|
28
|
-
|
29
|
-
Product.instance_eval do
|
30
|
-
after_purchase do |order, order_item|
|
31
|
-
if defined?(:instance_order)
|
32
|
-
instance_order = order
|
33
|
-
instance_product = self
|
34
|
-
instance_purchased = self.purchased?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
order.purchase!
|
40
|
-
|
41
|
-
instance_order.purchased?.should eq true
|
42
|
-
instance_product.purchased?.should eq true
|
43
|
-
instance_purchased.should eq true
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'is returned by the purchased scopes' do
|
47
|
-
order.purchase!
|
48
|
-
|
49
|
-
Product.purchased.to_a.include?(product).should eq true
|
50
|
-
Product.purchased_by(order.user).to_a.include?(product).should eq true
|
51
|
-
|
52
|
-
Product.sold.to_a.include?(product).should eq true
|
53
|
-
|
54
|
-
Product.not_purchased.to_a.include?(product).should eq false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe 'price=' do
|
59
|
-
it 'should accept an integer price' do
|
60
|
-
product = Product.new()
|
61
|
-
product.price = 1250
|
62
|
-
|
63
|
-
product.price.should eq 1250
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should convert a String that looks like an Integer' do
|
67
|
-
product = Product.new()
|
68
|
-
product.price = '1250'
|
69
|
-
|
70
|
-
product.price.should eq 1250
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'stripe_mock'
|
4
|
-
|
5
|
-
# # Attributes
|
6
|
-
describe Effective::Customer do
|
7
|
-
let(:customer) { FactoryGirl.create(:customer) }
|
8
|
-
let(:user) { FactoryGirl.create(:user) }
|
9
|
-
|
10
|
-
describe 'Customer.for' do
|
11
|
-
it 'creates a new Customer when passed a new user' do
|
12
|
-
c = Effective::Customer.for_buyer(user)
|
13
|
-
|
14
|
-
c.kind_of?(Effective::Customer).should eq true
|
15
|
-
c.persisted?.should eq true
|
16
|
-
c.valid?.should eq true
|
17
|
-
c.user.should eq user
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns an existing Customer when passed an existing user' do
|
21
|
-
c = Effective::Customer.for_buyer(customer.user)
|
22
|
-
c.should eq customer
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'Stripe Integration' do
|
27
|
-
before { StripeMock.start }
|
28
|
-
after { StripeMock.stop }
|
29
|
-
let(:stripe_helper) { StripeMock.create_test_helper }
|
30
|
-
|
31
|
-
describe '#stripe_customer' do
|
32
|
-
it 'creates a new Stripe::Customer if one doesnt exist.' do
|
33
|
-
stripe_customer = customer.stripe_customer
|
34
|
-
|
35
|
-
stripe_customer.kind_of?(::Stripe::Customer).should eq true
|
36
|
-
|
37
|
-
stripe_customer.email.should eq customer.user.email
|
38
|
-
stripe_customer.id.should eq customer.stripe_customer_id
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'retrieves an existing Stripe::Customer if exists' do
|
42
|
-
# Test set up. Create the user.
|
43
|
-
user = customer.user
|
44
|
-
stripe_customer = ::Stripe::Customer.create(:email => user.email, :description => user.id.to_s)
|
45
|
-
customer.update_attributes(:stripe_customer_id => stripe_customer.id)
|
46
|
-
|
47
|
-
customer.reload
|
48
|
-
|
49
|
-
customer.stripe_customer.id.should eq stripe_customer.id
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#update_card' do
|
54
|
-
it 'can update the card' do
|
55
|
-
customer.update_card!(stripe_helper.generate_card_token).should eq true
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'updates stripe_active_card when updating the card' do
|
59
|
-
customer.should_receive(:save!).and_return(true)
|
60
|
-
customer.update_card!(stripe_helper.generate_card_token).should eq true
|
61
|
-
|
62
|
-
customer.stripe_active_card.present?.should eq true
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|