Sha256: 32280ffc4da486c64aeac7d5b175778bcc1f9b709fad5f7353b535af5c0ea422

Contents?: true

Size: 761 Bytes

Versions: 4

Compression:

Stored size: 761 Bytes

Contents

require 'rails_helper'

# this is a nested resource
describe Event::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, 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, 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/event_discounts_controller_spec.rb
lazy_crud-0.9.8.3 spec/integration/event_discounts_controller_spec.rb
lazy_crud-0.9.8.2 spec/integration/event_discounts_controller_spec.rb
lazy_crud-0.9.8.1 spec/integration/event_discounts_controller_spec.rb