diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-06 06:08:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-06 06:08:18 +0300 |
commit | 53a3791717e8925078f074b976a561c7a72b1b22 (patch) | |
tree | 826aea342691595c3d3cdc716019a81e09c05873 /spec/support/shared_examples | |
parent | a807e50ade2a78add0c13b75575203d7d99e8a4c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples')
-rw-r--r-- | spec/support/shared_examples/features/wiki/user_views_wiki_pages_shared_examples.rb | 45 | ||||
-rw-r--r-- | spec/support/shared_examples/models/wiki_shared_examples.rb | 89 |
2 files changed, 69 insertions, 65 deletions
diff --git a/spec/support/shared_examples/features/wiki/user_views_wiki_pages_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_views_wiki_pages_shared_examples.rb index 32cb2b1d187..979c8ac2e84 100644 --- a/spec/support/shared_examples/features/wiki/user_views_wiki_pages_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_views_wiki_pages_shared_examples.rb @@ -4,7 +4,7 @@ # wiki # user -RSpec.shared_examples 'User views wiki pages' do +RSpec.shared_examples 'User views wiki pages' do |support_sorting_by_created_at = true| include WikiHelpers let!(:wiki_page1) do @@ -54,34 +54,37 @@ RSpec.shared_examples 'User views wiki pages' do end end - context 'ordered by created_at' do - let(:pages_ordered_by_created_at) { [wiki_page1, wiki_page2, wiki_page3] } + if support_sorting_by_created_at + context 'ordered by created_at' do + let(:pages_ordered_by_created_at) { [wiki_page1, wiki_page2, wiki_page3] } - before do - page.within('.wiki-sort-dropdown') do - click_button('Title') - click_button('Created date') + before do + stub_feature_flags(wiki_list_pages_with_normal_repository_rpcs: false) + page.within('.wiki-sort-dropdown') do + click_button('Title') + click_button('Created date') + end end - end - context 'asc' do - it 'pages are displayed in direct order' do - pages.each.with_index do |page_title, index| - expect(page_title.text).to eq(pages_ordered_by_created_at[index].title) + context 'asc' do + it 'pages are displayed in direct order' do + pages.each.with_index do |page_title, index| + expect(page_title.text).to eq(pages_ordered_by_created_at[index].title) + end end end - end - context 'desc' do - before do - page.within('.wiki-sort-dropdown') do - page.find('.rspec-reverse-sort').click + context 'desc' do + before do + page.within('.wiki-sort-dropdown') do + page.find('.rspec-reverse-sort').click + end end - end - it 'pages are displayed in reversed order' do - pages.reverse_each.with_index do |page_title, index| - expect(page_title.text).to eq(pages_ordered_by_created_at[index].title) + it 'pages are displayed in reversed order' do + pages.reverse_each.with_index do |page_title, index| + expect(page_title.text).to eq(pages_ordered_by_created_at[index].title) + end end end end diff --git a/spec/support/shared_examples/models/wiki_shared_examples.rb b/spec/support/shared_examples/models/wiki_shared_examples.rb index b9c273b1e1a..7dc36bf227e 100644 --- a/spec/support/shared_examples/models/wiki_shared_examples.rb +++ b/spec/support/shared_examples/models/wiki_shared_examples.rb @@ -180,70 +180,71 @@ RSpec.shared_examples 'wiki model' do it 'returns false' do expect(subject.empty?).to be(false) end - - it 'only instantiates a Wiki page once' do - expect(WikiPage).to receive(:new).once.and_call_original - - subject.empty? - end end end end describe '#list_pages' do - let(:wiki_pages) { subject.list_pages } + shared_examples 'wiki model #list_pages' do + let(:wiki_pages) { subject.list_pages } - before do - subject.create_page('index', 'This is an index') - subject.create_page('index2', 'This is an index2') - subject.create_page('an index3', 'This is an index3') - end + before do + subject.create_page('index', 'This is an index') + subject.create_page('index2', 'This is an index2') + subject.create_page('an index3', 'This is an index3') + end - it 'returns an array of WikiPage instances' do - expect(wiki_pages).to be_present - expect(wiki_pages).to all(be_a(WikiPage)) - end + it 'returns an array of WikiPage instances' do + expect(wiki_pages).to be_present + expect(wiki_pages).to all(be_a(WikiPage)) + end - it 'does not load WikiPage content by default' do - wiki_pages.each do |page| - expect(page.content).to be_empty + it 'does not load WikiPage content by default' do + wiki_pages.each do |page| + expect(page.content).to be_empty + end end - end - it 'returns all pages by default' do - expect(wiki_pages.count).to eq(3) - end + it 'returns all pages by default' do + expect(wiki_pages.count).to eq(3) + end - context 'with limit option' do - it 'returns limited set of pages' do - expect(subject.list_pages(limit: 1).count).to eq(1) + context 'with limit option' do + it 'returns limited set of pages' do + expect(subject.list_pages(limit: 1).count).to eq(1) + end end - end - context 'with sorting options' do - it 'returns pages sorted by title by default' do - pages = ['an index3', 'index', 'index2'] + context 'with sorting options' do + it 'returns pages sorted by title by default' do + pages = ['an index3', 'index', 'index2'] - expect(subject.list_pages.map(&:title)).to eq(pages) - expect(subject.list_pages(direction: 'desc').map(&:title)).to eq(pages.reverse) + expect(subject.list_pages.map(&:title)).to eq(pages) + expect(subject.list_pages(direction: 'desc').map(&:title)).to eq(pages.reverse) + end end - it 'returns pages sorted by created_at' do - pages = ['index', 'index2', 'an index3'] + context 'with load_content option' do + let(:pages) { subject.list_pages(load_content: true) } - expect(subject.list_pages(sort: 'created_at').map(&:title)).to eq(pages) - expect(subject.list_pages(sort: 'created_at', direction: 'desc').map(&:title)).to eq(pages.reverse) + it 'loads WikiPage content' do + expect(pages.first.content).to eq('This is an index3') + expect(pages.second.content).to eq('This is an index') + expect(pages.third.content).to eq('This is an index2') + end end end - context 'with load_content option' do - let(:pages) { subject.list_pages(load_content: true) } - - it 'loads WikiPage content' do - expect(pages.first.content).to eq('This is an index3') - expect(pages.second.content).to eq('This is an index') - expect(pages.third.content).to eq('This is an index2') + context 'list pages with legacy wiki rpcs' do + before do + stub_feature_flags(wiki_list_page_with_normal_repository_rpcs: false) end + + it_behaves_like 'wiki model #list_pages' + end + + context 'list pages with normal repository rpcs' do + it_behaves_like 'wiki model #list_pages' end end @@ -531,7 +532,7 @@ RSpec.shared_examples 'wiki model' do it 'sets the correct commit message' do subject.create_page('test page', 'some content', :markdown, 'commit message') - expect(subject.list_pages.first.page.version.message).to eq('commit message') + expect(subject.list_pages.first.version.message).to eq('commit message') end it 'sets the correct commit email' do |