Skip to content

Commit

Permalink
spec added
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshumishra31 committed Apr 20, 2018
1 parent 914f8d3 commit 276387a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/factories/gift_cards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,11 @@
amount { 100.00 }
authorization_code { "#{gift_card.id}-SC-20140602164814476128" }
end

factory :gift_card_capture_transaction, class: Spree::GiftCardTransaction do
gift_card
action { Spree::GiftCard::CAPTURE_ACTION }
amount { 100.00 }
authorization_code { "#{gift_card.id}-SC-20140602164814476128" }
end
end
15 changes: 15 additions & 0 deletions spec/models/spree/gift_card_transaction_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
require 'spec_helper'

describe Spree::GiftCardTransaction do
let(:gift_card_authorize_transaction) { FactoryBot.create(:gift_card_transaction) }
let(:gift_card_capture_transaction) { FactoryBot.create(:gift_card_capture_transaction) }

it { is_expected.to belong_to(:gift_card) }
it { is_expected.to belong_to(:order) }
it { is_expected.to validate_presence_of(:amount) }
it { is_expected.to validate_presence_of(:gift_card) }

describe 'scope' do
describe 'authorize' do
it 'is expected to include gift card authorize transactions' do
expect(Spree::GiftCardTransaction.authorize).to include(gift_card_authorize_transaction)
end

it 'is expect to not include gift card capture transactions' do
expect(Spree::GiftCardTransaction.authorize).not_to include(gift_card_capture_transaction)
end
end
end
end

0 comments on commit 276387a

Please sign in to comment.