diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /spec/features/static_site_editor_spec.rb | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'spec/features/static_site_editor_spec.rb')
-rw-r--r-- | spec/features/static_site_editor_spec.rb | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/spec/features/static_site_editor_spec.rb b/spec/features/static_site_editor_spec.rb index b67e47b6ac4..03085917d67 100644 --- a/spec/features/static_site_editor_spec.rb +++ b/spec/features/static_site_editor_spec.rb @@ -6,18 +6,71 @@ RSpec.describe 'Static Site Editor' do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository) } + let(:sse_path) { project_show_sse_path(project, 'master/README.md') } + + before_all do + project.add_developer(user) + end + before do - project.add_maintainer(user) sign_in(user) + end + + context "when no config file is present" do + before do + visit sse_path + end - visit project_show_sse_path(project, 'master/README.md') + it 'renders SSE page with all generated config values and default config file values' do + node = page.find('#static-site-editor') + + # assert generated config values are present + expect(node['data-base-url']).to eq("/#{project.full_path}/-/sse/master%2FREADME.md") + expect(node['data-branch']).to eq('master') + expect(node['data-commit-id']).to match(/\A[0-9a-f]{40}\z/) + expect(node['data-is-supported-content']).to eq('true') + expect(node['data-merge-requests-illustration-path']) + .to match(%r{/assets/illustrations/merge_requests-.*\.svg}) + expect(node['data-namespace']).to eq(project.namespace.full_path) + expect(node['data-project']).to eq(project.path) + expect(node['data-project-id']).to eq(project.id.to_s) + + # assert default config file values are present + expect(node['data-image-upload-path']).to eq('source/images') + expect(node['data-mounts']).to eq('[{"source":"source","target":""}]') + expect(node['data-static-site-generator']).to eq('middleman') + end end - it 'renders Static Site Editor page with generated and file attributes' do - # assert generated config value is present - expect(page).to have_css('#static-site-editor[data-branch="master"]') + context "when a config file is present" do + let(:config_file_yml) do + <<~YAML + image_upload_path: custom-image-upload-path + mounts: + - source: source1 + target: "" + - source: source2 + target: target2 + static_site_generator: middleman + YAML + end + + before do + allow_next_instance_of(Repository) do |repository| + allow(repository).to receive(:blob_data_at).and_return(config_file_yml) + end + + visit sse_path + end + + it 'renders Static Site Editor page values read from config file' do + node = page.find('#static-site-editor') - # assert file config value is present - expect(page).to have_css('#static-site-editor[data-static-site-generator="middleman"]') + # assert user-specified config file values are present + expected_mounts = '[{"source":"source1","target":""},{"source":"source2","target":"target2"}]' + expect(node['data-image-upload-path']).to eq('custom-image-upload-path') + expect(node['data-mounts']).to eq(expected_mounts) + expect(node['data-static-site-generator']).to eq('middleman') + end end end |