Allow wiki pages to be empty

In this commit we allow wiki pages to be empty (mostly removing
the validation in the backend).

This aligns the existing behavior because users can push
wiki empty pages through git and that will trigger an error
because of the existing validator.

Changelog: changed
parent 737ec1bb
...@@ -40,7 +40,6 @@ class WikiPage ...@@ -40,7 +40,6 @@ class WikiPage
end end
validates :title, presence: true validates :title, presence: true
validates :content, presence: true
validate :validate_path_limits, if: :title_changed? validate :validate_path_limits, if: :title_changed?
validate :validate_content_size_limit, if: :content_changed? validate :validate_content_size_limit, if: :content_changed?
......
...@@ -201,11 +201,10 @@ RSpec.describe WikiPage do ...@@ -201,11 +201,10 @@ RSpec.describe WikiPage do
expect(subject.errors.messages).to eq(title: ["can't be blank"]) expect(subject.errors.messages).to eq(title: ["can't be blank"])
end end
it "validates presence of content" do it "does not validate presence of content" do
subject.attributes.delete(:content) subject.attributes.delete(:content)
expect(subject).not_to be_valid expect(subject).to be_valid
expect(subject.errors.messages).to eq(content: ["can't be blank"])
end end
describe '#validate_content_size_limit' do describe '#validate_content_size_limit' do
......
...@@ -20,17 +20,6 @@ RSpec.shared_examples 'User creates wiki page' do ...@@ -20,17 +20,6 @@ RSpec.shared_examples 'User creates wiki page' do
click_link "Create your first page" click_link "Create your first page"
end end
it "shows validation error message if the form is force submitted", :js do
page.within(".wiki-form") do
fill_in(:wiki_content, with: "")
page.execute_script("document.querySelector('.wiki-form').submit()")
page.accept_alert # manually force form submit
end
expect(page).to have_content("The form contains the following error:").and have_content("Content can't be blank")
end
it "disables the submit button", :js do it "disables the submit button", :js do
page.within(".wiki-form") do page.within(".wiki-form") do
fill_in(:wiki_content, with: "") fill_in(:wiki_content, with: "")
......
...@@ -90,19 +90,6 @@ RSpec.shared_examples 'User updates wiki page' do ...@@ -90,19 +90,6 @@ RSpec.shared_examples 'User updates wiki page' do
expect(page).to have_field('wiki[message]', with: 'Update Wiki title') expect(page).to have_field('wiki[message]', with: 'Update Wiki title')
end end
it 'shows a validation error message if the form is force submitted', :js do
fill_in(:wiki_content, with: '')
page.execute_script("document.querySelector('.wiki-form').submit()")
page.accept_alert # manually force form submit
expect(page).to have_selector('.wiki-form')
expect(page).to have_content('Edit Page')
expect(page).to have_content('The form contains the following error:')
expect(page).to have_content("Content can't be blank")
expect(find('textarea#wiki_content').value).to eq('')
end
it "disables the submit button", :js do it "disables the submit button", :js do
page.within(".wiki-form") do page.within(".wiki-form") do
fill_in(:wiki_content, with: "") fill_in(:wiki_content, with: "")
......
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