mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Starting to get in the login stuff
This commit is contained in:
14
app/views/shop/checkout/_login.html.haml
Normal file
14
app/views/shop/checkout/_login.html.haml
Normal file
@@ -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"
|
||||
13
app/views/shop/checkout/_signup.html.haml
Normal file
13
app/views/shop/checkout/_signup.html.haml
Normal file
@@ -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'
|
||||
@@ -0,0 +1,3 @@
|
||||
- unless spree_current_user
|
||||
= render partial: "shop/checkout/login"
|
||||
= render partial: "shop/checkout/signup"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user