mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-15 04:14:24 +00:00
Adding ze boilerplate
This commit is contained in:
3
app/assets/javascripts/shop/checkout.js.coffee
Normal file
3
app/assets/javascripts/shop/checkout.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
3
app/assets/stylesheets/shop/checkout.css.scss
Normal file
3
app/assets/stylesheets/shop/checkout.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Shop::Checkout controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
24
app/controllers/shop/checkout_controller.rb
Normal file
24
app/controllers/shop/checkout_controller.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
class Shop::CheckoutController < BaseController
|
||||
layout 'darkswarm'
|
||||
|
||||
before_filter :set_distributor
|
||||
before_filter :require_order_cycle
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_distributor
|
||||
unless @distributor = current_distributor
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def require_order_cycle
|
||||
unless current_order_cycle
|
||||
redirect_to shop_path
|
||||
end
|
||||
end
|
||||
end
|
||||
2
app/helpers/shop/checkout_helper.rb
Normal file
2
app/helpers/shop/checkout_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Shop::CheckoutHelper
|
||||
end
|
||||
0
app/views/shop/checkout/new.html.haml
Normal file
0
app/views/shop/checkout/new.html.haml
Normal file
21
spec/controllers/shop/checkout_controller_spec.rb
Normal file
21
spec/controllers/shop/checkout_controller_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Shop::CheckoutController do
|
||||
it "redirects home when no distributor is selected" do
|
||||
get :new
|
||||
response.should redirect_to root_path
|
||||
end
|
||||
|
||||
it "redirects to the shop when no order cycle is selected" do
|
||||
controller.stub(:current_distributor).and_return(double(:distributor))
|
||||
get :new
|
||||
response.should redirect_to shop_path
|
||||
end
|
||||
|
||||
it "renders when both distributor and order cycle is selected" do
|
||||
controller.stub(:current_distributor).and_return(double(:distributor))
|
||||
controller.stub(:order_cycle).and_return(double(:order_cycle))
|
||||
get :new
|
||||
response.should be_success
|
||||
end
|
||||
end
|
||||
45
spec/features/consumer/shopping/checkout_spec.rb
Normal file
45
spec/features/consumer/shopping/checkout_spec.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
require 'spec_helper'
|
||||
|
||||
include AuthenticationWorkflow
|
||||
include WebHelper
|
||||
|
||||
feature "As a consumer I want to check out my cart", js: true do
|
||||
describe "Attempting to access checkout without meeting the preconditions" do
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
let(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) }
|
||||
|
||||
before do
|
||||
create_enterprise_group_for distributor
|
||||
end
|
||||
|
||||
it "redirects to the homepage if no distributor is selected" do
|
||||
visit "/shop/checkout"
|
||||
current_path.should == root_path
|
||||
end
|
||||
|
||||
it "redirects to the shop page if we have a distributor but no order cycle selected" do
|
||||
select_distributor
|
||||
visit "/shop/checkout"
|
||||
current_path.should == shop_path
|
||||
end
|
||||
|
||||
|
||||
it "renders checkout if we have distributor and order cycle selected" do
|
||||
select_distributor
|
||||
select_order_cycle
|
||||
visit "/shop/checkout"
|
||||
current_path.should == "/shop/checkout"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def select_distributor
|
||||
visit "/"
|
||||
click_link distributor.name
|
||||
end
|
||||
|
||||
def select_order_cycle
|
||||
exchange = Exchange.find(order_cycle.exchanges.to_enterprises(distributor).outgoing.first.id)
|
||||
visit "/shop"
|
||||
select exchange.pickup_time, from: "order_cycle_id"
|
||||
end
|
||||
15
spec/helpers/shop/checkout_helper_spec.rb
Normal file
15
spec/helpers/shop/checkout_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Shop::CheckoutHelper. For example:
|
||||
#
|
||||
# describe Shop::CheckoutHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe Shop::CheckoutHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user