This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class C2CancelAttributes | ||
def initialize(auction) | ||
@auction = auction | ||
end | ||
|
||
def to_h | ||
{ | ||
status: 'cancelled', | ||
gsa18f_procurement: { | ||
additional_info: additional_info | ||
} | ||
} | ||
end | ||
|
||
private | ||
|
||
attr_accessor :auction | ||
|
||
def additional_info | ||
"Reason cancelled: #{reason_cancelled}" | ||
end | ||
|
||
def reason_cancelled | ||
if auction.archived? | ||
'the auction was archived' | ||
elsif auction.rejected? | ||
'the auction was rejected' | ||
else | ||
'unknown' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'rails_helper' | ||
|
||
describe C2CancelAttributes do | ||
describe '#to_h' do | ||
it 'constructs the right attributes for archived auctions' do | ||
auction = create(:auction, :archived) | ||
|
||
attributes = C2CancelAttributes.new(auction).to_h | ||
|
||
expect(attributes[:status]).to eq('cancelled') | ||
expect(attributes[:gsa18f_procurement][:additional_info]) | ||
.to eq('Reason cancelled: the auction was archived') | ||
end | ||
|
||
it 'constructs the right attributes for rejected auctions' do | ||
auction = create(:auction, :rejected) | ||
|
||
attributes = C2CancelAttributes.new(auction).to_h | ||
|
||
expect(attributes[:status]).to eq('cancelled') | ||
expect(attributes[:gsa18f_procurement][:additional_info]) | ||
.to eq('Reason cancelled: the auction was rejected') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters