diff --git a/app/views/shop/checkout/_login.html.haml b/app/views/shop/checkout/_login.html.haml
new file mode 100644
index 0000000000..7e5170805f
--- /dev/null
+++ b/app/views/shop/checkout/_login.html.haml
@@ -0,0 +1,14 @@
+%h2 Login
+
+= form_for Spree::User.new, :remote => true, :html => {'data-type' => :json}, :as => :spree_user, :url => spree.spree_user_session_path do |f|
+ %p
+ = f.label :email, t(:email)
+ = f.email_field :email, :class => 'title', :tabindex => 1, :id => "login_spree_user_email"
+ %p
+ = f.label :password, t(:password)
+ = f.password_field :password, :class => 'title', :tabindex => 2, :id => "login_spree_user_password"
+ %p
+ %label
+ = f.check_box :remember_me
+ = f.label :remember_me, t(:remember_me)
+ %p= f.submit t(:login), :class => 'button primary', :tabindex => 3, :id => "login_spree_user_remember_me"
diff --git a/app/views/shop/checkout/_signup.html.haml b/app/views/shop/checkout/_signup.html.haml
new file mode 100644
index 0000000000..449abeb892
--- /dev/null
+++ b/app/views/shop/checkout/_signup.html.haml
@@ -0,0 +1,13 @@
+%h2 Sign Up
+= form_for Spree::User.new, :as => :spree_user, :url => spree.spree_user_registration_path(@spree_user) do |f|
+ %p
+ = f.label :email, t(:email)
+ = f.email_field :email, :class => 'title', :id => "signup_spree_user_email"
+ %p
+ = f.label :password, t(:password)
+ = f.password_field :password, :class => 'title', :id => "signup_spree_user_password"
+ %p
+ = f.label :password_confirmation, t(:confirm_password)
+ = f.password_field :password_confirmation, :class => 'title', :id => "signup_spree_user_password_confirmation"
+
+ = f.submit t(:create), :class => 'button'
diff --git a/app/views/shop/checkout/new.html.haml b/app/views/shop/checkout/new.html.haml
index e69de29bb2..7081ab3b7c 100644
--- a/app/views/shop/checkout/new.html.haml
+++ b/app/views/shop/checkout/new.html.haml
@@ -0,0 +1,3 @@
+- unless spree_current_user
+ = render partial: "shop/checkout/login"
+ = render partial: "shop/checkout/signup"
diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb
index 3c328ca8b1..0800691fda 100644
--- a/spec/features/consumer/shopping/checkout_spec.rb
+++ b/spec/features/consumer/shopping/checkout_spec.rb
@@ -4,14 +4,14 @@ include AuthenticationWorkflow
include WebHelper
feature "As a consumer I want to check out my cart", js: true 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
+
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
@@ -31,6 +31,43 @@ feature "As a consumer I want to check out my cart", js: true do
current_path.should == "/shop/checkout"
end
end
+
+ describe "Login behaviour" do
+ before do
+ select_distributor
+ select_order_cycle
+ end
+
+ it "renders the login form if user is logged out" do
+ visit "/shop/checkout"
+ within "section[role='main']" do
+ page.should have_content "Login"
+ end
+ end
+
+ it "does not not render the login form if user is logged in" do
+ login_to_consumer_section
+ visit "/shop/checkout"
+ within "section[role='main']" do
+ page.should_not have_content "Login"
+ end
+ end
+
+ it "renders the signup link if user is logged out" do
+ visit "/shop/checkout"
+ within "section[role='main']" do
+ page.should have_content "Sign Up"
+ end
+ end
+
+ it "does not not render the signup form if user is logged in" do
+ login_to_consumer_section
+ visit "/shop/checkout"
+ within "section[role='main']" do
+ page.should_not have_content "Sign Up"
+ end
+ end
+ end
end
def select_distributor