diff --git a/admin/app/components/solidus_admin/roles/edit/component.html.erb b/admin/app/components/solidus_admin/roles/edit/component.html.erb index 541df92c402..1d0ead5bcfa 100644 --- a/admin/app/components/solidus_admin/roles/edit/component.html.erb +++ b/admin/app/components/solidus_admin/roles/edit/component.html.erb @@ -3,6 +3,7 @@ <%= form_for @role, url: solidus_admin.role_path(@role), html: { id: form_id } do |f| %>
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> + <%= render component("ui/forms/field").text_field(f, :description) %>
<% modal.with_actions do %>
diff --git a/admin/app/components/solidus_admin/roles/index/component.rb b/admin/app/components/solidus_admin/roles/index/component.rb index 63ac5c15923..c5c4e92e297 100644 --- a/admin/app/components/solidus_admin/roles/index/component.rb +++ b/admin/app/components/solidus_admin/roles/index/component.rb @@ -60,6 +60,10 @@ def columns { header: :role, data: :name, + }, + { + header: :description, + data: :description, } ] end diff --git a/admin/app/components/solidus_admin/roles/index/component.yml b/admin/app/components/solidus_admin/roles/index/component.yml index 3934c0825e9..5a9eabd3f0d 100644 --- a/admin/app/components/solidus_admin/roles/index/component.yml +++ b/admin/app/components/solidus_admin/roles/index/component.yml @@ -1,6 +1,6 @@ en: batch_actions: - delete: 'Delete' + delete: "Delete" scopes: - admin: Admin - all: All + admin: "Admin" + all: "All" diff --git a/admin/app/components/solidus_admin/roles/new/component.html.erb b/admin/app/components/solidus_admin/roles/new/component.html.erb index dcd5d78d38c..3d49f4f987a 100644 --- a/admin/app/components/solidus_admin/roles/new/component.html.erb +++ b/admin/app/components/solidus_admin/roles/new/component.html.erb @@ -3,6 +3,7 @@ <%= form_for @role, url: solidus_admin.roles_path, html: { id: form_id } do |f| %>
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> + <%= render component("ui/forms/field").text_field(f, :description) %>
<% modal.with_actions do %> diff --git a/admin/app/controllers/solidus_admin/roles_controller.rb b/admin/app/controllers/solidus_admin/roles_controller.rb index cba1b7bd8ef..0fa1c16044b 100644 --- a/admin/app/controllers/solidus_admin/roles_controller.rb +++ b/admin/app/controllers/solidus_admin/roles_controller.rb @@ -112,7 +112,7 @@ def set_index_page end def role_params - params.require(:role).permit(:role_id, :name, :description, :type) + params.require(:role).permit(:role_id, :name, :description) end end end diff --git a/admin/spec/features/roles_spec.rb b/admin/spec/features/roles_spec.rb index 2b08dab450b..c2843d84816 100644 --- a/admin/spec/features/roles_spec.rb +++ b/admin/spec/features/roles_spec.rb @@ -49,6 +49,7 @@ context "with valid data" do it "successfully creates a new role, keeping page and q params" do fill_in "Name", with: "Purchaser" + fill_in "Description", with: "A person who buys stuff" click_on "Add Role" @@ -59,18 +60,27 @@ end context "with invalid data" do - # @note: The only validation that Roles currently have is that names must - # be unique (but they can still be blank). - before do - create(:role, name: "Customer Role" ) + context "with a non-unique name" do + before do + create(:role, name: "Customer Role" ) + end + + it "fails to create a new role, keeping page and q params" do + fill_in "Name", with: "Customer Role" + click_on "Add Role" + + expect(page).to have_content("has already been taken") + expect(page.current_url).to include(query) + end end - it "fails to create a new role, keeping page and q params" do - fill_in "Name", with: "Customer Role" - click_on "Add Role" + context "with no name" do + it "fails to create a new role, keeping page and q params" do + click_on "Add Role" - expect(page).to have_content("has already been taken") - expect(page.current_url).to include(query) + expect(page).to have_content("can't be blank") + expect(page.current_url).to include(query) + end end end end @@ -95,10 +105,12 @@ it "successfully updates the existing role" do fill_in "Name", with: "Publisher" + fill_in "Description", with: "A person who publishes stuff" click_on "Update Role" expect(page).to have_content("Role was successfully updated.") expect(page).to have_content("Publisher") + expect(page).to have_content("A person who publishes stuff") expect(page).not_to have_content("Reviewer") expect(Spree::Role.find_by(name: "Publisher")).to be_present expect(page.current_url).to include(query) diff --git a/admin/spec/requests/solidus_admin/roles_spec.rb b/admin/spec/requests/solidus_admin/roles_spec.rb index 95e57c6cb63..43b96560334 100644 --- a/admin/spec/requests/solidus_admin/roles_spec.rb +++ b/admin/spec/requests/solidus_admin/roles_spec.rb @@ -27,7 +27,7 @@ describe "POST /create" do context "with valid parameters" do - let(:valid_attributes) { { name: "Customer" } } + let(:valid_attributes) { { name: "Customer", description: "A person who buys stuff" } } it "creates a new Role" do expect { @@ -49,7 +49,7 @@ end context "with invalid parameters" do - let(:invalid_attributes) { { name: "admin" } } + let(:invalid_attributes) { { name: "" } } it "does not create a new Role" do expect { @@ -73,7 +73,7 @@ describe "PATCH /update" do context "with valid parameters" do - let(:valid_attributes) { { name: "Publisher" } } + let(:valid_attributes) { { name: "Publisher", description: "A person who publishes stuff" } } it "updates the role" do patch solidus_admin.role_path(role), params: { role: valid_attributes } @@ -95,7 +95,7 @@ end context "with invalid parameters" do - let(:invalid_attributes) { { name: "admin" } } + let(:invalid_attributes) { { name: "" } } it "does not update the role" do original_name = role.name