Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
getfitter-core / spec / models / core / promotion_spec.rb
Size: Mime:
require 'rails_helper'

RSpec.describe Core::Promotion, type: :model do
  it 'has a valid factory' do
    expect(create(:core_promotion)).to be_valid
  end

  it 'is invalid without a title' do
    expect(build(:core_promotion, title: nil)).to be_invalid
  end

  it 'can be associated with multiple organisation venues' do
    promotion = create(:core_promotion)
    organisation = create(:core_organisation)
    venue = create(:core_venue)
    org_venue = Core::OrganisationVenue.new(organisation: organisation,
                                            venue: venue)
    promotion.organisation_venues << org_venue

    expect(promotion.organisation_venues).to eq([org_venue])
  end

  it 'is sorted by sort_order' do
    one = create(:core_promotion, sort_order: 2)
    two = create(:core_promotion, sort_order: 1)

    promotions = Core::Promotion.all

    expect(promotions).to eq [two, one]
  end
end