Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormicael.bergeron <micaelbergeron@gmail.com>2017-11-01 17:31:35 +0300
committermicael.bergeron <micaelbergeron@gmail.com>2017-11-03 15:13:11 +0300
commitcd88fa8f80710ec977a85ab8701570073c94f017 (patch)
tree8866f616741d7a3f7f35f6e37b2e01503804b2a2 /spec/models/merge_request_spec.rb
parent8c01f3110c8d8601fc16b17850dfa778f1f3d877 (diff)
removed the #ensure_ref_fetched from all controllers
also, I refactored the MergeRequest#fetch_ref method to express the side-effect that this method has. MergeRequest#fetch_ref -> MergeRequest#fetch_ref! Repository#fetch_source_branch -> Repository#fetch_source_branch!
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r--spec/models/merge_request_spec.rb37
1 files changed, 5 insertions, 32 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 476a2697605..f719ee26767 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -1755,39 +1755,12 @@ describe MergeRequest do
end
end
- describe '#fetch_ref' do
- it 'sets "ref_fetched" flag to true' do
- subject.update!(ref_fetched: nil)
+ describe '#fetch_ref!' do
+ it 'fetch the ref correctly' do
+ expect { subject.target_project.repository.delete_refs(subject.ref_path) }.not_to raise_error
- subject.fetch_ref
-
- expect(subject.reload.ref_fetched).to be_truthy
- end
- end
-
- describe '#ref_fetched?' do
- it 'does not perform git operation when value is cached' do
- subject.ref_fetched = true
-
- expect_any_instance_of(Repository).not_to receive(:ref_exists?)
- expect(subject.ref_fetched?).to be_truthy
- end
-
- it 'caches the value when ref exists but value is not cached' do
- subject.update!(ref_fetched: nil)
- allow_any_instance_of(Repository).to receive(:ref_exists?)
- .and_return(true)
-
- expect(subject.ref_fetched?).to be_truthy
- expect(subject.reload.ref_fetched).to be_truthy
- end
-
- it 'returns false when ref does not exist' do
- subject.update!(ref_fetched: nil)
- allow_any_instance_of(Repository).to receive(:ref_exists?)
- .and_return(false)
-
- expect(subject.ref_fetched?).to be_falsey
+ subject.fetch_ref!
+ expect(subject.target_project.repository.ref_exists?(subject.ref_path)).to be_truthy
end
end