Commit 29530857 authored by Nathan Friend's avatar Nathan Friend

Merge branch '212558-follow-up-parse-boolean' into 'master'

Refactor to use parseBoolean

See merge request gitlab-org/gitlab!30076
parents fd46e26d 04529170
import Vue from 'vue'; import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import StaticSiteEditor from './components/static_site_editor.vue'; import StaticSiteEditor from './components/static_site_editor.vue';
import createStore from './store'; import createStore from './store';
const initStaticSiteEditor = el => { const initStaticSiteEditor = el => {
const { projectId, path: sourcePath, returnUrl } = el.dataset; const { isSupportedContent, projectId, path: sourcePath, returnUrl } = el.dataset;
const isSupportedContent = 'isSupportedContent' in el.dataset;
const store = createStore({ const store = createStore({
initialState: { initialState: {
isSupportedContent, isSupportedContent: parseBoolean(isSupportedContent),
projectId, projectId,
returnUrl, returnUrl,
sourcePath, sourcePath,
......
...@@ -22,7 +22,7 @@ module Gitlab ...@@ -22,7 +22,7 @@ module Gitlab
project: project.path, project: project.path,
namespace: project.namespace.path, namespace: project.namespace.path,
return_url: return_url, return_url: return_url,
is_supported_content: supported_content? is_supported_content: supported_content?.to_s
} }
end end
......
...@@ -24,38 +24,38 @@ describe Gitlab::StaticSiteEditor::Config do ...@@ -24,38 +24,38 @@ describe Gitlab::StaticSiteEditor::Config do
project: 'project', project: 'project',
project_id: project.id, project_id: project.id,
return_url: 'http://example.com', return_url: 'http://example.com',
is_supported_content: true is_supported_content: 'true'
) )
end end
context 'when branch is not master' do context 'when branch is not master' do
let(:ref) { 'my-branch' } let(:ref) { 'my-branch' }
it { is_expected.to include(is_supported_content: false) } it { is_expected.to include(is_supported_content: 'false') }
end end
context 'when file does not have a markdown extension' do context 'when file does not have a markdown extension' do
let(:file_path) { 'README.txt' } let(:file_path) { 'README.txt' }
it { is_expected.to include(is_supported_content: false) } it { is_expected.to include(is_supported_content: 'false') }
end end
context 'when file does not have an extension' do context 'when file does not have an extension' do
let(:file_path) { 'README' } let(:file_path) { 'README' }
it { is_expected.to include(is_supported_content: false) } it { is_expected.to include(is_supported_content: 'false') }
end end
context 'when file does not exist' do context 'when file does not exist' do
let(:file_path) { 'UNKNOWN.md' } let(:file_path) { 'UNKNOWN.md' }
it { is_expected.to include(is_supported_content: false) } it { is_expected.to include(is_supported_content: 'false') }
end end
context 'when repository is empty' do context 'when repository is empty' do
let(:project) { create(:project_empty_repo) } let(:project) { create(:project_empty_repo) }
it { is_expected.to include(is_supported_content: false) } it { is_expected.to include(is_supported_content: 'false') }
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment