From 030730b4a6714454bf05c5c7e768c14d2df23202 Mon Sep 17 00:00:00 2001 From: Hugo Daniel Date: Wed, 12 Sep 2018 09:54:24 +0200 Subject: [PATCH] Enable setting a customized user guide link in general settings for admin --- .../general_settings_controller_decorator.rb | 1 + .../spree/app_configuration_decorator.rb | 3 +++ .../admin/shared/_user_guide_link.html.haml | 2 +- config/locales/en.yml | 3 ++- spec/features/admin/general_settings_spec.rb | 22 +++++++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 spec/features/admin/general_settings_spec.rb diff --git a/app/controllers/spree/admin/general_settings_controller_decorator.rb b/app/controllers/spree/admin/general_settings_controller_decorator.rb index 603f74bf6325..2eca8a62eef2 100644 --- a/app/controllers/spree/admin/general_settings_controller_decorator.rb +++ b/app/controllers/spree/admin/general_settings_controller_decorator.rb @@ -8,6 +8,7 @@ module GeneralSettingsEditPreferences def edit super @preferences_general << :bugherd_api_key + @preferences_general << :user_guide_link end end GeneralSettingsController.send(:prepend, GeneralSettingsEditPreferences) diff --git a/app/models/spree/app_configuration_decorator.rb b/app/models/spree/app_configuration_decorator.rb index 992c39abe11c..5c30ee5578ba 100644 --- a/app/models/spree/app_configuration_decorator.rb +++ b/app/models/spree/app_configuration_decorator.rb @@ -4,6 +4,9 @@ # we can allow to be modified in the UI by adding appropriate form # elements to existing or new configuration pages. + # General Preferences + preference :user_guide_link, :string, default: nil + # Embedded Shopfronts preference :enable_embedded_shopfronts, :boolean, default: false preference :embedded_shopfronts_whitelist, :text, default: nil diff --git a/app/views/admin/shared/_user_guide_link.html.haml b/app/views/admin/shared/_user_guide_link.html.haml index cd1b0dba8642..65efbf63be39 100644 --- a/app/views/admin/shared/_user_guide_link.html.haml +++ b/app/views/admin/shared/_user_guide_link.html.haml @@ -1 +1 @@ -= button_link_to t('.user_guide'), "http://www.openfoodnetwork.org/platform/user-guide/", icon: 'icon-external-link', target: '_blank' += button_link_to t('.user_guide'), Spree::Config.user_guide_link, icon: 'icon-external-link', target: '_blank' diff --git a/config/locales/en.yml b/config/locales/en.yml index f34706ca29b9..dc5dc430e621 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1427,7 +1427,7 @@ To activate your Profile we need to confirm this email address." email_confirmation_link_label: "Confirm this email address ยป" email_confirmation_help_html: "After confirming your email you can access your administration account for this enterprise. See the %{link} to find out more about %{sitename}'s features and to start using your profile or online store." - email_confirmation_notice_unexpected: "You received this message because you signed up on %{sitename}, or were invited to sign up by someone you probably know. If you don't understand why you are receiving this email, please write to %{contact}." + email_confirmation_notice_unexpected: "You received this message because you signed up on %{sitename}, or were invited to sign up by someone you probably know. If you don't understand why you are receiving this email, please write to %{contact}." email_social: "Connect with Us:" email_contact: "Email us:" email_signoff: "Cheers," @@ -2382,6 +2382,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using order_information: "Order Information" date_completed: "Date Completed" amount: "Amount" + user_guide_link: "User Guide Link" state_names: ready: Ready pending: Pending diff --git a/spec/features/admin/general_settings_spec.rb b/spec/features/admin/general_settings_spec.rb new file mode 100644 index 000000000000..d08693566ff0 --- /dev/null +++ b/spec/features/admin/general_settings_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +feature 'General Settings' do + include AuthenticationWorkflow + + describe "update" do + before do + Spree::Config.user_guide_link = nil + login_to_admin_section + end + + it 'lets me set the instance user guide link' do + visit spree.edit_admin_general_settings_path + + fill_in 'user_guide_link', with: 'http://www.openfoodnetwork.org/platform/user-guide/' + click_button 'Update' + + expect(page).to have_content 'General Settings has been successfully updated!' + expect(Spree::Config.user_guide_link).to eq 'http://www.openfoodnetwork.org/platform/user-guide/' + end + end +end