diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-12-24 15:24:57 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-12-24 15:24:57 +0300 |
commit | 76b7e24f855c99814fc09e286fb061b7aea3954c (patch) | |
tree | 498970380a63da563d29b24078bf293ce66a7658 /features/steps | |
parent | 84e75ebd4cd463cf5e0dea9c46e7bcef50b98f50 (diff) | |
parent | cfa716ebe0f149fd3f152d90c4dcf32ea450b486 (diff) |
Merge branch 'edit-on-fork' into 'master'
Automatically fork a project when not allowed to edit a file.
Fixes #3215.
To do:
- [ ] Add tests
-----
## "Edit" button on file in a project the user does NOT have write access to
![edit_file](/uploads/7602157420768aef483a6586bba2d164/edit_file.png)
## Clicking will automatically create a fork
![during_fork](/uploads/32f4f5dff9f24ea99522000b0bf881c5/during_fork.png)
## When the fork has been created, the user is returned to the edit page on the original project with a notice
![edit_notice](/uploads/94ed1319404370ff1e9c0d672fb41e03/edit_notice.png)
## The user cannot change the target branch and is informed that editing will start an MR
![edit_footer](/uploads/4da68d4795c7177e575b7c434d16eeae/edit_footer.png)
## Hitting "Commit changes" will commit and start an MR from my fork to the origin project
![Screen_Shot_2015-12-17_at_23.38.08](/uploads/d777a4db6f38a5a1be84031694465bc1/Screen_Shot_2015-12-17_at_23.38.08.png)
-----
## "Create file, "Upload file" and "New directory" buttons in a project the user does NOT have write access to
![new_directory](/uploads/72f556248f30d6652523bbb4be01b3e0/new_directory.png)
## Clicking any of these options will automatically create a fork
![during_fork](/uploads/32f4f5dff9f24ea99522000b0bf881c5/during_fork.png)
## When the fork has been created, the user is returned to the tree page on the original project with a notice
![new_directory_notice](/uploads/a1a3e11308ae0e8f0913fae6813a37ed/new_directory_notice.png)
## Clicking "New directory" again will show the modal. The user cannot change the target branch and is informed that editing will start an MR
![new_dir](/uploads/99ca8cbfb2f70603e352b3fdf67b6281/new_dir.png)
## Hitting "Create directory" will commit and start an MR from my fork to the origin project
![Screen_Shot_2015-12-17_at_23.39.19](/uploads/3713d0235abf831361b803a6198c5bc1/Screen_Shot_2015-12-17_at_23.39.19.png)
cc @dzaporozhets @skyruler
See merge request !2145
Diffstat (limited to 'features/steps')
-rw-r--r-- | features/steps/project/source/browse_files.rb | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/features/steps/project/source/browse_files.rb b/features/steps/project/source/browse_files.rb index 0c6df18ce2e..d08935aa101 100644 --- a/features/steps/project/source/browse_files.rb +++ b/features/steps/project/source/browse_files.rb @@ -5,6 +5,12 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps include SharedPaths include RepoHelpers + step "I don't have write access" do + @project = create(:project, name: "Other Project", path: "other-project") + @project.team << [@user, :reporter] + visit namespace_project_tree_path(@project.namespace, @project, root_ref) + end + step 'I should see files from repository' do expect(page).to have_content "VERSION" expect(page).to have_content ".gitignore" @@ -75,7 +81,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps end step 'I fill the new branch name' do - fill_in :new_branch, with: 'new_branch_name', visible: true + fill_in :target_branch, with: 'new_branch_name', visible: true end step 'I fill the new file name with an illegal name' do @@ -87,7 +93,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps end step 'I fill the commit message' do - fill_in :commit_message, with: 'Not yet a commit message.', visible: true + fill_in :commit_message, with: 'New commit message', visible: true end step 'I click link "Diff"' do @@ -103,7 +109,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps end step 'I click on "Delete"' do - click_button 'Delete' + click_on 'Delete' end step 'I click on "Delete file"' do @@ -111,7 +117,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps end step 'I click on "Replace"' do - click_button "Replace" + click_on "Replace" end step 'I click on "Replace file"' do @@ -124,7 +130,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps step 'I click on "New file" link in repo' do find('.add-to-tree').click - click_link 'Create file' + click_link 'New file' end step 'I click on "Upload file" link in repo' do @@ -155,7 +161,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps end step 'I can see the new commit message' do - expect(page).to have_content "New upload commit message" + expect(page).to have_content "New commit message" end step 'I upload a new text file' do @@ -164,7 +170,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps step 'I fill the upload file commit message' do page.within('#modal-upload-blob') do - fill_in :commit_message, with: 'New upload commit message' + fill_in :commit_message, with: 'New commit message' end end @@ -251,9 +257,14 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps expect(current_path).to eq(new_namespace_project_merge_request_path(@project.namespace, @project)) end + step "I am redirected to the fork's new merge request page" do + fork = @user.fork_of(@project) + expect(current_path).to eq(new_namespace_project_merge_request_path(fork.namespace, fork)) + end + step 'I am redirected to the root directory' do expect(current_path).to eq( - namespace_project_tree_path(@project.namespace, @project, 'master/')) + namespace_project_tree_path(@project.namespace, @project, 'master')) end step "I don't see the permalink link" do @@ -332,8 +343,12 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps expect(page).to have_content 'Permalink' expect(page).not_to have_content 'Edit' expect(page).not_to have_content 'Blame' - expect(page).not_to have_content 'Delete' - expect(page).not_to have_content 'Replace' + expect(page).to have_content 'Delete' + expect(page).to have_content 'Replace' + end + + step 'I should see a notice about a new fork having been created' do + expect(page).to have_content "You're not allowed to make changes to this project directly. A fork of this project has been created that you can make changes in, so you can submit a merge request." end private |