From 99774b3e7026751ba9800ac499e896b1df1c7526 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 14 Jul 2020 11:59:36 +0200 Subject: [PATCH] Allow editing sites Prior to this commit, the site's form partial would only reference the path needed to create a new site, not the one needed to edit an existing one. This commit changes the partial to use `resource_path`, which does the right thing: `/admin/sites/` for creating a new site, `/admin/sites/2/` for editing an existing one. --- app/views/alchemy/admin/sites/_form.html.erb | 2 +- spec/features/admin/site_editing_spec.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 spec/features/admin/site_editing_spec.rb diff --git a/app/views/alchemy/admin/sites/_form.html.erb b/app/views/alchemy/admin/sites/_form.html.erb index e02c5801e5..d2c0a2da8b 100644 --- a/app/views/alchemy/admin/sites/_form.html.erb +++ b/app/views/alchemy/admin/sites/_form.html.erb @@ -1,4 +1,4 @@ -<%= alchemy_form_for site, url: alchemy.admin_sites_path(site, search_filter_params) do |f| %> +<%= alchemy_form_for site, url: resource_path(site, search_filter_params) do |f| %> <%= f.input :host, hint: resource_handler.help_text_for(name: :host)&.html_safe %> <%= f.input :name %> <%= f.input :public %> diff --git a/spec/features/admin/site_editing_spec.rb b/spec/features/admin/site_editing_spec.rb new file mode 100644 index 0000000000..c844146eae --- /dev/null +++ b/spec/features/admin/site_editing_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe "Site editing feature", type: :system do + before { authorize_user(:as_admin) } + + it "can create a new page" do + visit alchemy.new_admin_site_path + fill_in "site_host", with: "api.example.com" + fill_in "site_name", with: "API Site" + click_button "Save" + expect(page).to have_content "You need at least one language to work with. Please create one below." + visit alchemy.edit_admin_site_path(Alchemy::Site.first) + fill_in "Aliases", with: "api.localhost" + click_button "Save" + expect(page).to have_content "api.localhost" + end +end