Commit 04529170 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Make `is_supported_content` to return a boolean string

There is a specific behavior how HAML treats booleans.

* If value is true, then the data attribute key is present but
it has no value.
* If value is false, then the data attribute key is missing.

Such behavior makes it more difficult to fetch data attributes on
frontend side. It seems to be a common approach in GitLab codebase to
use boolean strings and parse them.
parent c8ed7ba6
...@@ -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