jackpot 0.0.3
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.
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.rvmrc.example +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +181 -0
- data/MIT-LICENSE +20 -0
- data/README.md +134 -0
- data/Rakefile +25 -0
- data/app/assets/images/jackpot/.gitkeep +0 -0
- data/app/assets/javascripts/jackpot/application.js +5 -0
- data/app/assets/javascripts/jackpot/bootstrap.js +32 -0
- data/app/assets/javascripts/jackpot/customers.js +2 -0
- data/app/assets/javascripts/jackpot/login.js +1 -0
- data/app/assets/javascripts/jackpot/payments.js +2 -0
- data/app/assets/javascripts/jackpot/subscriptions.js +2 -0
- data/app/assets/stylesheets/jackpot/application.css +9 -0
- data/app/assets/stylesheets/jackpot/customers.css +4 -0
- data/app/assets/stylesheets/jackpot/jackpot.css +10 -0
- data/app/controllers/jackpot/application_controller.rb +4 -0
- data/app/controllers/jackpot/customers_controller.rb +100 -0
- data/app/controllers/jackpot/payments_controller.rb +20 -0
- data/app/controllers/jackpot/subscriptions_controller.rb +86 -0
- data/app/helpers/jackpot/application_helper.rb +27 -0
- data/app/helpers/jackpot/customers_helper.rb +7 -0
- data/app/helpers/jackpot/subscriptions_helper.rb +4 -0
- data/app/models/jackpot/card.rb +29 -0
- data/app/models/jackpot/customer.rb +48 -0
- data/app/models/jackpot/gateway.rb +28 -0
- data/app/models/jackpot/payment.rb +33 -0
- data/app/models/jackpot/subscription.rb +13 -0
- data/app/models/jackpot/user.rb +25 -0
- data/app/views/jackpot/customers/_credit_card_form.html.erb +42 -0
- data/app/views/jackpot/customers/_form.html.erb +17 -0
- data/app/views/jackpot/customers/edit.html.erb +13 -0
- data/app/views/jackpot/customers/index.html.erb +30 -0
- data/app/views/jackpot/customers/new.html.erb +8 -0
- data/app/views/jackpot/customers/show.html.erb +32 -0
- data/app/views/jackpot/payments/create.html.erb +1 -0
- data/app/views/jackpot/payments/index.html.erb +25 -0
- data/app/views/jackpot/shared/_flash_messages.html.erb +6 -0
- data/app/views/jackpot/shared/_navigation.html.erb +5 -0
- data/app/views/jackpot/subscriptions/_form.html.erb +13 -0
- data/app/views/jackpot/subscriptions/edit.html.erb +6 -0
- data/app/views/jackpot/subscriptions/index.html.erb +29 -0
- data/app/views/jackpot/subscriptions/new.html.erb +4 -0
- data/app/views/jackpot/subscriptions/show.html.erb +23 -0
- data/app/views/layouts/devise.html.erb +22 -0
- data/app/views/layouts/jackpot/application.html.erb +39 -0
- data/config/initializers/jackpot_devise.rb +226 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/routes.rb +17 -0
- data/db/migrate/20111221002616_create_jackpot_payments.rb +11 -0
- data/db/migrate/20111230014003_add_customer_information_to_jackpot_payments.rb +5 -0
- data/db/migrate/20120102223341_create_jackpot_subscriptions.rb +10 -0
- data/db/migrate/20120103211153_create_jackpot_customers.rb +11 -0
- data/db/migrate/20120104164830_add_credit_card_number_to_customer.rb +5 -0
- data/db/migrate/20120130173242_add_credit_card_information_to_customers.rb +7 -0
- data/db/migrate/20120208191815_add_billing_period_to_jackpot_subscriptions.rb +5 -0
- data/db/migrate/20120208191934_add_good_until_date_to_jackpot_customers.rb +6 -0
- data/db/migrate/20120209203542_add_subscription_and_customer_to_jackpot_payments.rb +8 -0
- data/db/migrate/20120209212043_rename_column_token_in_jackpot_payments.rb +5 -0
- data/db/migrate/20120210144038_devise_create_jackpot_users.rb +49 -0
- data/jackpot.gemspec +33 -0
- data/lib/jackpot.rb +23 -0
- data/lib/jackpot/configuration.rb +33 -0
- data/lib/jackpot/cron.rb +22 -0
- data/lib/jackpot/engine.rb +14 -0
- data/lib/jackpot/errors.rb +18 -0
- data/lib/jackpot/factory.rb +26 -0
- data/lib/jackpot/version.rb +3 -0
- data/lib/tasks/jackpot_tasks.rake +38 -0
- data/script/rails +6 -0
- data/spec/controllers/jackpot/customers_controller_spec.rb +170 -0
- data/spec/controllers/jackpot/payments_controller_spec.rb +47 -0
- data/spec/controllers/jackpot/subscriptions_controller_spec.rb +153 -0
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +51 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +17 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +32 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/jackpot.rb +13 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/schema.rb +68 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +5 -0
- data/spec/dummy/public/payment.html +36 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/vcr/Create_Customers_To_bill_monthly_my_customers_As_a_user_I_want_to_record_their_billing_information_/assigning_credit_card_information_to_customer.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_NEVER_persist_in_the_database_the_actual_card_number.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_NEVER_persist_in_the_database_the_verification_value.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_persist_in_the_database_the_ONLY_last_four_digits.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_persist_the_card_information.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_store_this_card_at_the_gateway.yml +34 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/creates_a_new_payment.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/does_not_persist_credit_card_token_information.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/records_the_payment_transaction_id_for_future_reference.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/records_this_payment_information.yml +96 -0
- data/spec/fixtures/vcr/Jackpot_Payment/_customer_name/returns_its_customer_email.yml +96 -0
- data/spec/fixtures/vcr/jackpot/customer/updatecard.yml +34 -0
- data/spec/fixtures/vcr/jackpot/customer_expiration_date.yml +34 -0
- data/spec/fixtures/vcr/jackpot/receiving_payments.yml +96 -0
- data/spec/helpers/jackpot/customers_helper_spec.rb +16 -0
- data/spec/helpers/jackpot/subscriptions_helper_spec.rb +4 -0
- data/spec/lib/cron_spec.rb +39 -0
- data/spec/lib/factory_spec.rb +40 -0
- data/spec/models/jackpot/card_spec.rb +23 -0
- data/spec/models/jackpot/customer_spec.rb +140 -0
- data/spec/models/jackpot/gateway_spec.rb +22 -0
- data/spec/models/jackpot/payment_spec.rb +74 -0
- data/spec/models/jackpot/subscription_spec.rb +19 -0
- data/spec/requests/jackpot/jackpot_assign_subscription_to_customer_spec.rb +39 -0
- data/spec/requests/jackpot/jackpot_create_customer_spec.rb +73 -0
- data/spec/requests/jackpot/jackpot_create_subscriptions_spec.rb +27 -0
- data/spec/requests/jackpot/jackpot_receive_payments_spec.rb +34 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/support/active_merchant.rb +1 -0
- data/spec/support/capybara.rb +6 -0
- data/spec/support/devise.rb +21 -0
- data/spec/support/factories/jackpot_customers.rb +36 -0
- data/spec/support/factories/jackpot_payments.rb +7 -0
- data/spec/support/factories/jackpot_subscriptions.rb +9 -0
- data/spec/support/factories/jackpot_users.rb +9 -0
- data/spec/support/helpers.rb +16 -0
- data/spec/support/routes.rb +3 -0
- data/spec/support/vcr.rb +10 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/twitter/bootstrap.js +12 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +91 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +98 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +154 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +136 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +92 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +209 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +95 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +125 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +130 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +270 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +51 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +271 -0
- data/vendor/assets/stylesheets/twitter/bootstrap/bootstrap-responsive.css +567 -0
- data/vendor/assets/stylesheets/twitter/bootstrap/bootstrap.css.erb +3366 -0
- metadata +351 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Jackpot
|
|
4
|
+
describe CustomersController do
|
|
5
|
+
|
|
6
|
+
let(:user) { Factory(:user) }
|
|
7
|
+
|
|
8
|
+
before :each do
|
|
9
|
+
sign_in :user, user
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def valid_attributes
|
|
13
|
+
{}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:customer) { Customer.create! valid_attributes }
|
|
17
|
+
|
|
18
|
+
describe "PUT edit_credit_card" do
|
|
19
|
+
|
|
20
|
+
before do
|
|
21
|
+
Card.stub!(:new).with(valid_attributes).and_return('stub')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "updates card number" do
|
|
25
|
+
Customer.any_instance.should_receive(:update_credit_card).with('stub')
|
|
26
|
+
valid_request
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "sets the flash message" do
|
|
30
|
+
Customer.any_instance.stub(:update_credit_card).with('stub')
|
|
31
|
+
valid_request
|
|
32
|
+
should set_the_flash
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def valid_request
|
|
37
|
+
put :credit_card, :id => customer.id , :credit_card => valid_attributes , :use_route => "jackpot"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "GET index" do
|
|
43
|
+
it "assigns all customers as @customers" do
|
|
44
|
+
customer = Customer.create! valid_attributes
|
|
45
|
+
get :index, :use_route => "jackpot"
|
|
46
|
+
assigns(:customers).should eq([customer])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "GET show" do
|
|
51
|
+
it "assigns the requested customer as @customer" do
|
|
52
|
+
customer = Customer.create! valid_attributes
|
|
53
|
+
get :show, :id => customer.id , :use_route => "jackpot"
|
|
54
|
+
assigns(:customer).should eq(customer)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe "GET new" do
|
|
59
|
+
it "assigns a new customer as @customer" do
|
|
60
|
+
get :new, :use_route => "jackpot"
|
|
61
|
+
assigns(:customer).should be_a_new(Customer)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe "GET edit" do
|
|
66
|
+
it "assigns the requested customer as @customer" do
|
|
67
|
+
customer = Customer.create! valid_attributes
|
|
68
|
+
get :edit, :id => customer.id, :use_route => "jackpot"
|
|
69
|
+
assigns(:customer).should eq(customer)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "POST create" do
|
|
74
|
+
describe "with valid params" do
|
|
75
|
+
it "creates a new Customer" do
|
|
76
|
+
expect {
|
|
77
|
+
post :create, :customer => valid_attributes, :use_route => "jackpot"
|
|
78
|
+
}.to change(Customer, :count).by(1)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "assigns a newly created customer as @customer" do
|
|
82
|
+
post :create, :customer => valid_attributes, :use_route => "jackpot"
|
|
83
|
+
assigns(:customer).should be_a(Customer)
|
|
84
|
+
assigns(:customer).should be_persisted
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "redirects to the created customer" do
|
|
88
|
+
post :create, :customer => valid_attributes, :use_route => "jackpot"
|
|
89
|
+
response.should redirect_to(Customer.last)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe "with invalid params" do
|
|
94
|
+
it "assigns a newly created but unsaved customer as @customer" do
|
|
95
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
96
|
+
Customer.any_instance.stub(:save).and_return(false)
|
|
97
|
+
post :create, :customer => {}, :use_route => "jackpot"
|
|
98
|
+
assigns(:customer).should be_a_new(Customer)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "re-renders the 'new' template" do
|
|
102
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
103
|
+
Customer.any_instance.stub(:save).and_return(false)
|
|
104
|
+
post :create, :customer => {}, :use_route => "jackpot"
|
|
105
|
+
response.should render_template("new")
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe "PUT update" do
|
|
111
|
+
describe "with valid params" do
|
|
112
|
+
it "updates the requested customer" do
|
|
113
|
+
customer = Customer.create! valid_attributes
|
|
114
|
+
# Assuming there are no other customers in the database, this
|
|
115
|
+
# specifies that the Customer created on the previous line
|
|
116
|
+
# receives the :update_attributes message with whatever params are
|
|
117
|
+
# submitted in the request.
|
|
118
|
+
Customer.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
|
|
119
|
+
put :update, :id => customer.id, :customer => {'these' => 'params'}, :use_route => "jackpot"
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "assigns the requested customer as @customer" do
|
|
123
|
+
customer = Customer.create! valid_attributes
|
|
124
|
+
put :update, :id => customer.id, :customer => valid_attributes, :use_route => "jackpot"
|
|
125
|
+
assigns(:customer).should eq(customer)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "redirects to the customer" do
|
|
129
|
+
customer = Customer.create! valid_attributes
|
|
130
|
+
put :update, :id => customer.id, :customer => valid_attributes, :use_route => "jackpot"
|
|
131
|
+
response.should redirect_to(customer)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
describe "with invalid params" do
|
|
136
|
+
it "assigns the customer as @customer" do
|
|
137
|
+
customer = Customer.create! valid_attributes
|
|
138
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
139
|
+
Customer.any_instance.stub(:save).and_return(false)
|
|
140
|
+
put :update, :id => customer.id, :customer => {}, :use_route => "jackpot"
|
|
141
|
+
assigns(:customer).should eq(customer)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "re-renders the 'edit' template" do
|
|
145
|
+
customer = Customer.create! valid_attributes
|
|
146
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
147
|
+
Customer.any_instance.stub(:save).and_return(false)
|
|
148
|
+
put :update, :id => customer.id, :customer => {}, :use_route => "jackpot"
|
|
149
|
+
response.should render_template("edit")
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe "DELETE destroy" do
|
|
155
|
+
it "destroys the requested customer" do
|
|
156
|
+
customer = Customer.create! valid_attributes
|
|
157
|
+
expect {
|
|
158
|
+
delete :destroy, :id => customer.id, :use_route => "jackpot"
|
|
159
|
+
}.to change(Customer, :count).by(-1)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it "redirects to the customers list" do
|
|
163
|
+
customer = Customer.create! valid_attributes
|
|
164
|
+
delete :destroy, :id => customer.id, :use_route => "jackpot"
|
|
165
|
+
response.should redirect_to(customers_path)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
end
|
|
170
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Jackpot::PaymentsController do
|
|
4
|
+
|
|
5
|
+
let(:user) { Factory(:user) }
|
|
6
|
+
|
|
7
|
+
before :each do
|
|
8
|
+
sign_in :user, user
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "POST 'create'" do
|
|
12
|
+
before(:each) do
|
|
13
|
+
Jackpot::Customer.stub!(:find).with('42').and_return customer
|
|
14
|
+
Jackpot::Customer.stub!(:find).with('1').and_return invalid_customer
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:customer) { stub(:pay_subscription => true) }
|
|
18
|
+
let(:invalid_customer) { stub(:pay_subscription => false) }
|
|
19
|
+
|
|
20
|
+
context "when customer pay his/hers subscription successfuly" do
|
|
21
|
+
it "fetches the customer we're charging" do
|
|
22
|
+
post :create, :customer_id => '42', :use_route => :jackpot
|
|
23
|
+
response.should redirect_to(payments_path)
|
|
24
|
+
end
|
|
25
|
+
it "assigns a success message" do
|
|
26
|
+
post :create, :customer_id => '42' , :use_route => :jackpot
|
|
27
|
+
flash[:notice].should be_present
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "when customer could not pay his/hers subscription" do
|
|
32
|
+
it "does not assign a success message" do
|
|
33
|
+
post :create, :customer_id => '42' , :use_route => :jackpot
|
|
34
|
+
flash[:notice].should be_present
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
describe "GET 'index'" do
|
|
41
|
+
it "returns all the payments already received" do
|
|
42
|
+
Jackpot::Payment.stub!(:all).and_return(['payments'])
|
|
43
|
+
get :index, :use_route => :jackpot
|
|
44
|
+
assigns[:payments].should be_eql ['payments']
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Jackpot
|
|
4
|
+
describe Jackpot::SubscriptionsController do
|
|
5
|
+
|
|
6
|
+
let(:user) { Factory(:user) }
|
|
7
|
+
before do
|
|
8
|
+
sign_in :user, user
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def valid_attributes
|
|
12
|
+
{name: "Gold"}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "GET index" do
|
|
16
|
+
it "assigns all subscriptions as @subscriptions" do
|
|
17
|
+
subscription = Subscription.create! valid_attributes
|
|
18
|
+
get :index, :use_route => "jackpot"
|
|
19
|
+
assigns(:subscriptions).should eq([subscription])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "GET show" do
|
|
24
|
+
it "assigns the requested subscription as @subscription" do
|
|
25
|
+
subscription = Subscription.create! valid_attributes
|
|
26
|
+
get :show, :id => subscription.id, :use_route => "jackpot"
|
|
27
|
+
|
|
28
|
+
assigns(:subscription).should eq(subscription)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "GET new" do
|
|
33
|
+
it "assigns a new subscription as @subscription" do
|
|
34
|
+
get :new, :use_route => "jackpot"
|
|
35
|
+
|
|
36
|
+
assigns(:subscription).should be_a_new(Subscription)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "GET edit" do
|
|
41
|
+
it "assigns the requested subscription as @subscription" do
|
|
42
|
+
subscription = Subscription.create! valid_attributes
|
|
43
|
+
get :edit, :id => subscription.id, :use_route => "jackpot"
|
|
44
|
+
|
|
45
|
+
assigns(:subscription).should eq(subscription)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "POST create" do
|
|
50
|
+
describe "with valid params" do
|
|
51
|
+
it "creates a new Subscription" do
|
|
52
|
+
expect {
|
|
53
|
+
post :create, :subscription => valid_attributes, :use_route => "jackpot"
|
|
54
|
+
|
|
55
|
+
}.to change(Subscription, :count).by(1)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "assigns a newly created subscription as @subscription" do
|
|
59
|
+
post :create, :subscription => valid_attributes, :use_route => "jackpot"
|
|
60
|
+
|
|
61
|
+
assigns(:subscription).should be_a(Subscription)
|
|
62
|
+
assigns(:subscription).should be_persisted
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "redirects to the created subscription" do
|
|
66
|
+
post :create, :subscription => valid_attributes, :use_route => "jackpot"
|
|
67
|
+
|
|
68
|
+
response.should redirect_to(Subscription.last)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe "with invalid params" do
|
|
73
|
+
it "assigns a newly created but unsaved subscription as @subscription" do
|
|
74
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
75
|
+
Subscription.any_instance.stub(:save).and_return(false)
|
|
76
|
+
post :create, :subscription => {}, :use_route => "jackpot"
|
|
77
|
+
|
|
78
|
+
assigns(:subscription).should be_a_new(Subscription)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "re-renders the 'new' template" do
|
|
82
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
83
|
+
Subscription.any_instance.stub(:save).and_return(false)
|
|
84
|
+
post :create, :subscription => {}, :use_route => "jackpot"
|
|
85
|
+
|
|
86
|
+
response.should render_template("new")
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe "PUT update" do
|
|
92
|
+
describe "with valid params" do
|
|
93
|
+
it "updates the requested subscription" do
|
|
94
|
+
subscription = Subscription.create! valid_attributes
|
|
95
|
+
Subscription.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
|
|
96
|
+
put :update, :id => subscription.id, :subscription => {'these' => 'params'}, :use_route => "jackpot"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "assigns the requested subscription as @subscription" do
|
|
100
|
+
subscription = Subscription.create! valid_attributes
|
|
101
|
+
put :update, :id => subscription.id, :subscription => valid_attributes, :use_route => "jackpot"
|
|
102
|
+
|
|
103
|
+
assigns(:subscription).should eq(subscription)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "redirects to the subscription" do
|
|
107
|
+
subscription = Subscription.create! valid_attributes
|
|
108
|
+
put :update, :id => subscription.id, :subscription => valid_attributes, :use_route => "jackpot"
|
|
109
|
+
|
|
110
|
+
response.should redirect_to(subscription)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "with invalid params" do
|
|
115
|
+
it "assigns the subscription as @subscription" do
|
|
116
|
+
subscription = Subscription.create! valid_attributes
|
|
117
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
118
|
+
Subscription.any_instance.stub(:save).and_return(false)
|
|
119
|
+
put :update, :id => subscription.id, :subscription => {}, :use_route => "jackpot"
|
|
120
|
+
|
|
121
|
+
assigns(:subscription).should eq(subscription)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "re-renders the 'edit' template" do
|
|
125
|
+
subscription = Subscription.create! valid_attributes
|
|
126
|
+
# Trigger the behavior that occurs when invalid params are submitted
|
|
127
|
+
Subscription.any_instance.stub(:save).and_return(false)
|
|
128
|
+
put :update, :id => subscription.id, :subscription => {}, :use_route => "jackpot"
|
|
129
|
+
|
|
130
|
+
response.should render_template("edit")
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
describe "DELETE destroy" do
|
|
136
|
+
it "destroys the requested subscription" do
|
|
137
|
+
subscription = Subscription.create! valid_attributes
|
|
138
|
+
expect {
|
|
139
|
+
delete :destroy, :id => subscription.id, :use_route => "jackpot"
|
|
140
|
+
|
|
141
|
+
}.to change(Subscription, :count).by(-1)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "redirects to the subscriptions list" do
|
|
145
|
+
subscription = Subscription.create! valid_attributes
|
|
146
|
+
delete :destroy, :id => subscription.id, :use_route => "jackpot"
|
|
147
|
+
|
|
148
|
+
response.should redirect_to(subscriptions_path)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sass-cache
|
data/spec/dummy/Rakefile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
4
|
+
|
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
|
6
|
+
|
|
7
|
+
Dummy::Application.load_tasks
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
5
|
+
// the compiled file.
|
|
6
|
+
//
|
|
7
|
+
//= require jquery
|
|
8
|
+
//= require jquery_ujs
|
|
9
|
+
//= require_tree .
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
|
5
|
+
*= require_self
|
|
6
|
+
*= require_tree .
|
|
7
|
+
*/
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
# Pick the frameworks you want:
|
|
4
|
+
require "active_record/railtie"
|
|
5
|
+
require "action_controller/railtie"
|
|
6
|
+
require "action_mailer/railtie"
|
|
7
|
+
require "active_resource/railtie"
|
|
8
|
+
require "sprockets/railtie"
|
|
9
|
+
# require "rails/test_unit/railtie"
|
|
10
|
+
|
|
11
|
+
Bundler.require
|
|
12
|
+
require "jackpot"
|
|
13
|
+
|
|
14
|
+
module Dummy
|
|
15
|
+
class Application < Rails::Application
|
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
17
|
+
# Application configuration should go into files in config/initializers
|
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
19
|
+
|
|
20
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
21
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
|
22
|
+
|
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
26
|
+
|
|
27
|
+
# Activate observers that should always be running.
|
|
28
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
29
|
+
|
|
30
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
31
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
32
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
33
|
+
|
|
34
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
35
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
36
|
+
# config.i18n.default_locale = :de
|
|
37
|
+
|
|
38
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
39
|
+
config.encoding = "utf-8"
|
|
40
|
+
|
|
41
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
42
|
+
config.filter_parameters += [:password]
|
|
43
|
+
|
|
44
|
+
# Enable the asset pipeline
|
|
45
|
+
config.assets.enabled = true
|
|
46
|
+
|
|
47
|
+
# Version of your assets, change this if you want to expire all your assets
|
|
48
|
+
config.assets.version = '1.0'
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|