summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/models/wiki_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/models/wiki_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/models/wiki_shared_examples.rb46
1 files changed, 33 insertions, 13 deletions
diff --git a/spec/support/shared_examples/models/wiki_shared_examples.rb b/spec/support/shared_examples/models/wiki_shared_examples.rb
index 89d30688b5c..abc6e3ecce8 100644
--- a/spec/support/shared_examples/models/wiki_shared_examples.rb
+++ b/spec/support/shared_examples/models/wiki_shared_examples.rb
@@ -354,27 +354,47 @@ RSpec.shared_examples 'wiki model' do
subject.repository.create_file(user, 'image.png', image, branch_name: subject.default_branch, message: 'add image')
end
- it 'returns the latest version of the file if it exists' do
- file = subject.find_file('image.png')
+ shared_examples 'find_file results' do
+ it 'returns the latest version of the file if it exists' do
+ file = subject.find_file('image.png')
- expect(file.mime_type).to eq('image/png')
- end
+ expect(file.mime_type).to eq('image/png')
+ end
+
+ it 'returns nil if the page does not exist' do
+ expect(subject.find_file('non-existent')).to eq(nil)
+ end
+
+ it 'returns a Gitlab::Git::WikiFile instance' do
+ file = subject.find_file('image.png')
+
+ expect(file).to be_a Gitlab::Git::WikiFile
+ end
- it 'returns nil if the page does not exist' do
- expect(subject.find_file('non-existent')).to eq(nil)
+ it 'returns the whole file' do
+ file = subject.find_file('image.png')
+ image.rewind
+
+ expect(file.raw_data.b).to eq(image.read.b)
+ end
end
- it 'returns a Gitlab::Git::WikiFile instance' do
- file = subject.find_file('image.png')
+ it_behaves_like 'find_file results'
+
+ context 'when load_content is disabled' do
+ it 'includes the file data in the Gitlab::Git::WikiFile' do
+ file = subject.find_file('image.png', load_content: false)
- expect(file).to be_a Gitlab::Git::WikiFile
+ expect(file.raw_data).to be_empty
+ end
end
- it 'returns the whole file' do
- file = subject.find_file('image.png')
- image.rewind
+ context 'when feature flag :gitaly_find_file is disabled' do
+ before do
+ stub_feature_flags(gitaly_find_file: false)
+ end
- expect(file.raw_data.b).to eq(image.read.b)
+ it_behaves_like 'find_file results'
end
end