diff --git a/app/controllers/katalyst/navigation/menus_controller.rb b/app/controllers/katalyst/navigation/menus_controller.rb index 525d0ec..41fc56a 100644 --- a/app/controllers/katalyst/navigation/menus_controller.rb +++ b/app/controllers/katalyst/navigation/menus_controller.rb @@ -62,7 +62,7 @@ def destroy menu.destroy! - redirect_to action: :index + redirect_to action: :index, status: :see_other end private diff --git a/app/views/katalyst/navigation/menus/edit.html.erb b/app/views/katalyst/navigation/menus/edit.html.erb index 07f62c1..a3953b5 100644 --- a/app/views/katalyst/navigation/menus/edit.html.erb +++ b/app/views/katalyst/navigation/menus/edit.html.erb @@ -11,5 +11,10 @@ <%= form.text_field :slug %> - <%= form.submit :save %> +
<% end %> diff --git a/app/views/katalyst/navigation/menus/index.html.erb b/app/views/katalyst/navigation/menus/index.html.erb index 2354b4e..fffde5e 100644 --- a/app/views/katalyst/navigation/menus/index.html.erb +++ b/app/views/katalyst/navigation/menus/index.html.erb @@ -11,7 +11,4 @@ <%= link_to cell.value, menu %> <% end %> <%= row.cell :slug %> - <%= row.cell :actions do |cell| %> - <%= button_to "Delete", menu, method: :delete, class: "button button--text" %> - <% end %> <% end %> diff --git a/spec/dummy/app/assets/stylesheets/application.scss b/spec/dummy/app/assets/stylesheets/application.scss index a097ffc..e1a9a72 100644 --- a/spec/dummy/app/assets/stylesheets/application.scss +++ b/spec/dummy/app/assets/stylesheets/application.scss @@ -48,3 +48,11 @@ main { .index-table-actions { grid-area: sidebar; } + +.button-row { + display: flex; + flex-direction: row; + > * { + margin-right: 0.5rem; + } +} diff --git a/spec/requests/katalyst/navigation/menus_controller_spec.rb b/spec/requests/katalyst/navigation/menus_controller_spec.rb index d3bf64e..dc708ca 100644 --- a/spec/requests/katalyst/navigation/menus_controller_spec.rb +++ b/spec/requests/katalyst/navigation/menus_controller_spec.rb @@ -98,4 +98,13 @@ it { expect { action }.to change { menu.reload.state }.from(:draft).to(:published) } end end + + describe "DELETE /navigation/menus/:id" do + let(:action) { delete katalyst_navigation.menu_path(menu) } + let!(:menu) { create :katalyst_navigation_menu } + + it { is_expected.to have_http_status(:see_other) } + it { is_expected.to redirect_to(katalyst_navigation.menus_path) } + it { expect { action }.to change(Katalyst::Navigation::Menu, :count).to(0) } + end end diff --git a/spec/system/katalyst/navigation/menu_spec.rb b/spec/system/katalyst/navigation/menu_spec.rb new file mode 100644 index 0000000..e0b085c --- /dev/null +++ b/spec/system/katalyst/navigation/menu_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe "katalyst/navigation/menu" do + it "can add a menu" do + visit katalyst_navigation.menus_path + + expect(page).to have_text("Title") + + click_on "Add" + + fill_in "Title", with: "Magic" + fill_in "Slug", with: "magic" + + click_on "Create Menu" + + # Menu show page + expect(page).to have_text "Publish" + end + + it "can edit a menu" do + menu = create :katalyst_navigation_menu, title: "Magic", slug: "magic" + + visit katalyst_navigation.menus_path + + expect(page).to have_text("Magic") + + visit katalyst_navigation.edit_menu_path(menu) + + fill_in "Title", with: "Not Magic" + + click_on "save" + + visit katalyst_navigation.menus_path + expect(page).to have_text("Not Magic") + end + + it "can delete a menu" do + menu = create :katalyst_navigation_menu, title: "Magic", slug: "magic" + + visit katalyst_navigation.menus_path + + expect(page).to have_text("Magic") + + visit katalyst_navigation.edit_menu_path(menu) + + click_on "Delete" + + expect(page).not_to have_text("Magic") + end +end