Verified Commit 9ac2c7d0 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

add test for group offer model methods and terminated scope

parent 2192517f
......@@ -65,4 +65,12 @@ class GroupOfferScopesTest < ActiveSupport::TestCase
assert query.include? created_before
refute query.include? created_after
end
test 'terminated' do
terminated_go = create :group_offer, :terminated
unterminated_go = create :group_offer
query = GroupOffer.terminated
assert query.include? terminated_go
refute query.include? unterminated_go
end
end
require 'test_helper'
class GroupOfferTest < ActiveSupport::TestCase
test 'terminated? method' do
terminated = create :group_offer, :terminated
unterminated = create :group_offer
assert terminated.terminated?
refute unterminated.terminated?
end
test 'terminatable? method' do
terminatable = create :group_offer
create :terminated_group_assignment, group_offer: terminatable
unterminatable = create :group_offer
create :group_assignment, group_offer: unterminatable, period_start: 2.months.ago,
period_end: nil
assert terminatable.terminatable?
refute unterminatable.terminatable?
end
test 'terminated_and_active_group_offer_is_not_valid' do
still_active = build :group_offer, period_end: 2.days.ago, period_end_set_by: create(:user)
refute still_active.valid?
assert still_active.errors.messages[:active].any?
still_active.active = false
assert still_active.valid?
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment