mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 21:46:24 +02:00
assign auction type for nil value rake task
This commit is contained in:
parent
73a4364196
commit
3fc79f96c2
2 changed files with 39 additions and 0 deletions
12
lib/tasks/assing_auction_platform_type.rake
Normal file
12
lib/tasks/assing_auction_platform_type.rake
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
namespace :auction do
|
||||||
|
desc 'Check closed disputes with expired_at in the Past'
|
||||||
|
task assign_platform_type: :environment do
|
||||||
|
auctions = Auction.where(platform: nil)
|
||||||
|
|
||||||
|
auctions.each do |auction|
|
||||||
|
auction.update(platform: :auto)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
27
test/tasks/assign_auction_platform_type_test.rb
Normal file
27
test/tasks/assign_auction_platform_type_test.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class AssignAuctionPlatformTypeTest < ActiveSupport::TestCase
|
||||||
|
setup do
|
||||||
|
@auction_one = auctions(:one)
|
||||||
|
@auction_two = auctions(:idn)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_output
|
||||||
|
assert_nil @auction_one.platform
|
||||||
|
assert_nil @auction_two.platform
|
||||||
|
|
||||||
|
run_task
|
||||||
|
|
||||||
|
@auction_one.reload
|
||||||
|
@auction_two.reload
|
||||||
|
|
||||||
|
assert_equal @auction_one.platform, "auto"
|
||||||
|
assert_equal @auction_two.platform, "auto"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def run_task
|
||||||
|
Rake::Task['auction:assign_platform_type'].execute
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue