Skip to content

Commit

Permalink
Remove extraneous square brackets around %w
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Dec 19, 2013
1 parent 1fa8a92 commit b82d32b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/rails_admin/main_controller.rb
Expand Up @@ -143,7 +143,7 @@ def get_association_scope_from_params
source_abstract_model = RailsAdmin::AbstractModel.new(to_model_name(params[:source_abstract_model]))
source_model_config = source_abstract_model.config
source_object = source_abstract_model.get(params[:source_object_id])
action = params[:current_action].in?([%w(create update)]) ? params[:current_action] : 'edit'
action = params[:current_action].in?(%w(create update)) ? params[:current_action] : 'edit'
@association = source_model_config.send(action).fields.detect { |f| f.name == params[:associated_collection].to_sym }.with(:controller => self, :object => source_object)
@association.associated_collection_scope
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_admin/config/fields/types/datetime.rb
Expand Up @@ -97,7 +97,7 @@ def js_plugin_options
'value' => formatted_date_value,
},
'timepicker' => {
'amPmText' => meridian_indicator? ? [%w(Am Pm)] : ['', ''],
'amPmText' => meridian_indicator? ? %w(Am Pm) : ['', ''],
'hourText' => I18n.t('datetime.prompts.hour', :default => I18n.t('datetime.prompts.hour', :locale => :en)),
'minuteText' => I18n.t('datetime.prompts.minute', :default => I18n.t('datetime.prompts.minute', :locale => :en)),
'showPeriod' => meridian_indicator?,
Expand Down
Expand Up @@ -14,7 +14,7 @@

it 'works for static names' do
RailsAdmin.config do |config|
config.main_app_name = [%w(static value)]
config.main_app_name = %w(static value)
end
expect(controller.send(:_get_plugin_name)).to eq(%w(static value))
end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/config/edit/rails_admin_config_edit_spec.rb
Expand Up @@ -1002,7 +1002,7 @@ def color_list
Team.instance_eval do
serialize :color
def color_enum
[%w(blue green red)]
%w(blue green red)
end
end
visit new_path(:model_name => 'team')
Expand All @@ -1023,7 +1023,7 @@ def color_enum
Team.instance_eval do
field :color, :type => Array
def color_enum
[%w(blue green red)]
%w(blue green red)
end
end
visit new_path(:model_name => 'team')
Expand Down
14 changes: 7 additions & 7 deletions spec/rails_admin/adapters/mongoid_spec.rb
Expand Up @@ -77,7 +77,7 @@ class MongoNote
end

it 'reads correct and know types in [:belongs_to, :has_and_belongs_to_many, :has_many, :has_one]' do
expect((@post.associations + @blog.associations + @user.associations).map { |a|a[:type].to_s }.uniq).to match_array [%w(belongs_to has_and_belongs_to_many has_many has_one)]
expect((@post.associations + @blog.associations + @user.associations).map { |a|a[:type].to_s }.uniq).to match_array %w(belongs_to has_and_belongs_to_many has_many has_one)
end

it 'has correct parameter of belongs_to association' do
Expand Down Expand Up @@ -143,7 +143,7 @@ class MongoNote
end

it 'has correct parameter of polymorphic belongs_to association' do
allow(RailsAdmin::Config).to receive(:models_pool).and_return([%w(MongoBlog MongoPost MongoCategory MongoUser MongoProfile MongoComment)])
allow(RailsAdmin::Config).to receive(:models_pool).and_return(%w(MongoBlog MongoPost MongoCategory MongoUser MongoProfile MongoComment))
param = @comment.associations.detect { |a| a[:name] == :commentable }
expect(param.reject { |k, v| [:primary_key_proc, :model_proc].include? k }).to eq(
:name => :commentable,
Expand All @@ -163,7 +163,7 @@ class MongoNote
end

it 'has correct parameter of polymorphic inverse has_many association' do
allow(RailsAdmin::Config).to receive(:models_pool).and_return([%w(MongoBlog MongoPost MongoCategory MongoUser MongoProfile MongoComment)])
allow(RailsAdmin::Config).to receive(:models_pool).and_return(%w(MongoBlog MongoPost MongoCategory MongoUser MongoProfile MongoComment))
param = @blog.associations.detect { |a| a[:name] == :mongo_comments }
expect(param.reject { |k, v| [:primary_key_proc, :model_proc].include? k }).to eq(
:name => :mongo_comments,
Expand All @@ -183,7 +183,7 @@ class MongoNote
end

it 'has correct opposite model lookup for polymorphic associations' do
allow(RailsAdmin::Config).to receive(:models_pool).and_return([%w(MongoBlog MongoPost MongoCategory MongoUser MongoProfile MongoComment)])
allow(RailsAdmin::Config).to receive(:models_pool).and_return(%w(MongoBlog MongoPost MongoCategory MongoUser MongoProfile MongoComment))
expect(@category.associations.detect { |a| a[:name] == :librarian }[:model_proc].call).to eq [MongoUser]
expect(@blog.associations.detect { |a| a[:name] == :librarian }[:model_proc].call).to eq [MongoProfile]
end
Expand Down Expand Up @@ -692,10 +692,10 @@ class CustomValiated
end

it 'supports boolean type query' do
[%w(false f 0)].each do |value|
%w(false f 0).each do |value|
expect(@abstract_model.send(:build_statement, :field, :boolean, value, nil)).to eq(:field => false)
end
[%w(true t 1)].each do |value|
%w(true t 1).each do |value|
expect(@abstract_model.send(:build_statement, :field, :boolean, value, nil)).to eq(:field => true)
end
expect(@abstract_model.send(:build_statement, :field, :boolean, 'word', nil)).to be_nil
Expand All @@ -712,7 +712,7 @@ class CustomValiated
expect(@abstract_model.send(:build_statement, :field, :integer, ['', '3', ''], 'between')).to eq(:field => {'$gte' => 3})
expect(@abstract_model.send(:build_statement, :field, :integer, ['', '', '5'], 'between')).to eq(:field => {'$lte' => 5})
expect(@abstract_model.send(:build_statement, :field, :integer, ['' , '10', '20'], 'between')).to eq(:field => {'$gte' => 10, '$lte' => 20})
expect(@abstract_model.send(:build_statement, :field, :integer, [%w(15 10 20)], 'between')).to eq(:field => {'$gte' => 10, '$lte' => 20})
expect(@abstract_model.send(:build_statement, :field, :integer, %w(15 10 20), 'between')).to eq(:field => {'$gte' => 10, '$lte' => 20})
expect(@abstract_model.send(:build_statement, :field, :integer, ['', 'word1', ''], 'between')).to be_nil
expect(@abstract_model.send(:build_statement, :field, :integer, ['', '' , 'word2'], 'between')).to be_nil
expect(@abstract_model.send(:build_statement, :field, :integer, ['', 'word3', 'word4'], 'between')).to be_nil
Expand Down

0 comments on commit b82d32b

Please sign in to comment.