mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add model test for sponsership_level
This commit is contained in:
parent
6a6824cef1
commit
53f732ce9c
1 changed files with 28 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SponsorshipLevel do
|
||||
describe 'validations' do
|
||||
describe 'validation' do
|
||||
|
||||
it 'has a valid factory' do
|
||||
expect(build(:sponsorship_level)).to be_valid
|
||||
|
|
@ -11,4 +11,31 @@ describe SponsorshipLevel do
|
|||
should validate_presence_of(:title)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'association' do
|
||||
it { is_expected.to belong_to(:conference) }
|
||||
it { is_expected.to have_many(:sponsors) }
|
||||
end
|
||||
|
||||
describe 'acts_as_list' do
|
||||
let(:conference) { create(:conference) }
|
||||
|
||||
before do
|
||||
@first_sponsorship_level = create(:sponsorship_level, conference: conference)
|
||||
@second_sponsorship_level = create(:sponsorship_level, conference: conference)
|
||||
@second_sponsorship_level.move_higher
|
||||
@third_sponsorship_level = create(:sponsorship_level, conference: conference)
|
||||
end
|
||||
|
||||
it 'is positions sponsorship_levels in order' do
|
||||
expect(SponsorshipLevel.where(conference_id: conference.id).order(:position).map(&:id))
|
||||
.to eq [2, 1, 3]
|
||||
end
|
||||
|
||||
it 'maintains order after deleting one element' do
|
||||
@first_sponsorship_level.destroy
|
||||
expect(SponsorshipLevel.where(conference_id: conference.id).order(:position).map(&:id))
|
||||
.to eq [2, 3]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue