summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-12 22:15:30 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-12 22:15:30 +0800
commit115a57c2ba512b9414c8a96e6d9d14e58e5eeab3 (patch)
tree3d572a4b31b628571b02e0cfc091d92f6f57557f /spec
parent7b43749e69fac0f50f5b17511c7caf1d819bb767 (diff)
parent850bb6db2facf570a7e0933bbf555f764aeac601 (diff)
downloadgitlab-ce-115a57c2ba512b9414c8a96e6d9d14e58e5eeab3.tar.gz
Merge remote-tracking branch 'upstream/master' into use-string-in-describeuse-string-in-describe
* upstream/master: Expire the branch cache after `git gc` runs Be explicit on merge request discussion variables Improve wording in UI guide Fix expandable diffs CHANGELOG was updated. Style of import project buttons were fixed in the new project page. api: expose {should,force}_remove_source_branch Fix typo in UI guide Add rule about adding new header tab to the ui guide Update the health_check gem to the latest release Display tooltip for "Copy to Clipboard" button (!5164) Remove icons from some buttons which already has text
Diffstat (limited to 'spec')
-rw-r--r--spec/features/expand_collapse_diffs_spec.rb6
-rw-r--r--spec/features/merge_requests/diffs_spec.rb25
-rw-r--r--spec/requests/api/merge_requests_spec.rb4
-rw-r--r--spec/services/projects/housekeeping_service_spec.rb4
-rw-r--r--spec/workers/git_garbage_collect_worker_spec.rb24
5 files changed, 58 insertions, 5 deletions
diff --git a/spec/features/expand_collapse_diffs_spec.rb b/spec/features/expand_collapse_diffs_spec.rb
index 7cff196c8d9..78bc888f2a6 100644
--- a/spec/features/expand_collapse_diffs_spec.rb
+++ b/spec/features/expand_collapse_diffs_spec.rb
@@ -106,7 +106,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do
let(:comment_text) { 'A comment' }
before do
- large_diff.find('.line_holder', match: :prefer_exact).hover
+ large_diff.find('.diff-line-num', match: :prefer_exact).hover
large_diff.find('.add-diff-note').click
large_diff.find('.note-textarea').send_keys comment_text
large_diff.find_button('Comment').click
@@ -161,7 +161,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do
end
it 'does not make a new HTTP request' do
- expect(evaluate_script('ajaxUris')).to be_empty
+ expect(evaluate_script('ajaxUris')).not_to include(a_string_matching('small_diff.md'))
end
end
end
@@ -199,7 +199,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do
end
it 'does not make a new HTTP request' do
- expect(evaluate_script('ajaxUris')).to be_empty
+ expect(evaluate_script('ajaxUris')).not_to include(a_string_matching('small_diff.md'))
end
end
end
diff --git a/spec/features/merge_requests/diffs_spec.rb b/spec/features/merge_requests/diffs_spec.rb
new file mode 100644
index 00000000000..c9a0059645d
--- /dev/null
+++ b/spec/features/merge_requests/diffs_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+feature 'Diffs URL', js: true, feature: true do
+ before do
+ login_as :admin
+ @merge_request = create(:merge_request)
+ @project = @merge_request.source_project
+ end
+
+ context 'when visit with */* as accept header' do
+ before(:each) do
+ page.driver.add_header('Accept', '*/*')
+ end
+
+ it 'renders the notes' do
+ create :note_on_merge_request, project: @project, noteable: @merge_request, note: 'Rebasing with master'
+
+ visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
+
+ # Load notes and diff through AJAX
+ expect(page).to have_css('.note-text', visible: false, text: 'Rebasing with master')
+ expect(page).to have_css('.diffs.tab-pane.active')
+ end
+ end
+end
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 4a1b5600bdf..651b91e9f68 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -138,6 +138,8 @@ describe API::API, api: true do
expect(json_response['work_in_progress']).to be_falsy
expect(json_response['merge_when_build_succeeds']).to be_falsy
expect(json_response['merge_status']).to eq('can_be_merged')
+ expect(json_response['should_close_merge_request']).to be_falsy
+ expect(json_response['force_close_merge_request']).to be_falsy
end
it "should return merge_request" do
@@ -147,6 +149,8 @@ describe API::API, api: true do
expect(json_response['iid']).to eq(merge_request.iid)
expect(json_response['work_in_progress']).to eq(false)
expect(json_response['merge_status']).to eq('can_be_merged')
+ expect(json_response['should_close_merge_request']).to be_falsy
+ expect(json_response['force_close_merge_request']).to be_falsy
end
it 'should return merge_request by iid' do
diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb
index bd4dc6a0f79..7ab95e042ce 100644
--- a/spec/services/projects/housekeeping_service_spec.rb
+++ b/spec/services/projects/housekeeping_service_spec.rb
@@ -12,7 +12,7 @@ describe Projects::HousekeepingService do
it 'enqueues a sidekiq job' do
expect(subject).to receive(:try_obtain_lease).and_return(true)
- expect(GitlabShellOneShotWorker).to receive(:perform_async).with(:gc, project.repository_storage_path, project.path_with_namespace)
+ expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id)
subject.execute
expect(project.pushes_since_gc).to eq(0)
@@ -20,7 +20,7 @@ describe Projects::HousekeepingService do
it 'does not enqueue a job when no lease can be obtained' do
expect(subject).to receive(:try_obtain_lease).and_return(false)
- expect(GitlabShellOneShotWorker).not_to receive(:perform_async)
+ expect(GitGarbageCollectWorker).not_to receive(:perform_async)
expect { subject.execute }.to raise_error(Projects::HousekeepingService::LeaseTaken)
expect(project.pushes_since_gc).to eq(0)
diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb
new file mode 100644
index 00000000000..a9cce8b8b59
--- /dev/null
+++ b/spec/workers/git_garbage_collect_worker_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe GitGarbageCollectWorker do
+ let(:project) { create(:project) }
+ let(:shell) { Gitlab::Shell.new }
+
+ subject { GitGarbageCollectWorker.new }
+
+ before do
+ allow(subject).to receive(:gitlab_shell).and_return(shell)
+ end
+
+ describe "#perform" do
+ it "runs `git gc`" do
+ expect(shell).to receive(:gc).with(
+ project.repository_storage_path,
+ project.path_with_namespace).
+ and_return(true)
+ expect_any_instance_of(Repository).to receive(:after_create_branch)
+
+ subject.perform(project.id)
+ end
+ end
+end