-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: make bowser validations configurable via DSL
- Loading branch information
Showing
39 changed files
with
223 additions
and
6 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::MainHelper, type: :helper do | ||
describe '#rails_admin_form_for' do | ||
let(:html_form) do | ||
helper.rails_admin_form_for(FieldTest.new, url: new_path(model_name: 'field_test')) {} | ||
end | ||
|
||
context 'with html5 browser_validations enabled' do | ||
before do | ||
RailsAdmin.config.browser_validations = true | ||
RailsAdmin.config FieldTest do | ||
field :address, :string do | ||
required true | ||
end | ||
end | ||
end | ||
|
||
it 'should not add novalidate attribute to the html form tag' do | ||
expect(html_form).to_not include 'novalidate' | ||
end | ||
end | ||
|
||
context 'with html5 browser_validations disabled' do | ||
before do | ||
RailsAdmin.config.browser_validations = false | ||
RailsAdmin.config FieldTest do | ||
field :address, :string do | ||
required true | ||
end | ||
end | ||
end | ||
|
||
it 'should add novalidate attribute to the html form tag' do | ||
expect(html_form).to include "novalidate=\"novalidate\"" | ||
end | ||
end | ||
end | ||
end |
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
5 changes: 5 additions & 0 deletions
5
spec/rails_admin/config/fields/types/belongs_to_association_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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::BelongsToAssociation do | ||
it_behaves_like 'a generic field type', :integer_field, :belongs_to_association | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Boolean do | ||
it_behaves_like 'a generic field type', :boolean_field, :boolean | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::BsonObjectId do | ||
it_behaves_like 'a generic field type', :string_field, :bson_object_id | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Carrierwave do | ||
it_behaves_like 'a generic field type', :string_field, :carrierwave | ||
end |
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 |
---|---|---|
|
@@ -21,4 +21,6 @@ | |
).to eq @custom_prefix | ||
end | ||
end | ||
|
||
it_behaves_like 'a generic field type', :text_field, :ck_editor | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::CodeMirror do | ||
it_behaves_like 'a generic field type', :text_field, :code_mirror | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Color do | ||
it_behaves_like 'a generic field type', :string_field, :color | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Date do | ||
it_behaves_like 'a generic field type', :date_field, :date | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Decimal do | ||
it_behaves_like 'a generic field type', :decimal_field, :decimal | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Dragonfly do | ||
it_behaves_like 'a generic field type', :string_field, :dragonfly | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Enum do | ||
it_behaves_like 'a generic field type', :string_field, :enum | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::FileUpload do | ||
it_behaves_like 'a generic field type', :string_field, :file_upload | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Float do | ||
it_behaves_like 'a generic field type', :float_field, :float | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Froala do | ||
it_behaves_like 'a generic field type', :text_field, :froala | ||
end |
5 changes: 5 additions & 0 deletions
5
spec/rails_admin/config/fields/types/has_and_belongs_to_many_association_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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::HasAndBelongsToManyAssociation do | ||
it_behaves_like 'a generic field type', :integer_field, :has_and_belongs_to_many_association | ||
end |
5 changes: 5 additions & 0 deletions
5
spec/rails_admin/config/fields/types/has_many_association_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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::HasManyAssociation do | ||
it_behaves_like 'a generic field type', :integer_field, :has_many_association | ||
end |
5 changes: 5 additions & 0 deletions
5
spec/rails_admin/config/fields/types/has_one_association_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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::HasOneAssociation do | ||
it_behaves_like 'a generic field type', :integer_field, :has_one_association | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Hidden do | ||
it_behaves_like 'a generic field type', :integer_field, :hidden | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Inet do | ||
it_behaves_like 'a generic field type', :string_field, :inet | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Integer do | ||
it_behaves_like 'a generic field type', :integer_field, :integer | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Paperclip do | ||
it_behaves_like 'a generic field type', :string_field, :paperclip | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Password do | ||
it_behaves_like 'a generic field type', :string_field, :password | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Serialized do | ||
it_behaves_like 'a generic field type', :text_field, :serialized | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Text do | ||
it_behaves_like 'a generic field type', :text_field, :text | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Time do | ||
it_behaves_like 'a generic field type', :time_field, :time | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe RailsAdmin::Config::Fields::Types::Wysihtml5 do | ||
it_behaves_like 'a generic field type', :text_field, :wysihtml5 | ||
end |
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,25 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.shared_examples 'a generic field type' do |column_name, field_type| | ||
describe '#html_attributes' do | ||
context 'when the field is required' do | ||
before do | ||
RailsAdmin.config FieldTest do | ||
field column_name, field_type do | ||
required true | ||
end | ||
end | ||
end | ||
|
||
let :rails_admin_field do | ||
RailsAdmin.config('FieldTest').fields.detect do |f| | ||
f.name == column_name | ||
end.with(object: FieldTest.new) | ||
end | ||
|
||
it 'should contain a required attribute with the string "required" as value' do | ||
expect(rails_admin_field.html_attributes[:required]).to be_truthy | ||
end | ||
end | ||
end | ||
end |
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