Sha256: 149ef6c1244bd63ce272d53d983d652d9708ae81a219b86a508605ecbe776af9

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 Bytes

Contents

require 'rails_helper'

module Mks
  module Rate
    RSpec.describe ServiceRatesController, type: :controller do
      routes { Mks::Rate::Engine.routes }

      before(:each) do
        u = create(:user)
        token = Mks::Auth::TokenAuth.issue(name: u.full_name, email: u.email, id: u.id)
        request.headers['Authorization'] = "Bearer #{token}"
      end

      describe 'GET #index' do
        it 'Returns all equipment rates' do
          3.times { create(:service_rate) }
          get :index
          result = JSON.parse(response.body)
          expect(result['data'].count).to eq(3)
        end
      end

      describe 'GET #working_rates' do
        it 'Returns all working rates' do
          3.times { create(:service_rate) }
          get :working_rates
          result = JSON(response.body)
          expect(result.count).to eq 3
          expect(result[0].count).to eq 9
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mks_rate-1.0.5 spec/controllers/mks/rate/service_rates_controller_spec.rb
mks_rate-1.0.4 spec/controllers/mks/rate/service_rates_controller_spec.rb
mks_rate-1.0.3 spec/controllers/mks/rate/service_rates_controller_spec.rb
mks_rate-1.0.2 spec/controllers/mks/rate/service_rates_controller_spec.rb
mks_rate-1.0.1 spec/controllers/mks/rate/service_rates_controller_spec.rb