debian-mirror-gitlab/spec/features/projects/labels/user_creates_labels_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.1 KiB
Ruby
Raw Permalink Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require "spec_helper"
2023-03-04 22:38:38 +05:30
RSpec.describe "User creates labels", feature_category: :team_planning do
2020-04-08 14:13:33 +05:30
let_it_be(:project) { create(:project_empty_repo, :public) }
let_it_be(:user) { create(:user) }
2018-05-09 12:01:36 +05:30
shared_examples_for "label creation" do
it "creates new label" do
title = "bug"
create_label(title)
page.within(".other-labels .manage-labels-list") do
expect(page).to have_content(title)
end
end
end
context "in project" do
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2018-05-09 12:01:36 +05:30
sign_in(user)
visit(new_project_label_path(project))
end
context "when data is valid" do
include_examples "label creation"
end
context "when data is invalid" do
context "when title is invalid" do
it "shows error message" do
create_label("")
page.within(".label-form") do
expect(page).to have_content("Title can't be blank")
end
end
end
context "when color is invalid" do
it "shows error message" do
create_label("feature", "#12")
page.within(".label-form") do
expect(page).to have_content("Color must be a valid color code")
end
end
end
end
context "when label already exists" do
let!(:label) { create(:label, project: project) }
it "shows error message" do
create_label(label.title)
page.within(".label-form") do
expect(page).to have_content("Title has already been taken")
end
end
end
end
context "in another project" do
2020-04-08 14:13:33 +05:30
let_it_be(:another_project) { create(:project_empty_repo, :public) }
2018-05-09 12:01:36 +05:30
before do
create(:label, project: project, title: "bug") # Create label for `project` (not `another_project`) project.
2018-11-18 11:00:15 +05:30
another_project.add_maintainer(user)
2018-05-09 12:01:36 +05:30
sign_in(user)
visit(new_project_label_path(another_project))
end
include_examples "label creation"
end
private
def create_label(title, color = "#F95610")
fill_in("Title", with: title)
fill_in("Background color", with: color)
click_button("Create label")
end
end