diff --git a/app/views/admin/enterprises/form/_shop_preferences.html.haml b/app/views/admin/enterprises/form/_shop_preferences.html.haml index c78efa2ac6..55d3777555 100644 --- a/app/views/admin/enterprises/form/_shop_preferences.html.haml +++ b/app/views/admin/enterprises/form/_shop_preferences.html.haml @@ -45,3 +45,15 @@ .five.columns.omega = f.radio_button :require_login, true = f.label :require_login, t('.shopfront_requires_login_true'), value: :true +.row + .alpha.eleven.columns + .three.columns.alpha + %label= t '.allow_guest_orders' + %div{'ofn-with-tip' => t('.allow_guest_orders_tip')} + %a= t 'admin.whats_this' + .three.columns + = f.radio_button :allow_guest_orders, false + = f.label :allow_guest_orders, t('.allow_guest_orders_false'), value: :false + .five.columns.omega + = f.radio_button :allow_guest_orders, true + = f.label :allow_guest_orders, t('.allow_guest_orders_true'), value: :true diff --git a/config/locales/en.yml b/config/locales/en.yml index f60f91ad96..808f36c533 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -201,6 +201,10 @@ en: shopfront_requires_login_tip: "Choose whether customers must login to view the shopfront." shopfront_requires_login_false: "Public" shopfront_requires_login_true: "Require customers to login" + allow_guest_orders: "Guest orders" + allow_guest_orders_tip: "Allow checkout as guest or require a registered user." + allow_guest_orders_false: "Require login to order" + allow_guest_orders_true: "Allow checkout as guest" home: hubs: diff --git a/db/migrate/20160921060442_add_allow_guest_orders_to_enterprise.rb b/db/migrate/20160921060442_add_allow_guest_orders_to_enterprise.rb new file mode 100644 index 0000000000..7e92c7e74c --- /dev/null +++ b/db/migrate/20160921060442_add_allow_guest_orders_to_enterprise.rb @@ -0,0 +1,5 @@ +class AddAllowGuestOrdersToEnterprise < ActiveRecord::Migration + def change + add_column :enterprises, :allow_guest_orders, :boolean, default: true, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 48b07e3cdb..64bfd0df69 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160819065331) do +ActiveRecord::Schema.define(:version => 20160921060442) do create_table "account_invoices", :force => true do |t| t.integer "user_id", :null => false @@ -248,6 +248,7 @@ ActiveRecord::Schema.define(:version => 20160819065331) do t.boolean "charges_sales_tax", :default => false, :null => false t.string "email_address" t.boolean "require_login", :default => false, :null => false + t.boolean "allow_guest_orders", :default => true, :null => false end add_index "enterprises", ["address_id"], :name => "index_enterprises_on_address_id" diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index 7ea8810d5d..27c04316ca 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -90,6 +90,10 @@ feature %q{ expect(page).to have_checked_field "enterprise_require_login_false" choose "Require customers to login" + # Require login for checkout + expect(page).to have_checked_field "enterprise_allow_guest_orders_true" + choose "Require login to order" + within (".side_menu") { click_link "Users" } select2_search user.email, from: 'Owner' @@ -191,6 +195,7 @@ feature %q{ page.should have_content 'This is my shopfront message.' page.should have_checked_field "enterprise_preferred_shopfront_order_cycle_order_orders_open_at" expect(page).to have_checked_field "enterprise_require_login_true" + expect(page).to have_checked_field "enterprise_allow_guest_orders_false" end describe "producer properties" do