From e20b06bb9776d406a5ca14f443b04931e9074af7 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 14 Oct 2015 10:30:22 +1100 Subject: [PATCH] Adding basic route and controller for business model configuration --- ...business_model_configuration_controller.rb | 3 +++ config/routes.rb | 2 ++ ...ess_model_configuration_controller_spec.rb | 26 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 app/controllers/admin/business_model_configuration_controller.rb create mode 100644 spec/controllers/admin/business_model_configuration_controller_spec.rb diff --git a/app/controllers/admin/business_model_configuration_controller.rb b/app/controllers/admin/business_model_configuration_controller.rb new file mode 100644 index 0000000000..0ac2a00eb7 --- /dev/null +++ b/app/controllers/admin/business_model_configuration_controller.rb @@ -0,0 +1,3 @@ +class Admin::BusinessModelConfigurationController < Spree::Admin::BaseController + +end diff --git a/config/routes.rb b/config/routes.rb index eb8c228b91..902855db2a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -116,6 +116,8 @@ Openfoodnetwork::Application.routes.draw do end end + resource :business_model_configuration, only: [:edit] + resource :account, only: [:show], controller: 'account' end diff --git a/spec/controllers/admin/business_model_configuration_controller_spec.rb b/spec/controllers/admin/business_model_configuration_controller_spec.rb new file mode 100644 index 0000000000..df80bce9e6 --- /dev/null +++ b/spec/controllers/admin/business_model_configuration_controller_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Admin::AccountsAndBillingSettingsController, type: :controller do + let(:user) { create(:user) } + let(:admin) { create(:admin_user) } + + describe "edit" do + context "as an enterprise user" do + before { allow(controller).to receive(:spree_current_user) { user } } + + it "does not allow access" do + spree_get :edit + expect(response).to redirect_to spree.unauthorized_path + end + end + + context "as super admin" do + before { allow(controller).to receive(:spree_current_user) { admin } } + + it "allows access" do + spree_get :edit + expect(response).to_not redirect_to spree.unauthorized_path + end + end + end +end