Skip to content

Commit

Permalink
Use obj.deep_dup instead of Marshal.load(Marshal.dump(obj))
Browse files Browse the repository at this point in the history
...and other wonky fixes to appease rubocop
  • Loading branch information
tjgrathwell committed Feb 15, 2017
1 parent 5dcdd90 commit d38fb0c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ AllCops:
- 'db/migrate/20151210035820_init_schema.rb'
- 'db/schema.rb'

Bundler/OrderedGems:
Enabled: false

Lint/BlockAlignment:
Exclude:
- 'lib/tasks/db.rake'
Expand All @@ -29,6 +32,9 @@ Lint/Void:
Metrics/AbcSize:
Max: 160

Metrics/BlockLength:
Enabled: false

Metrics/ClassLength:
Max: 500
Exclude:
Expand Down Expand Up @@ -134,6 +140,9 @@ Style/EmptyLinesAroundMethodBody:
Style/EmptyLinesAroundModuleBody:
Enabled: false

Style/EmptyMethod:
Enabled: false

Style/ExtraSpacing:
Exclude:
- 'bin/setup'
Expand Down
2 changes: 1 addition & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Dir.chdir APP_ROOT do

require 'yaml'
require 'erb'
db_config = YAML.load(ERB.new(File.read("config/database.yml")).result)
db_config = YAML.safe_load(ERB.new(File.read("config/database.yml")).result)
if File.exist?(db_config['development']['database'])
puts "Database already exists, running migrations..."
system "bin/rake db:migrate"
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Application < Rails::Application
config.middleware.insert_before 0, "Rack::Cors" do
allow do
origins 'bridgefoundry.org'
resource '/events.json', :headers => :any, :methods => [:get]
resource '/events.json', headers: :any, methods: [:get]
end
end
end
Expand Down
8 changes: 2 additions & 6 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,6 @@
@session1 = @event.event_sessions.first
@session2 = create(:event_session, event: @event)

def deep_copy(o)
Marshal.load(Marshal.dump(o))
end

expectation = {
Role::VOLUNTEER.id => {
@session1.id => [],
Expand All @@ -491,8 +487,8 @@ def deep_copy(o)
@session2.id => []
}
}
@rsvps = deep_copy(expectation)
@checkins = deep_copy(expectation)
@rsvps = expectation.deep_dup
@checkins = expectation.deep_dup

def add_rsvp(factory, session_checkins, additional_rsvp_options = {})
rsvp_options = {
Expand Down

0 comments on commit d38fb0c

Please sign in to comment.