diff options
author | Xavier Noria <fxn@hashref.com> | 2016-09-01 23:41:49 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-09-01 23:41:49 +0200 |
commit | bb1ecdcc677bf6e68e0252505509c089619b5b90 (patch) | |
tree | 99dd8fd164e1c582216a4b08c3d066049217bb7f /railties | |
parent | 8c402ef425771c3dbb4659dd946714e69fdf5ce9 (diff) | |
download | rails-bb1ecdcc677bf6e68e0252505509c089619b5b90.tar.gz rails-bb1ecdcc677bf6e68e0252505509c089619b5b90.tar.bz2 rails-bb1ecdcc677bf6e68e0252505509c089619b5b90.zip |
fixes remaining RuboCop issues [Vipul A M, Xavier Noria]
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/app_loader.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/base.rb | 4 | ||||
-rw-r--r-- | railties/test/json_params_parsing_test.rb | 16 |
3 files changed, 11 insertions, 11 deletions
diff --git a/railties/lib/rails/app_loader.rb b/railties/lib/rails/app_loader.rb index 107e47de55..525d5f0161 100644 --- a/railties/lib/rails/app_loader.rb +++ b/railties/lib/rails/app_loader.rb @@ -50,7 +50,7 @@ EOS # If we exhaust the search there is no executable, this could be a # call to generate a new application, so restore the original cwd. - Dir.chdir(original_cwd) and return if Pathname.new(Dir.pwd).root? + Dir.chdir(original_cwd) && return if Pathname.new(Dir.pwd).root? # Otherwise keep moving upwards in search of an executable. Dir.chdir("..") diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index c0e34c20e7..1a0420c769 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -310,9 +310,9 @@ module Rails # Returns default for the option name given doing a lookup in config. def self.default_for_option(config, name, options, default) - if generator_name and c = config[generator_name.to_sym] and c.key?(name) + if generator_name && (c = config[generator_name.to_sym]) && c.key?(name) c[name] - elsif base_name and c = config[base_name.to_sym] and c.key?(name) + elsif base_name && (c = config[base_name.to_sym]) && c.key?(name) c[name] elsif config[:rails].key?(name) config[:rails][name] diff --git a/railties/test/json_params_parsing_test.rb b/railties/test/json_params_parsing_test.rb index 104664c1ee..7fff3bb465 100644 --- a/railties/test/json_params_parsing_test.rb +++ b/railties/test/json_params_parsing_test.rb @@ -6,7 +6,7 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest def test_prevent_null_query # Make sure we have data to find klass = Class.new(ActiveRecord::Base) do - def self.name; 'Foo'; end + def self.name; "Foo"; end establish_connection adapter: "sqlite3", database: ":memory:" connection.create_table "foos" do |t| t.string :title @@ -26,24 +26,24 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest end } - assert_nil app.call(make_env({ 't' => nil })) - assert_nil app.call(make_env({ 't' => [nil] })) + assert_nil app.call(make_env("t" => nil)) + assert_nil app.call(make_env("t" => [nil])) [[[nil]], [[[nil]]]].each do |data| - assert_nil app.call(make_env({ 't' => data })) + assert_nil app.call(make_env("t" => data)) end ensure klass.connection.drop_table("foos") end private - def make_env json + def make_env(json) data = JSON.dump json content_length = data.length { - 'CONTENT_LENGTH' => content_length, - 'CONTENT_TYPE' => 'application/json', - 'rack.input' => StringIO.new(data) + "CONTENT_LENGTH" => content_length, + "CONTENT_TYPE" => "application/json", + "rack.input" => StringIO.new(data) } end end |