Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Flesh out Color Administration feature spec

Alexander Brandon Colesf15c46a84d8f
diff --git a/spec/features/colors/color_administration_spec.rb b/spec/features/colors/color_administration_spec.rb
index 6090f5afe15..78269e3c644 100644
--- a/spec/features/colors/color_administration_spec.rb
+++ b/spec/features/colors/color_administration_spec.rb
@@ -30,21 +30,113 @@
require "spec_helper"
-RSpec.describe "color administration" do
+RSpec.describe "color administration", :js, :selenium do
shared_let(:admin) { create(:admin) }
before do
login_as(admin)
+
+ visit colors_path
end
- it "CRUD" do
- # Only a stub for now
+ describe "listing colors" do
+ it "shows no results by default" do
+ expect(page).to have_content(I18n.t(:"colors.index.no_results_title_text"))
- visit colors_path
+ click_link I18n.t(:"colors.index.no_results_content_text")
+ end
+ end
+
+ describe "creating colors" do
+ it "creates a color" do
+ within "sub-header" do
+ click_link accessible_name: "New color"
+ end
+
+ fill_in "Name", with: "Vibrant pink"
+ fill_in "Hex code", with: "#FF69B4"
+
+ click_on "Save"
+
+ expect_and_dismiss_flash type: :success, message: "Successful creation."
+
+ within ".color--preview-patch-field" do
+ expect(page).to have_link "Vibrant pink"
+ end
+ end
+
+ it "displays validation errors if color values are invalid" do
+ within "sub-header" do
+ click_link accessible_name: "New color"
+ end
+
+ fill_in "Name", with: "Not so vibrant pink"
+ fill_in "Hex code", with: "11"
+
+ click_on "Save"
+
+ expect_and_dismiss_flash type: :error, message: /not a valid 6-digit hexadecimal color code/
+ end
+ end
+
+ describe "updating colors" do
+ it "creates and updates a color" do
+ within "sub-header" do
+ click_link accessible_name: "New color"
+ end
+
+ fill_in "Name", with: "Dark Purple"
+ fill_in "Hex code", with: "#301934"
+
+ click_on "Save"
+
+ expect_and_dismiss_flash type: :success, message: "Successful creation."
+
+ within ".color--preview-patch-field" do
+ click_on "Dark Purple"
+ end
+
+ expect(page).to have_heading "Dark Purple"
+
+ fill_in "Name", with: "Dark Grape (web safe)"
+ fill_in "Hex code", with: "330033"
+
+ click_on "Save"
+
+ expect_and_dismiss_flash type: :success, message: "Successful update."
+
+ within ".color--preview-patch-field" do
+ expect(page).to have_link "Dark Grape (web safe)"
+ end
+ end
+ end
+
+ describe "deleting colors" do
+ it "creates and deletes a color" do
+ within "sub-header" do
+ click_link accessible_name: "New color"
+ end
+
+ fill_in "Name", with: "Dark Purple"
+ fill_in "Hex code", with: "#301934"
+
+ click_on "Save"
+
+ expect_and_dismiss_flash type: :success, message: "Successful creation."
+
+ within ".color--preview-patch-field" do
+ click_on "Dark Purple"
+ end
+
+ expect(page).to have_heading "Dark Purple"
- expect(page)
- .to have_content(I18n.t(:"colors.index.no_results_title_text"))
+ within ".PageHeader-actions" do
+ accept_confirm do
+ click_on "Delete"
+ end
+ end
- click_link I18n.t(:"colors.index.no_results_content_text")
+ expect_and_dismiss_flash type: :success, message: "Successful deletion."
+ end
end
end