Permalink
Browse files

Consistently use hash colon

  • Loading branch information...
1 parent 8162da0 commit dcf58d9c53a6c777a6179c8af97f7c3e9699bc3e @sferik committed Mar 24, 2014
View
4 lib/rails_admin/adapters/active_record.rb
@@ -64,8 +64,8 @@ def properties
name: property.name.to_sym,
pretty_name: property.name.to_s.tr('_', ' ').capitalize,
length: property.limit,
- :nullable? => property.null,
- :serial? => property.primary,
+ nullable?: property.null,
+ serial?: property.primary,
}.merge(type_lookup(property))
end
end
View
8 lib/rails_admin/adapters/mongoid.rb
@@ -71,8 +71,8 @@ def properties
name: field.name.to_sym,
length: nil,
pretty_name: field.name.to_s.gsub('_', ' ').strip.capitalize,
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
}.merge(type_lookup(name, field))
end
end
@@ -163,8 +163,8 @@ def type_lookup(name, field)
'BigDecimal' => {type: :decimal},
'Mongoid::Boolean' => {type: :boolean},
'Boolean' => {type: :boolean},
- 'BSON::ObjectId' => {type: :bson_object_id, :serial? => (name == primary_key)},
- 'Moped::BSON::ObjectId' => {type: :bson_object_id, :serial? => (name == primary_key)},
+ 'BSON::ObjectId' => {type: :bson_object_id, serial?: (name == primary_key)},
+ 'Moped::BSON::ObjectId' => {type: :bson_object_id, serial?: (name == primary_key)},
'Date' => {type: :date},
'DateTime' => {type: :datetime},
'ActiveSupport::TimeWithZone' => {type: :datetime},
View
7 rails_admin.gemspec
@@ -23,11 +23,12 @@ Gem::Specification.new do |spec|
spec.description = %q(RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.)
spec.email = ['sferik@gmail.com', 'bogdan@cadmio.org', 'petteri.kaapa@gmail.com']
spec.files = Dir['Gemfile', 'LICENSE.md', 'README.md', 'Rakefile', 'app/**/*', 'config/**/*', 'lib/**/*', 'public/**/*']
- spec.licenses = ['MIT']
+ spec.licenses = %w[MIT]
spec.homepage = 'https://github.com/sferik/rails_admin'
spec.name = 'rails_admin'
- spec.require_paths = ['lib']
- spec.required_rubygems_version = '>= 1.3.5'
+ spec.require_paths = %w[lib]
+ spec.required_ruby_version = '>= 1.9.3'
+ spec.required_rubygems_version = '>= 1.8.11'
spec.summary = %q(Admin for Rails)
spec.test_files = Dir['spec/**/*'].reject { |f| f.end_with? 'log' }
spec.version = RailsAdmin::Version
View
4 spec/rails_admin/adapters/active_record_spec.rb
@@ -163,11 +163,11 @@ class ARComment < ActiveRecord::Base
describe '#properties' do
it 'returns parameters of string-type field' do
- expect(RailsAdmin::AbstractModel.new('Player').properties.select { |f| f[:name] == :name }).to eq([{name: :name, pretty_name: 'Name', type: :string, length: 100, :nullable? => false, :serial? => false}])
+ expect(RailsAdmin::AbstractModel.new('Player').properties.select { |f| f[:name] == :name }).to eq([{name: :name, pretty_name: 'Name', type: :string, length: 100, nullable?: false, serial?: false}])
end
it 'maps serialized attribute to :serialized field type' do
- expect(RailsAdmin::AbstractModel.new('User').properties.detect { |f| f[:name] == :roles }).to eq(name: :roles, pretty_name: 'Roles', length: 255, :nullable? => true, :serial? => false, type: :serialized)
+ expect(RailsAdmin::AbstractModel.new('User').properties.detect { |f| f[:name] == :roles }).to eq(name: :roles, pretty_name: 'Roles', length: 255, nullable?: true, serial?: false, type: :serialized)
end
end
View
84 spec/rails_admin/adapters/mongoid_spec.rb
@@ -291,128 +291,128 @@ class MongoEmbedsChild < MongoEmbedsParent; end
expect(@abstract_model.properties.select { |p| properties.include? p[:name].to_s }).to match_array [
{name: :_id,
pretty_name: 'Id',
- :nullable? => true,
- :serial? => true,
+ nullable?: true,
+ serial?: true,
type: :bson_object_id,
length: nil},
{name: :array_field,
pretty_name: 'Array field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :serialized,
length: nil},
{name: :big_decimal_field,
pretty_name: 'Big decimal field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :decimal,
length: nil},
{name: :boolean_field,
pretty_name: 'Boolean field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :boolean,
length: nil},
{name: :bson_object_id_field,
pretty_name: 'Bson object id field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :bson_object_id,
length: nil},
{name: :date_field,
pretty_name: 'Date field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :date,
length: nil},
{name: :datetime_field,
pretty_name: 'Datetime field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :datetime,
length: nil},
{name: :time_with_zone_field,
pretty_name: 'Time with zone field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :datetime,
length: nil},
{name: :default_field,
pretty_name: 'Default field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :string,
length: 255},
{name: :float_field,
pretty_name: 'Float field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :float,
length: nil},
{name: :hash_field,
pretty_name: 'Hash field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :serialized,
length: nil},
{name: :integer_field,
pretty_name: 'Integer field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :integer,
length: nil},
{name: :name,
pretty_name: 'Name',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :string,
length: 255},
{name: :object_field,
pretty_name: 'Object field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :string,
length: 255},
{name: :short_text,
pretty_name: 'Short text',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :string,
length: 255},
{name: :string_field,
pretty_name: 'String field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :text,
length: nil},
{name: :subject,
pretty_name: 'Subject',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :string,
length: 255},
{name: :symbol_field,
pretty_name: 'Symbol field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :string,
length: 255},
{name: :text_field,
pretty_name: 'Text field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :text,
length: nil},
{name: :time_field,
pretty_name: 'Time field',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :datetime,
length: nil},
{name: :title,
pretty_name: 'Title',
- :nullable? => true,
- :serial? => false,
+ nullable?: true,
+ serial?: false,
type: :string,
length: 255}
]
View
12 spec/rails_admin/config/actions/base_spec.rb
@@ -11,9 +11,9 @@
end
end
end
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Player))).to be_visible
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_nil
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Cms::BasicPage))).to be_visible
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Player))).to be_visible
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_nil
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Cms::BasicPage))).to be_visible
end
it 'excludes models referenced in the except array' do
@@ -24,9 +24,9 @@
end
end
end
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Player))).to be_nil
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_visible
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Cms::BasicPage))).to be_nil
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Player))).to be_nil
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_visible
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Cms::BasicPage))).to be_nil
end
end
end
View
8 spec/rails_admin/config/actions_spec.rb
@@ -51,16 +51,16 @@
hide
end
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Comment))).to be_a(RailsAdmin::Config::Actions::Index) # decoy
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_nil
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Comment))).to be_a(RailsAdmin::Config::Actions::Index) # decoy
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_nil
end
it "checks bindings[:abstract_model] presence while checking action\'s visibility" do
RailsAdmin.config do |config|
config.excluded_models << Team
end
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Comment))).to be_a(RailsAdmin::Config::Actions::Index) # decoy
- expect(RailsAdmin::Config::Actions.find(:index, controller: double(:authorized? => true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_nil
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Comment))).to be_a(RailsAdmin::Config::Actions::Index) # decoy
+ expect(RailsAdmin::Config::Actions.find(:index, controller: double(authorized?: true), abstract_model: RailsAdmin::AbstractModel.new(Team))).to be_nil
end
end
View
10 spec/rails_admin/config_spec.rb
@@ -234,23 +234,23 @@ class Version; end
end
end
- expect(RailsAdmin.config.visible_models(controller: double(_current_user: double(role: :admin), :authorized? => true)).collect(&:abstract_model).collect(&:model)).to match_array [Fan, Comment]
+ expect(RailsAdmin.config.visible_models(controller: double(_current_user: double(role: :admin), authorized?: true)).collect(&:abstract_model).collect(&:model)).to match_array [Fan, Comment]
end
it 'hides unallowed models' do
RailsAdmin.config do |config|
config.included_models = [Comment]
end
- expect(RailsAdmin.config.visible_models(controller: double(:authorized? => true)).collect(&:abstract_model).collect(&:model)).to eq([Comment])
- expect(RailsAdmin.config.visible_models(controller: double(:authorized? => false)).collect(&:abstract_model).collect(&:model)).to eq([])
+ expect(RailsAdmin.config.visible_models(controller: double(authorized?: true)).collect(&:abstract_model).collect(&:model)).to eq([Comment])
+ expect(RailsAdmin.config.visible_models(controller: double(authorized?: false)).collect(&:abstract_model).collect(&:model)).to eq([])
end
it 'does not contain embedded model', mongoid: true do
RailsAdmin.config do |config|
config.included_models = [FieldTest, Comment, Embed]
end
- expect(RailsAdmin.config.visible_models(controller: double(_current_user: double(role: :admin), :authorized? => true)).collect(&:abstract_model).collect(&:model)).to match_array [FieldTest, Comment]
+ expect(RailsAdmin.config.visible_models(controller: double(_current_user: double(role: :admin), authorized?: true)).collect(&:abstract_model).collect(&:model)).to match_array [FieldTest, Comment]
end
it 'basically does not contain embedded model except model using recursively_embeds_many or recursively_embeds_one', mongoid: true do
@@ -265,7 +265,7 @@ class RecursivelyEmbedsMany
RailsAdmin.config do |config|
config.included_models = [FieldTest, Comment, Embed, RecursivelyEmbedsMany, RecursivelyEmbedsOne]
end
- expect(RailsAdmin.config.visible_models(controller: double(_current_user: double(role: :admin), :authorized? => true)).collect(&:abstract_model).collect(&:model)).to match_array [FieldTest, Comment, RecursivelyEmbedsMany, RecursivelyEmbedsOne]
+ expect(RailsAdmin.config.visible_models(controller: double(_current_user: double(role: :admin), authorized?: true)).collect(&:abstract_model).collect(&:model)).to match_array [FieldTest, Comment, RecursivelyEmbedsMany, RecursivelyEmbedsOne]
end
end

0 comments on commit dcf58d9

Please sign in to comment.