Sha256: fe826839252a0b32fbb00c2b96d4f75aa70541436811eb9b567d41de70f6b7f0

Contents?: true

Size: 782 Bytes

Versions: 4

Compression:

Stored size: 782 Bytes

Contents

require 'rails_helper'

# this is a nested resource
describe HostedEvents::DiscountsController, type: :controller do

  before(:each) do
    @user = create(:user)
    @event = create(:event, user: @user)
  end

  describe '#index' do
    before(:each) do
      @discount = create(:discount, event: @event)
      @nope = create(:discount)
    end

    it 'sets the collection' do
      get :index, hosted_event_id: @event.id

      discounts = assigns(:discounts)
      expect(discounts).to be_present
      expect(discounts).to include(@discount)
      expect(discounts).to_not include(@nope)
    end

    it 'returns json' do
      get :index, hosted_event_id: @event.id, format: :json

      expect{
        JSON.parse(response.body)
      }.to_not raise_error
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazy_crud-0.9.8.4 spec/integration/hosted_events_discount_controller_spec.rb
lazy_crud-0.9.8.3 spec/integration/hosted_events_discount_controller_spec.rb
lazy_crud-0.9.8.2 spec/integration/hosted_events_discount_controller_spec.rb
lazy_crud-0.9.8.1 spec/integration/hosted_events_discount_controller_spec.rb