2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-11 07:46:31 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe "User creates branch", :js do
|
2018-04-11 07:46:31 -04:00
|
|
|
include Spec::Support::Helpers::Features::BranchesHelpers
|
|
|
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(new_project_branch_path(project))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates new branch" do
|
2020-05-05 08:09:31 -04:00
|
|
|
branch_name = "deploy_keys".freeze
|
2018-04-11 07:46:31 -04:00
|
|
|
|
2020-05-05 08:09:31 -04:00
|
|
|
create_branch(branch_name)
|
2018-04-11 07:46:31 -04:00
|
|
|
|
2020-05-05 08:09:31 -04:00
|
|
|
expect(page).to have_content(branch_name)
|
2018-04-11 07:46:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when branch name is invalid" do
|
|
|
|
it "does not create new branch" do
|
2020-05-05 08:09:31 -04:00
|
|
|
invalid_branch_name = "1.0 stable".freeze
|
2018-04-11 07:46:31 -04:00
|
|
|
|
2020-05-05 08:09:31 -04:00
|
|
|
fill_in("branch_name", with: invalid_branch_name)
|
2018-04-11 07:46:31 -04:00
|
|
|
page.find("body").click # defocus the branch_name input
|
|
|
|
|
|
|
|
select_branch("master")
|
|
|
|
click_button("Create branch")
|
|
|
|
|
|
|
|
expect(page).to have_content("Branch name is invalid")
|
|
|
|
expect(page).to have_content("can't contain spaces")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when branch name already exists" do
|
|
|
|
it "does not create new branch" do
|
|
|
|
create_branch("master")
|
|
|
|
|
|
|
|
expect(page).to have_content("Branch already exists")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|