Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify configs for numeric field types
Addresses issues raised by CodeClimate in https://codeclimate.com/github/sferik/rails_admin/pull/3378 and further consolidates a shared base field config for numeric types
- Loading branch information
1 parent
685cc7b
commit 6a1a126
Showing
5 changed files
with
41 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'rails_admin/config/fields/base' | ||
|
||
module RailsAdmin | ||
module Config | ||
module Fields | ||
module Types | ||
class Numeric < RailsAdmin::Config::Fields::Base | ||
# Register field type for the type loader | ||
RailsAdmin::Config::Fields::Types.register(self) | ||
|
||
register_instance_option :view_helper do | ||
:number_field | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe RailsAdmin::Config::Fields::Types::Numeric do | ||
it_behaves_like 'a generic field type', :integer_field, :integer | ||
|
||
subject do | ||
RailsAdmin.config('FieldTest').fields.detect do |f| | ||
f.name == :integer_field | ||
end.with(object: FieldTest.new) | ||
end | ||
|
||
describe '#view_helper' do | ||
it "uses the 'number' type input tag" do | ||
expect(subject.view_helper).to eq(:number_field) | ||
end | ||
end | ||
end |