Sha256: fd191b08ab3a3c1932341e5136d8a0ec07c7dd8248ac9cbe678da52368cb2ee1

Contents?: true

Size: 1.49 KB

Versions: 11

Compression:

Stored size: 1.49 KB

Contents

require "rails_helper"

RSpec.describe ::Dorsale::ExpenseGun::ExpensesController, type: :controller do
  routes { Dorsale::Engine.routes }
  let(:user) { create(:user) }
  before(:each) { sign_in(user) }

  describe "#index" do
    describe "filters" do
      render_views

      it "should filter by state" do
        expense1 = create(:expense_gun_expense, state: "accepted")
        expense2 = create(:expense_gun_expense, state: "refused")

        cookies[:filters] = {expense_state: "accepted"}.to_json
        get :index

        expect(assigns :expenses).to eq [expense1]
      end

      it "should filter by user" do
        user1    = create(:user)
        user2    = create(:user)
        expense1 = create(:expense_gun_expense, user: user1)
        expense2 = create(:expense_gun_expense, user: user2)

        cookies[:filters] = {expense_user_id: user1.id}.to_json
        get :index

        expect(assigns :expenses).to eq [expense1]
      end

      it "should assigns only users having expenses" do
        user1    = create(:user)
        user2    = create(:user)
        expense2 = create(:expense_gun_expense, user: user2)

        get :index

        expect(assigns :users).to eq [user2]
      end
    end # describe "filters"
  end # describe "#index"

  describe "#show" do
    render_views

    it "should be ok as PDF" do
      expense = create(:expense_gun_expense, user: user)
      get :show, params: {id: expense, format: :pdf}
      expect(response).to be_ok
    end
  end # describe "#show"
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dorsale-3.18.0 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.17.0 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.16.0 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.15.0 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.14.11 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.14.10 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.14.9 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.14.8 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.14.7 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.14.6 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb
dorsale-3.14.5 spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb