diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-04-11 14:46:31 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-04-11 14:46:31 +0300 |
commit | 6d9f16c0aba46edd45d194e6f919896359b98a03 (patch) | |
tree | 6946a380cd79a9f74ff072d88d3c3a5cb2f6b92c /spec/features/projects/branches | |
parent | 3efe170370c5ea6bbf68ab497339e4360af84030 (diff) |
Replace the `project/commits/branches.feature` spinach test with an rspec analog
Diffstat (limited to 'spec/features/projects/branches')
3 files changed, 103 insertions, 0 deletions
diff --git a/spec/features/projects/branches/user_creates_branch_spec.rb b/spec/features/projects/branches/user_creates_branch_spec.rb new file mode 100644 index 00000000000..b706ad64954 --- /dev/null +++ b/spec/features/projects/branches/user_creates_branch_spec.rb @@ -0,0 +1,46 @@ +require "spec_helper" + +describe "User creates branch", :js do + 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 + BRANCH_NAME = "deploy_keys".freeze + + create_branch(BRANCH_NAME) + + expect(page).to have_content(BRANCH_NAME) + end + + context "when branch name is invalid" do + it "does not create new branch" do + INVALID_BRANCH_NAME = "1.0 stable".freeze + + fill_in("branch_name", with: INVALID_BRANCH_NAME) + 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 diff --git a/spec/features/projects/branches/user_deletes_branch_spec.rb b/spec/features/projects/branches/user_deletes_branch_spec.rb new file mode 100644 index 00000000000..96f215e1606 --- /dev/null +++ b/spec/features/projects/branches/user_deletes_branch_spec.rb @@ -0,0 +1,23 @@ +require "spec_helper" + +describe "User deletes branch", :js do + set(:user) { create(:user) } + set(:project) { create(:project, :repository) } + + before do + project.add_developer(user) + sign_in(user) + + visit(project_branches_path(project)) + end + + it "deletes branch" do + fill_in("branch-search", with: "improve/awesome").native.send_keys(:enter) + + page.within(".js-branch-improve\\/awesome") do + accept_alert { find(".btn-remove").click } + end + + expect(page).to have_css(".js-branch-improve\\/awesome", visible: :hidden) + end +end diff --git a/spec/features/projects/branches/user_views_branches_spec.rb b/spec/features/projects/branches/user_views_branches_spec.rb new file mode 100644 index 00000000000..62ae793151c --- /dev/null +++ b/spec/features/projects/branches/user_views_branches_spec.rb @@ -0,0 +1,34 @@ +require "spec_helper" + +describe "User views branches" do + set(:project) { create(:project, :repository) } + set(:user) { project.owner } + + before do + sign_in(user) + end + + context "all branches" do + before do + visit(project_branches_path(project)) + end + + it "shows branches" do + expect(page).to have_content("Branches").and have_content("master") + end + end + + context "protected branches" do + set(:protected_branch) { create(:protected_branch, project: project) } + + before do + visit(project_protected_branches_path(project)) + end + + it "shows branches" do + page.within(".protected-branches-list") do + expect(page).to have_content(protected_branch.name).and have_no_content("master") + end + end + end +end |