Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix Rubocop offenses

  • Loading branch information...
commit 3f511ada34cd2aac5ca551127af3937cc229ce3a 1 parent 622f1cc
@linchus linchus authored
View
7 lib/rails_admin/config/fields/types/json.rb
@@ -6,7 +6,7 @@ module Fields
module Types
class Json < RailsAdmin::Config::Fields::Types::Text
# Register field type for the type loader
- RailsAdmin::Config::Fields::Types::register(self)
+ RailsAdmin::Config::Fields::Types.register(self)
register_instance_option :formatted_value do
value.present? ? JSON.pretty_generate(value) : nil
@@ -14,12 +14,11 @@ class Json < RailsAdmin::Config::Fields::Types::Text
def parse_input(params)
if params[name].is_a?(::String)
- params[name] = (params[name].blank? ? nil : JSON.parse(params[name]) )
+ params[name] = (params[name].blank? ? nil : JSON.parse(params[name]))
end
end
-
end
end
end
end
-end
+end
View
12 spec/rails_admin/config/fields/types/json_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe RailsAdmin::Config::Fields::Types::Json do
- describe "#parse_input", :active_record => true do
- let(:field){ RailsAdmin.config(FieldTest).fields.find{ |f| f.name == :json_field } }
+ describe '#parse_input', active_record: true do
+ let(:field) { RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :json_field } }
before :each do
RailsAdmin.config do |config|
config.model FieldTest do
@@ -11,13 +11,13 @@
end
end
- it "parse valid json string" do
- data = {string: 'string', integer: 1, array: [1,2,3], object: {bla:'foo'} }.as_json
+ it 'parse valid json string' do
+ data = {string: 'string', integer: 1, array: [1, 2, 3], object: {bla: 'foo'}}.as_json
expect(field.parse_input(json_field: data.to_json)).to eq data
end
- it "raise JSON::ParserError with invalid json string" do
- expect{ field.parse_input(json_field: '{{') }.to raise_error(JSON::ParserError)
+ it 'raise JSON::ParserError with invalid json string' do
+ expect { field.parse_input(json_field: '{{') }.to raise_error(JSON::ParserError)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.