diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/lib/gitlab/static_site_editor | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/lib/gitlab/static_site_editor')
-rw-r--r-- | spec/lib/gitlab/static_site_editor/config/file_config_spec.rb | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/static_site_editor/config/generated_config_spec.rb (renamed from spec/lib/gitlab/static_site_editor/config_spec.rb) | 48 |
2 files changed, 40 insertions, 23 deletions
diff --git a/spec/lib/gitlab/static_site_editor/config/file_config_spec.rb b/spec/lib/gitlab/static_site_editor/config/file_config_spec.rb new file mode 100644 index 00000000000..594425c2dab --- /dev/null +++ b/spec/lib/gitlab/static_site_editor/config/file_config_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::StaticSiteEditor::Config::FileConfig do + subject(:config) { described_class.new } + + describe '#data' do + subject { config.data } + + it 'returns hardcoded data for now' do + is_expected.to match(static_site_generator: 'middleman') + end + end +end diff --git a/spec/lib/gitlab/static_site_editor/config_spec.rb b/spec/lib/gitlab/static_site_editor/config/generated_config_spec.rb index 56cdb573785..3433a54be9c 100644 --- a/spec/lib/gitlab/static_site_editor/config_spec.rb +++ b/spec/lib/gitlab/static_site_editor/config/generated_config_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe Gitlab::StaticSiteEditor::Config do - subject(:config) { described_class.new(repository, ref, file_path, return_url) } +RSpec.describe Gitlab::StaticSiteEditor::Config::GeneratedConfig do + subject(:config) { described_class.new(repository, ref, path, return_url) } let_it_be(:namespace) { create(:namespace, name: 'namespace') } let_it_be(:root_group) { create(:group, name: 'group') } @@ -13,24 +13,26 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do let_it_be(:repository) { project.repository } let(:ref) { 'master' } - let(:file_path) { 'README.md' } + let(:path) { 'README.md' } let(:return_url) { 'http://example.com' } - describe '#payload' do - subject { config.payload } + describe '#data' do + subject { config.data } it 'returns data for the frontend component' do - is_expected.to eq( - branch: 'master', - commit_id: repository.commit.id, - namespace: 'namespace', - path: 'README.md', - project: 'project', - project_id: project.id, - return_url: 'http://example.com', - is_supported_content: 'true', - base_url: '/namespace/project/-/sse/master%2FREADME.md' - ) + is_expected + .to match({ + branch: 'master', + commit_id: repository.commit.id, + namespace: 'namespace', + path: 'README.md', + project: 'project', + project_id: project.id, + return_url: 'http://example.com', + is_supported_content: 'true', + base_url: '/namespace/project/-/sse/master%2FREADME.md', + merge_requests_illustration_path: %r{illustrations/merge_requests} + }) end context 'when namespace is a subgroup' do @@ -49,7 +51,7 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do before do repository.create_file( project.creator, - file_path, + path, '', message: 'message', branch_name: 'master' @@ -57,7 +59,7 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do end context 'when feature flag is enabled' do - let(:file_path) { 'FEATURE_ON.md.erb' } + let(:path) { 'FEATURE_ON.md.erb' } before do stub_feature_flags(sse_erb_support: project) @@ -67,7 +69,7 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do end context 'when feature flag is disabled' do - let(:file_path) { 'FEATURE_OFF.md.erb' } + let(:path) { 'FEATURE_OFF.md.erb' } before do stub_feature_flags(sse_erb_support: false) @@ -78,7 +80,7 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do end context 'when file path is nested' do - let(:file_path) { 'lib/README.md' } + let(:path) { 'lib/README.md' } it { is_expected.to include(base_url: '/namespace/project/-/sse/master%2Flib%2FREADME.md') } end @@ -90,19 +92,19 @@ RSpec.describe Gitlab::StaticSiteEditor::Config do end context 'when file does not have a markdown extension' do - let(:file_path) { 'README.txt' } + let(:path) { 'README.txt' } it { is_expected.to include(is_supported_content: 'false') } end context 'when file does not have an extension' do - let(:file_path) { 'README' } + let(:path) { 'README' } it { is_expected.to include(is_supported_content: 'false') } end context 'when file does not exist' do - let(:file_path) { 'UNKNOWN.md' } + let(:path) { 'UNKNOWN.md' } it { is_expected.to include(is_supported_content: 'false') } end |