Sha256: dcf125ed2e9450032e0189945bbd867e5a45c071b22d860878cf60345c21a13c

Contents?: true

Size: 1.16 KB

Versions: 30

Compression:

Stored size: 1.16 KB

Contents

require 'rails_helper'

module MnoEnterprise
  describe InvoicesController, type: :controller do
    render_views
    routes { MnoEnterprise::Engine.routes }

    # Stub controller ability
    let!(:ability) { stub_ability }
    before { allow(ability).to receive(:can?).with(any_args).and_return(true) }

    # Stub model calls
    let(:user) { build(:user) }
    let(:organization) { build(:organization) }
    let(:invoice) { build(:invoice, organization_id: organization.id) }
    before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
    before { api_stub_for(get: "/organizations/#{organization.id}", response: from_api(organization)) }
    before { api_stub_for(get: "/users/#{user.id}/organizations/#{organization.id}", response: from_api(organization)) }
    before { api_stub_for(get: "/invoices", params: { filter: { slug: '**' } }, response: from_api([invoice])) }


    describe "GET #show" do
      before { sign_in user }
      subject { get :show, id: invoice.slug }

      it_behaves_like "a navigatable protected user action"
      it_behaves_like "a user protected resource"

      it { subject; expect(response).to be_success }
    end

  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
mno-enterprise-frontend-2.0.4 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-3.1.0 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-3.0.3 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-2.0.3 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-3.0.2 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-2.0.2 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-3.0.1 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-2.0.1 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-3.0.0 spec/controllers/mno_enterprise/invoices_controller_spec.rb
mno-enterprise-frontend-2.0.0 spec/controllers/mno_enterprise/invoices_controller_spec.rb