-
-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/redesign-conferences
* develop: Ignore the problematics HTML validation checks with hidden inputs (#10020) Fix proposal etiquette and length validator with base64 images (#9639)
- Loading branch information
Showing
5 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
decidim-dev/lib/decidim/dev/test/w3c_rspec_validators_overrides.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
decidim-proposals/spec/validators/proposal_length_validator_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe ProposalLengthValidator do | ||
subject { validatable.new(body:) } | ||
|
||
let(:validatable) do | ||
Class.new do | ||
def self.model_name | ||
ActiveModel::Name.new(self, nil, "Validatable") | ||
end | ||
|
||
include Decidim::AttributeObject::Model | ||
include ActiveModel::Validations | ||
|
||
attribute :body | ||
|
||
validates :body, proposal_length: { | ||
minimum: 15, | ||
maximum: ->(_record) { 100 } | ||
} | ||
end | ||
end | ||
|
||
context "when the text is too short" do | ||
let(:body) { "Lorem ipsum d" } | ||
|
||
it { is_expected.to be_invalid } | ||
end | ||
|
||
context "when the text is too long" do | ||
let(:body) { "a" * 101 } | ||
|
||
it { is_expected.to be_invalid } | ||
end | ||
|
||
context "when the text is written in HTML" do | ||
let(:body) do | ||
data = File.read(Decidim::Dev.asset("avatar.jpg")) | ||
encoded = Base64.encode64(data) | ||
|
||
<<~HTML | ||
<p>Text before the image.</p> | ||
<p><img src="data:image/jpeg;base64,#{encoded.strip}"></p> | ||
<p>Some other text after the image.</p> | ||
HTML | ||
end | ||
|
||
it { is_expected.to be_valid } | ||
end | ||
end |