summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHan Loong Liauw <hanloongliauw@gmail.com>2015-10-13 21:24:44 +1100
committerHan Loong Liauw <hanloongliauw@gmail.com>2015-10-13 21:42:17 +1100
commitdf99ddbba13db4a7699bf1d585675f921cf382ce (patch)
treea6597628f5c46a553725a121169755f4c0f9cef2 /spec
parente12b6f30efef3f607cacc5da51f8c49c3be4643a (diff)
downloadgitlab-ce-df99ddbba13db4a7699bf1d585675f921cf382ce.tar.gz
Adds ability to remove the forked relationship
This was previously possible through the API but can now be done through the project#edit settings screen if the current user is the owner of the project. Update changelog
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects_controller_spec.rb40
-rw-r--r--spec/features/projects_spec.rb29
2 files changed, 65 insertions, 4 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 21beaf37fce..626b56cc789 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -62,4 +62,44 @@ describe ProjectsController do
expect(user.starred?(public_project)).to be_falsey
end
end
+
+ describe "PUT remove_fork" do
+ context 'when signed in' do
+ before do
+ sign_in(user)
+ end
+
+ context 'with forked project' do
+ let(:project_fork) { create(:project, namespace: user.namespace) }
+
+ it 'should remove fork from project' do
+ create(:forked_project_link, forked_to_project: project_fork)
+ put(:remove_fork,
+ namespace_id: project_fork.namespace.to_param,
+ id: project_fork.to_param, format: :js)
+
+ expect(project_fork.forked?).to be_falsey
+ expect(flash[:notice]).to eq('Fork relationship has been removed.')
+ expect(response).to render_template(:remove_fork)
+ end
+ end
+
+ it 'should do nothing if project was not forked' do
+ unforked_project = create(:project, namespace: user.namespace)
+ put(:remove_fork,
+ namespace_id: unforked_project.namespace.to_param,
+ id: unforked_project.to_param, format: :js)
+
+ expect(flash[:notice]).to be_nil
+ expect(response).to render_template(:remove_fork)
+ end
+ end
+
+ it "does nothing if user is not signed in" do
+ put(:remove_fork,
+ namespace_id: project.namespace.to_param,
+ id: project.to_param, format: :js)
+ expect(response.status).to eq(401)
+ end
+ end
end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index aac93b17a38..df0dcb2bb21 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -34,6 +34,27 @@ feature 'Project', feature: true do
end
end
+ describe 'remove forked relationship', js: true do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, namespace: user.namespace) }
+
+ before do
+ login_with user
+ create(:forked_project_link, forked_to_project: project)
+ visit edit_namespace_project_path(project.namespace, project)
+ end
+
+ it 'should remove fork' do
+ expect(page).to have_content 'Remove forked relationship'
+
+ remove_with_confirm('Remove forked relationship', project.path)
+
+ expect(page).to have_content 'Fork relationship has been removed.'
+ expect(project.forked?).to be_falsey
+ expect(page).not_to have_content 'Remove forked relationship'
+ end
+ end
+
describe 'removal', js: true do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
@@ -45,13 +66,13 @@ feature 'Project', feature: true do
end
it 'should remove project' do
- expect { remove_project }.to change {Project.count}.by(-1)
+ expect { remove_with_confirm('Remove project', project.path) }.to change {Project.count}.by(-1)
end
end
- def remove_project
- click_button "Remove project"
- fill_in 'confirm_name_input', with: project.path
+ def remove_with_confirm(button_text, confirm_with)
+ click_button button_text
+ fill_in 'confirm_name_input', with: confirm_with
click_button 'Confirm'
end
end