trollied 0.1.0
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/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +294 -0
- data/README.rdoc +96 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/app/controllers/line_items_controller.rb +168 -0
- data/app/controllers/notes_controller.rb +121 -0
- data/app/controllers/orders_controller.rb +210 -0
- data/app/controllers/trolleys_controller.rb +26 -0
- data/app/helpers/gets_trollied_helper.rb +31 -0
- data/app/helpers/line_items_helper.rb +5 -0
- data/app/helpers/orders_helper.rb +184 -0
- data/app/models/line_item.rb +14 -0
- data/app/models/note.rb +15 -0
- data/app/models/order.rb +29 -0
- data/app/models/trolley.rb +51 -0
- data/app/views/line_items/_form.html.erb +8 -0
- data/app/views/line_items/_line_item.html.erb +12 -0
- data/app/views/line_items/new.html.erb +11 -0
- data/app/views/notes/_form.html.erb +7 -0
- data/app/views/notes/_new.html.erb +14 -0
- data/app/views/notes/_note.html.erb +4 -0
- data/app/views/notes/index.html.erb +13 -0
- data/app/views/notes/new.html.erb +5 -0
- data/app/views/orders/_date_pickers.html.erb +15 -0
- data/app/views/orders/_order.html.erb +53 -0
- data/app/views/orders/index.html.erb +22 -0
- data/app/views/orders/show.html.erb +14 -0
- data/app/views/trolleys/_orders.html.erb +13 -0
- data/app/views/trolleys/show.html.erb +16 -0
- data/config/locales/en.yml +115 -0
- data/config/routes.rb +8 -0
- data/generators/trollied_migrations/USAGE +2 -0
- data/generators/trollied_migrations/templates/line_items_migration.rb +16 -0
- data/generators/trollied_migrations/templates/notes_migration.rb +15 -0
- data/generators/trollied_migrations/templates/orders_migration.rb +15 -0
- data/generators/trollied_migrations/templates/trolleys_migration.rb +14 -0
- data/generators/trollied_migrations/trollied_migrations_generator.rb +13 -0
- data/lib/gets_trollied.rb +38 -0
- data/lib/gets_trollied_controller_helpers.rb +29 -0
- data/lib/has_trolley.rb +42 -0
- data/lib/has_trolley_controller_helpers.rb +43 -0
- data/lib/order_status.rb +121 -0
- data/lib/trollied.rb +5 -0
- data/rails/init.rb +10 -0
- data/test/full_2_3_5_app_with_tests/.gitignore +27 -0
- data/test/full_2_3_5_app_with_tests/README +1 -0
- data/test/full_2_3_5_app_with_tests/Rakefile +10 -0
- data/test/full_2_3_5_app_with_tests/app/controllers/application_controller.rb +14 -0
- data/test/full_2_3_5_app_with_tests/app/controllers/items_controller.rb +85 -0
- data/test/full_2_3_5_app_with_tests/app/controllers/user_controller.rb +2 -0
- data/test/full_2_3_5_app_with_tests/app/helpers/application_helper.rb +3 -0
- data/test/full_2_3_5_app_with_tests/app/helpers/items_helper.rb +2 -0
- data/test/full_2_3_5_app_with_tests/app/helpers/user_helper.rb +2 -0
- data/test/full_2_3_5_app_with_tests/app/models/item.rb +4 -0
- data/test/full_2_3_5_app_with_tests/app/models/user.rb +3 -0
- data/test/full_2_3_5_app_with_tests/app/views/items/edit.html.erb +20 -0
- data/test/full_2_3_5_app_with_tests/app/views/items/index.html.erb +22 -0
- data/test/full_2_3_5_app_with_tests/app/views/items/new.html.erb +19 -0
- data/test/full_2_3_5_app_with_tests/app/views/items/show.html.erb +13 -0
- data/test/full_2_3_5_app_with_tests/app/views/layouts/application.html.erb +19 -0
- data/test/full_2_3_5_app_with_tests/app/views/layouts/items.html.erb +19 -0
- data/test/full_2_3_5_app_with_tests/config/boot.rb +110 -0
- data/test/full_2_3_5_app_with_tests/config/database.yml +22 -0
- data/test/full_2_3_5_app_with_tests/config/environment.rb +57 -0
- data/test/full_2_3_5_app_with_tests/config/environments/development.rb +17 -0
- data/test/full_2_3_5_app_with_tests/config/environments/production.rb +28 -0
- data/test/full_2_3_5_app_with_tests/config/environments/test.rb +28 -0
- data/test/full_2_3_5_app_with_tests/config/initializers/backtrace_silencers.rb +7 -0
- data/test/full_2_3_5_app_with_tests/config/initializers/inflections.rb +10 -0
- data/test/full_2_3_5_app_with_tests/config/initializers/mime_types.rb +5 -0
- data/test/full_2_3_5_app_with_tests/config/initializers/new_rails_defaults.rb +21 -0
- data/test/full_2_3_5_app_with_tests/config/initializers/session_store.rb +15 -0
- data/test/full_2_3_5_app_with_tests/config/locales/en.yml +4 -0
- data/test/full_2_3_5_app_with_tests/config/locales/fr.yml +4 -0
- data/test/full_2_3_5_app_with_tests/config/locales/zh.yml +4 -0
- data/test/full_2_3_5_app_with_tests/config/locales.yml +5 -0
- data/test/full_2_3_5_app_with_tests/config/routes.rb +8 -0
- data/test/full_2_3_5_app_with_tests/config.ru +6 -0
- data/test/full_2_3_5_app_with_tests/db/migrate/20100407010602_create_items.rb +13 -0
- data/test/full_2_3_5_app_with_tests/db/migrate/20110426030509_create_users.rb +13 -0
- data/test/full_2_3_5_app_with_tests/db/migrate/20110426033906_create_trolleys.rb +14 -0
- data/test/full_2_3_5_app_with_tests/db/migrate/20110426033907_create_orders.rb +15 -0
- data/test/full_2_3_5_app_with_tests/db/migrate/20110426033908_create_line_items.rb +16 -0
- data/test/full_2_3_5_app_with_tests/db/migrate/20110615234040_create_notes.rb +15 -0
- data/test/full_2_3_5_app_with_tests/db/schema.rb +56 -0
- data/test/full_2_3_5_app_with_tests/db/seeds.rb +7 -0
- data/test/full_2_3_5_app_with_tests/doc/README_FOR_APP +2 -0
- data/test/full_2_3_5_app_with_tests/public/404.html +30 -0
- data/test/full_2_3_5_app_with_tests/public/422.html +30 -0
- data/test/full_2_3_5_app_with_tests/public/500.html +30 -0
- data/test/full_2_3_5_app_with_tests/public/favicon.ico +0 -0
- data/test/full_2_3_5_app_with_tests/public/images/rails.png +0 -0
- data/test/full_2_3_5_app_with_tests/public/index.html +275 -0
- data/test/full_2_3_5_app_with_tests/public/javascripts/application.js +2 -0
- data/test/full_2_3_5_app_with_tests/public/javascripts/controls.js +963 -0
- data/test/full_2_3_5_app_with_tests/public/javascripts/dragdrop.js +973 -0
- data/test/full_2_3_5_app_with_tests/public/javascripts/effects.js +1128 -0
- data/test/full_2_3_5_app_with_tests/public/javascripts/prototype.js +4320 -0
- data/test/full_2_3_5_app_with_tests/public/robots.txt +5 -0
- data/test/full_2_3_5_app_with_tests/public/stylesheets/scaffold.css +54 -0
- data/test/full_2_3_5_app_with_tests/script/about +4 -0
- data/test/full_2_3_5_app_with_tests/script/console +3 -0
- data/test/full_2_3_5_app_with_tests/script/dbconsole +3 -0
- data/test/full_2_3_5_app_with_tests/script/destroy +3 -0
- data/test/full_2_3_5_app_with_tests/script/generate +3 -0
- data/test/full_2_3_5_app_with_tests/script/performance/benchmarker +3 -0
- data/test/full_2_3_5_app_with_tests/script/performance/profiler +3 -0
- data/test/full_2_3_5_app_with_tests/script/plugin +3 -0
- data/test/full_2_3_5_app_with_tests/script/runner +3 -0
- data/test/full_2_3_5_app_with_tests/script/server +3 -0
- data/test/full_2_3_5_app_with_tests/test/factories.rb +22 -0
- data/test/full_2_3_5_app_with_tests/test/functional/line_items_controller_test.rb +69 -0
- data/test/full_2_3_5_app_with_tests/test/functional/orders_controller_test.rb +75 -0
- data/test/full_2_3_5_app_with_tests/test/integration/gets_trollied_test.rb +38 -0
- data/test/full_2_3_5_app_with_tests/test/integration/order_test.rb +79 -0
- data/test/full_2_3_5_app_with_tests/test/integration/trolley_test.rb +71 -0
- data/test/full_2_3_5_app_with_tests/test/performance/browsing_test.rb +9 -0
- data/test/full_2_3_5_app_with_tests/test/selenium.rb +83 -0
- data/test/full_2_3_5_app_with_tests/test/test_helper.rb +54 -0
- data/test/full_2_3_5_app_with_tests/test/unit/gets_trollied_test.rb +29 -0
- data/test/full_2_3_5_app_with_tests/test/unit/helpers/gets_trollied_helper_test.rb +75 -0
- data/test/full_2_3_5_app_with_tests/test/unit/helpers/orders_helper_test.rb +34 -0
- data/test/full_2_3_5_app_with_tests/test/unit/line_item_test.rb +28 -0
- data/test/full_2_3_5_app_with_tests/test/unit/note_test.rb +14 -0
- data/test/full_2_3_5_app_with_tests/test/unit/order_test.rb +65 -0
- data/test/full_2_3_5_app_with_tests/test/unit/trolley_test.rb +80 -0
- data/test/full_2_3_5_app_with_tests/tmp/restart.txt +0 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/init.rb +1 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/base.rb +31 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/force_extension.rb +57 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/locale.rb +70 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/pagination.rb +33 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter/uuid_token.rb +78 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/lib/routing_filter.rb +94 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/force_extension_spec.rb +65 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/generation_spec.rb +367 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/pagination_extension_spec.rb +19 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/recognition_spec.rb +76 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/routing_filter_spec.rb +114 -0
- data/test/full_2_3_5_app_with_tests/vendor/plugins/routing-filter/spec/spec_helper.rb +108 -0
- data/test/helper.rb +10 -0
- metadata +345 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
|
2
|
+
|
|
3
|
+
body, p, ol, ul, td {
|
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 18px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
pre {
|
|
10
|
+
background-color: #eee;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a { color: #000; }
|
|
16
|
+
a:visited { color: #666; }
|
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
|
18
|
+
|
|
19
|
+
.fieldWithErrors {
|
|
20
|
+
padding: 2px;
|
|
21
|
+
background-color: red;
|
|
22
|
+
display: table;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#errorExplanation {
|
|
26
|
+
width: 400px;
|
|
27
|
+
border: 2px solid red;
|
|
28
|
+
padding: 7px;
|
|
29
|
+
padding-bottom: 12px;
|
|
30
|
+
margin-bottom: 20px;
|
|
31
|
+
background-color: #f0f0f0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#errorExplanation h2 {
|
|
35
|
+
text-align: left;
|
|
36
|
+
font-weight: bold;
|
|
37
|
+
padding: 5px 5px 5px 15px;
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
margin: -7px;
|
|
40
|
+
background-color: #c00;
|
|
41
|
+
color: #fff;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#errorExplanation p {
|
|
45
|
+
color: #333;
|
|
46
|
+
margin-bottom: 0;
|
|
47
|
+
padding: 5px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#errorExplanation ul li {
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
list-style: square;
|
|
53
|
+
}
|
|
54
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Factory.define :item do |f|
|
|
2
|
+
f.sequence(:label) { |n| "a label#{n}"}
|
|
3
|
+
f.sequence(:value) { |n| "a value#{n}"}
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Factory.define :user do |f|
|
|
7
|
+
f.name "Frisky Fitzpatrick"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Factory.define :trolley do |f|
|
|
11
|
+
f.association :user
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Factory.define :order do |f|
|
|
15
|
+
f.association :trolley
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Factory.define :note do |f|
|
|
19
|
+
f.body "a test body"
|
|
20
|
+
f.association :order
|
|
21
|
+
f.association :user
|
|
22
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
class LineItemsControllerTest < ActionController::TestCase
|
|
5
|
+
context "The line_items controller" do
|
|
6
|
+
setup do
|
|
7
|
+
@item = Factory.create(:item)
|
|
8
|
+
@user = Factory.create(:user)
|
|
9
|
+
@trolley = @user.trolley
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
should "get index" do
|
|
13
|
+
get :index, :item_id => @item.id
|
|
14
|
+
assert_response :success
|
|
15
|
+
assert_not_nil assigns(:line_items)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "get new" do
|
|
19
|
+
get :new, :item_id => @item.id
|
|
20
|
+
assert_response :success
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should "create line_item" do
|
|
24
|
+
assert_difference('LineItem.count') do
|
|
25
|
+
post :create, :line_item => {}, :item_id => @item.id, :user => @user.id
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
assert_redirected_to :controller => 'trolleys', :action => 'show', :user_id => @user.id
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "when there is an existing line_item" do
|
|
32
|
+
setup do
|
|
33
|
+
@order = @user.correct_order(@item)
|
|
34
|
+
|
|
35
|
+
@line_item_1 = @item.line_items.create(:order => @order)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
should "get index with a line_item" do
|
|
39
|
+
get :index, :item_id => @item.id
|
|
40
|
+
assert assigns(:line_items).size == 1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
should "show line_item" do
|
|
44
|
+
get :show, :id => @line_item_1.id, :item_id => @item.id
|
|
45
|
+
assert_response :success
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
should "get edit" do
|
|
49
|
+
get :edit, :id => @line_item_1.id, :item_id => @item.id
|
|
50
|
+
assert_response :success
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
should "update line_item" do
|
|
54
|
+
put :update, :id => @line_item_1.id, :item_id => @item.id, :line_item => { :order => Factory.create(:order) }
|
|
55
|
+
assert_redirected_to :controller => 'trolleys', :action => 'show', :user_id => @user.id
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
should "destroy line_item" do
|
|
59
|
+
assert_difference('LineItem.count', -1) do
|
|
60
|
+
delete :destroy, :order_id => @order.id, :id => @line_item_1.id
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
assert_redirected_to :action => 'index', :order_id => @order.id
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
class OrdersControllerTest < ActionController::TestCase
|
|
5
|
+
context "The orders controller" do
|
|
6
|
+
setup do
|
|
7
|
+
@item = Factory.create(:item)
|
|
8
|
+
@user = Factory.create(:user)
|
|
9
|
+
@trolley = @user.trolley
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
should "get index" do
|
|
13
|
+
get :index, :trolley_id => @trolley.id, :user_id => @user.id
|
|
14
|
+
assert_response :success
|
|
15
|
+
assert_not_nil assigns(:orders)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "get new" do
|
|
19
|
+
get :new, :trolley_id => @trolley.id, :user_id => @user.id
|
|
20
|
+
assert_response :success
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should "create order" do
|
|
24
|
+
assert_difference('Order.count') do
|
|
25
|
+
post :create, :order => {}, :user_id => @user.id
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
assert_redirected_to :controller => 'trolleys', :action => 'show', :user_id => @user.id
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "when there is an existing order" do
|
|
32
|
+
setup do
|
|
33
|
+
@order = @user.correct_order(@item)
|
|
34
|
+
|
|
35
|
+
@line_item_1 = @item.line_items.create(:order => @order)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
should "be able to checkout order" do
|
|
39
|
+
post :checkout, :id => @order.id, :trolley_id => @order.trolley.id
|
|
40
|
+
|
|
41
|
+
assert_redirected_to :controller => 'trolleys', :action => 'show', :user_id => @user.id
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# should "get index with a order" do
|
|
45
|
+
# get :index, :trolley_id => @trolley.id, :user_id => @user.id
|
|
46
|
+
# assert assigns(:orders).size == 1
|
|
47
|
+
# end
|
|
48
|
+
|
|
49
|
+
# should "show order" do
|
|
50
|
+
# get :show, :id => @order.id
|
|
51
|
+
# assert_response :success
|
|
52
|
+
# end
|
|
53
|
+
|
|
54
|
+
# should "get edit" do
|
|
55
|
+
# get :edit, :id => @order.id
|
|
56
|
+
# assert_response :success
|
|
57
|
+
# end
|
|
58
|
+
|
|
59
|
+
# should "update order" do
|
|
60
|
+
# put :update, :id => @order.id, :order => { :order => Factory.create(:order) }
|
|
61
|
+
# assert_redirected_to :controller => 'trolleys', :action => 'show', :user_id => @user.id
|
|
62
|
+
# end
|
|
63
|
+
|
|
64
|
+
# should "destroy order" do
|
|
65
|
+
# assert_difference('Order.count', -1) do
|
|
66
|
+
# delete :destroy, :id => @order_1.id
|
|
67
|
+
# end
|
|
68
|
+
|
|
69
|
+
# assert_redirected_to :controller => 'trolleys', :action => 'show', :user_id => @user.id
|
|
70
|
+
# end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
Webrat.configure do |config|
|
|
5
|
+
config.mode = :rails
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class TrolliedTest < ActionController::IntegrationTest
|
|
9
|
+
context "A gets_trollied object" do
|
|
10
|
+
include Webrat::HaveTagMatcher
|
|
11
|
+
setup do
|
|
12
|
+
@item = Factory.create(:item)
|
|
13
|
+
@user = Factory.create(:user)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
should "have an add to cart link on its show page" do
|
|
17
|
+
visit "/items/#{@item.id}"
|
|
18
|
+
assert_have_tag "input", :type => "submit", :value => I18n.t('gets_trollied_helper.add_to_trolley')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
should "be able to submit add to trolley request and be added to trolley" do
|
|
22
|
+
visit "/items/#{@item.id}"
|
|
23
|
+
click_button "add to cart"
|
|
24
|
+
assert_have_tag "title", :content => I18n.t('trolleys.show.your_title')
|
|
25
|
+
assert_have_tag "a", :href => "/items/#{@item.id}", :content => @item.description_for_purchasing
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# if an item has been placed in trolley previously, the add to trolley is replaced with link to trolley, and status of item shown
|
|
29
|
+
should "after being added to a trolley, the object on its show page report that it is in the trolley, rather than providing the button to add to trolley" do
|
|
30
|
+
@trolley = @user.trolley
|
|
31
|
+
@trolley.add(@item)
|
|
32
|
+
|
|
33
|
+
visit "/items/#{@item.id}"
|
|
34
|
+
assert_have_tag "div", :content => I18n.t('gets_trollied_helper.in_trolley')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
Webrat.configure do |config|
|
|
5
|
+
config.mode = :rails
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class OrderTest < ActionController::IntegrationTest
|
|
9
|
+
include Webrat::HaveTagMatcher
|
|
10
|
+
|
|
11
|
+
context "The orders index page" do
|
|
12
|
+
|
|
13
|
+
context "when there are no orders on the site" do
|
|
14
|
+
|
|
15
|
+
should "return message that there are currently no orders" do
|
|
16
|
+
visit "/orders"
|
|
17
|
+
assert_have_tag "p", :content => I18n.t('orders.index.no_orders')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "when there are orders" do
|
|
22
|
+
setup do
|
|
23
|
+
@item = Factory.create(:item)
|
|
24
|
+
@order = Factory.create(:order)
|
|
25
|
+
@item.place_in(@order.trolley)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "that are current" do
|
|
29
|
+
|
|
30
|
+
should "return message that there are no orders unless state = current" do
|
|
31
|
+
visit "/orders"
|
|
32
|
+
assert_have_tag "p", :content => I18n.t('orders.index.no_orders')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
should "have link to view current orders" do
|
|
36
|
+
visit "/orders"
|
|
37
|
+
assert_have_tag "a", :content => I18n.t('orders.index.current')
|
|
38
|
+
|
|
39
|
+
click_link I18n.t('orders.index.current')
|
|
40
|
+
|
|
41
|
+
assert_have_tag "a", :content => @item.description_for_purchasing
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "that are in_process" do
|
|
46
|
+
setup do
|
|
47
|
+
@order.checkout!
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
should "indicate that there are in_process orders and display them" do
|
|
51
|
+
visit "/orders"
|
|
52
|
+
assert_have_tag "li", :content => I18n.t('orders.index.in_process')
|
|
53
|
+
assert_have_tag "a", :content => @item.description_for_purchasing
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "when a trolley is given" do
|
|
60
|
+
setup do
|
|
61
|
+
@trolley = Factory.create(:trolley)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context "when there are no orders in the trolley" do
|
|
65
|
+
|
|
66
|
+
should "return message that there are currently no orders" do
|
|
67
|
+
visit "/orders?trolley_id=#{@trolley.id}"
|
|
68
|
+
assert_have_tag "p", :content => I18n.t('orders.index.no_orders')
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context "when there are orders" do
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
Webrat.configure do |config|
|
|
5
|
+
config.mode = :rails
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class TrolleyTest < ActionController::IntegrationTest
|
|
9
|
+
context "A trolley" do
|
|
10
|
+
include Webrat::HaveTagMatcher
|
|
11
|
+
setup do
|
|
12
|
+
@item = Factory.create(:item)
|
|
13
|
+
@user = Factory.create(:user)
|
|
14
|
+
@trolley = @user.trolley
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "when there are line items in a current order" do
|
|
18
|
+
setup do
|
|
19
|
+
@item.place_in(@trolley)
|
|
20
|
+
@order = @trolley.selected_order
|
|
21
|
+
@line_item = @order.line_items.first
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "lists a current order and" do
|
|
25
|
+
|
|
26
|
+
should "have the line item listed" do
|
|
27
|
+
visit "/user/#{@user.id}/trolley"
|
|
28
|
+
assert_have_tag "a", :href => "/items/#{@item.id}", :content => @item.description_for_purchasing
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
should "have a drop line item link for line item" do
|
|
32
|
+
visit "/user/#{@user.id}/trolley"
|
|
33
|
+
click_link "Delete"
|
|
34
|
+
# assert that we are redirected back to trolley
|
|
35
|
+
assert_have_tag "title", :content => I18n.t('trolleys.show.your_title')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
should "have a clear all button" do
|
|
39
|
+
visit "/user/#{@user.id}/trolley"
|
|
40
|
+
assert_have_tag "input", :type => "submit", :value => I18n.t('orders.order.destroy')
|
|
41
|
+
|
|
42
|
+
click_button I18n.t('orders.order.destroy')
|
|
43
|
+
|
|
44
|
+
assert_have_tag "p", :content => I18n.t('trolleys.orders.none_pending')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
should "have a checkout button that moves the order out of current status" do
|
|
48
|
+
visit "/user/#{@user.id}/trolley"
|
|
49
|
+
assert_have_tag "input", :type => "submit", :value => I18n.t('orders.order.checkout')
|
|
50
|
+
|
|
51
|
+
click_button I18n.t('orders.order.checkout')
|
|
52
|
+
|
|
53
|
+
assert_have_tag "p", :content => I18n.t('trolleys.orders.none_pending')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
should "have a cancel button that moves the order out of current status and marks it as cancelled" do
|
|
57
|
+
@order.checkout!
|
|
58
|
+
|
|
59
|
+
visit "/user/#{@user.id}/trolley"
|
|
60
|
+
assert_have_tag "input", :type => "submit", :value => I18n.t('orders.order.cancel')
|
|
61
|
+
|
|
62
|
+
click_button I18n.t('orders.order.cancel')
|
|
63
|
+
|
|
64
|
+
# cancelled orders are not listed on trolley
|
|
65
|
+
# assert_have_tag "h2", :content => I18n.t('orders.order.cancelled')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
# This file is not in integration/ because when run with
|
|
5
|
+
# 'rake', it causes segfaults in the test suite
|
|
6
|
+
|
|
7
|
+
# ATTN: Before runnings these tests, be sure to turn
|
|
8
|
+
# off all extensions and popup blockers in Safari
|
|
9
|
+
|
|
10
|
+
class ActiveSupport::TestCase
|
|
11
|
+
self.use_transactional_fixtures = true
|
|
12
|
+
setup do |session|
|
|
13
|
+
session.host! "localhost:3001"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Webrat.configure do |config|
|
|
18
|
+
config.mode = :selenium
|
|
19
|
+
config.application_environment = :test
|
|
20
|
+
config.selenium_browser_key = '*safari'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class SeleniumTest < ActionController::IntegrationTest
|
|
24
|
+
context "Using Selenium to test javascript functionality" do
|
|
25
|
+
|
|
26
|
+
# DEBUG: This works so if the others don't, try just this one
|
|
27
|
+
# should "be able to visit the homepage" do
|
|
28
|
+
# visit "/"
|
|
29
|
+
# assert_contain "Welcome aboard"
|
|
30
|
+
# end
|
|
31
|
+
|
|
32
|
+
should "be able to translate an item via AJAX" do
|
|
33
|
+
item = create_item
|
|
34
|
+
click_link "Français"
|
|
35
|
+
assert current_url =~ /\/en\/items\/#{item.id}$/
|
|
36
|
+
assert_contain "Translate from English to Français"
|
|
37
|
+
fill_in 'item_translation_label', :with => 'Certains Point'
|
|
38
|
+
click_button 'Create'
|
|
39
|
+
assert_contain 'Translation was successfully created.'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
should "be able to switch translations" do
|
|
43
|
+
item = create_item
|
|
44
|
+
click_link "Français"
|
|
45
|
+
assert current_url =~ /\/en\/items\/#{item.id}$/
|
|
46
|
+
assert_contain "Translate from English to Français"
|
|
47
|
+
click_link "Suomi"
|
|
48
|
+
assert current_url =~ /\/en\/items\/#{item.id}$/
|
|
49
|
+
assert_contain "Translate from English to Suomi"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
should "be able to close the translations box" do
|
|
53
|
+
item = create_item
|
|
54
|
+
click_link "Français"
|
|
55
|
+
click_link "[close]"
|
|
56
|
+
assert_not_contain "Translate from English to Français"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
should "be able to use the auto translate functionality" do
|
|
60
|
+
item = create_item
|
|
61
|
+
visit "/en/items/#{item.id}/translations/new?to_locale=fr"
|
|
62
|
+
click_link '[auto translate]'
|
|
63
|
+
sleep 1 # ugly way to wait for google to do it's thing
|
|
64
|
+
click_button 'Create'
|
|
65
|
+
assert_contain 'Translation was successfully created.'
|
|
66
|
+
assert_contain 'Certains Point'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def create_item
|
|
74
|
+
visit "/en/items"
|
|
75
|
+
click_link "New item"
|
|
76
|
+
fill_in 'item_label', :with => 'Some Item'
|
|
77
|
+
fill_in 'item_value', :with => '$3.50'
|
|
78
|
+
fill_in 'item_locale', :with => 'en'
|
|
79
|
+
click_button 'Create'
|
|
80
|
+
assert_contain 'Item was successfully created.'
|
|
81
|
+
Item.last
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
|
4
|
+
require 'test_help'
|
|
5
|
+
require 'rubygems'
|
|
6
|
+
require 'shoulda'
|
|
7
|
+
require 'factory_girl'
|
|
8
|
+
require "webrat"
|
|
9
|
+
|
|
10
|
+
require File.expand_path(File.dirname(__FILE__) + "/factories")
|
|
11
|
+
|
|
12
|
+
Webrat.configure do |config|
|
|
13
|
+
config.mode = :rails
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class ActiveSupport::TestCase
|
|
17
|
+
# Transactional fixtures accelerate your tests by wrapping each test method
|
|
18
|
+
# in a transaction that's rolled back on completion. This ensures that the
|
|
19
|
+
# test database remains unchanged so your fixtures don't have to be reloaded
|
|
20
|
+
# between every test method. Fewer database queries means faster tests.
|
|
21
|
+
#
|
|
22
|
+
# Read Mike Clark's excellent walkthrough at
|
|
23
|
+
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
|
24
|
+
#
|
|
25
|
+
# Every Active Record database supports transactions except MyISAM tables
|
|
26
|
+
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
|
27
|
+
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
|
28
|
+
# is recommended.
|
|
29
|
+
#
|
|
30
|
+
# The only drawback to using transactional fixtures is when you actually
|
|
31
|
+
# need to test transactions. Since your test is bracketed by a transaction,
|
|
32
|
+
# any transactions started in your code will be automatically rolled back.
|
|
33
|
+
# self.use_transactional_fixtures = true
|
|
34
|
+
|
|
35
|
+
# Instantiated fixtures are slow, but give you @david where otherwise you
|
|
36
|
+
# would need people(:david). If you don't want to migrate your existing
|
|
37
|
+
# test cases which use the @david style and don't mind the speed hit (each
|
|
38
|
+
# instantiated fixtures translates to a database query per test method),
|
|
39
|
+
# then set this back to true.
|
|
40
|
+
# self.use_instantiated_fixtures = false
|
|
41
|
+
|
|
42
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
43
|
+
#
|
|
44
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
45
|
+
# -- they do not yet inherit this setting
|
|
46
|
+
# fixtures :all
|
|
47
|
+
|
|
48
|
+
# Add more helper methods to be used by all tests here...
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def assert_purchasable_item_matches
|
|
52
|
+
assert @order.line_items.size == 1
|
|
53
|
+
assert_equal @item, @order.line_items.first.purchasable_item
|
|
54
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
|
|
4
|
+
class GetsTrolliedTest < ActiveSupport::TestCase
|
|
5
|
+
context "A model that can be trollied" do
|
|
6
|
+
setup do
|
|
7
|
+
@item = Factory.create(:item)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
should "be able to be added to a trolley" do
|
|
11
|
+
@trolley = Factory.create(:trolley)
|
|
12
|
+
@item.place_in(@trolley)
|
|
13
|
+
|
|
14
|
+
assert @trolley.selected_order
|
|
15
|
+
|
|
16
|
+
@order = @trolley.selected_order
|
|
17
|
+
|
|
18
|
+
assert_purchasable_item_matches
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
should "answer description_for_purchasing" do
|
|
22
|
+
assert_respond_to @item, :description_for_purchasing
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
should "return mapped attribute value from description_for_purchasing" do
|
|
26
|
+
assert_equal @item.label, @item.description_for_purchasing
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|