diff options
| author | Teddy Wing | 2017-12-13 18:28:01 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-12-13 18:30:58 +0100 | 
| commit | 6497b23e18385121974f6cbf56d48caf897e69b1 (patch) | |
| tree | 0a27c342b5527d53c103d4afadd55a07835de7e9 /app/models/referential.rb | |
| parent | 8ad2cf4ab09ed97cae8eee3840e89abe30018001 (diff) | |
| download | chouette-core-6497b23e18385121974f6cbf56d48caf897e69b1.tar.bz2 | |
Referential#save_with_table_lock_timeout: Add argument
I was getting test failures like this one:
    2) Workbenches show filtering filter by status should display archived referentials
       Failure/Error:
         def save_with_table_lock_timeout
           save_without_table_lock_timeout
         rescue ActiveRecord::StatementInvalid => e
           if e.message.include?('PG::LockNotAvailable')
             raise TableLockTimeoutError.new(e)
           else
             raise
           end
       ArgumentError:
         wrong number of arguments (given 1, expected 0)
       # ./app/models/referential.rb:64:in `save_with_table_lock_timeout'
       # .../.gem/ruby/2.3.3/gems/activerecord-4.2.8/lib/active_record/persistence.rb:241:in `update_attribute'
       # ./spec/features/workbenches_spec.rb:71:in `block (5 levels) in <top (required)>'
       # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
       # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `block in load'
       # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
       # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
       # .../.gem/ruby/2.3.3/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/command_wrapper.rb:38:in `call'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/application.rb:191:in `block in serve'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/application.rb:161:in `fork'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/application.rb:161:in `serve'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/application.rb:131:in `block in run'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/application.rb:125:in `loop'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/application.rb:125:in `run'
       # .../.gem/ruby/2.3.3/gems/spring-2.0.1/lib/spring/application/boot.rb:19:in `<top (required)>'
       # -e:1:in `<main>'
Sometimes an argument gets passed to the function and sometimes it
doesn't. Inspecting that argument in a debugger revealed what appeared
to be an options hash:
    (byebug) options
    {:validate=>false}
Add this optional argument to get past the test failures. At this point
I'm not even really considering whether this is a good idea or not, I
just want this to be done.
Refs #5024
Diffstat (limited to 'app/models/referential.rb')
| -rw-r--r-- | app/models/referential.rb | 4 | 
1 files changed, 2 insertions, 2 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index 6cdab8fb7..3a9ef2027 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -61,8 +61,8 @@ class Referential < ActiveRecord::Base    scope :order_by_validity_period, ->(dir) { joins(:metadatas).order("unnest(periodes) #{dir}") }    scope :order_by_lines, ->(dir) { joins(:metadatas).group("referentials.id").order("sum(array_length(referential_metadata.line_ids,1)) #{dir}") } -  def save_with_table_lock_timeout -    save_without_table_lock_timeout +  def save_with_table_lock_timeout(options = {}) +    save_without_table_lock_timeout(options)    rescue ActiveRecord::StatementInvalid => e      if e.message.include?('PG::LockNotAvailable')        raise TableLockTimeoutError.new(e) | 
