Sha256: 4891c0acb5b949bc04fbdfe560e8fecf6c73669827569ac8d17b76045c45fb8f

Contents?: true

Size: 847 Bytes

Versions: 42

Compression:

Stored size: 847 Bytes

Contents

require 'rails_helper'

module PandaPal
  RSpec.describe ApiCallController, type: :controller do
    let!(:api_call) { ApiCall.create!(logic: '"#{p[:foo]}_bar"') }

    def json_body
      JSON.parse(response.body)
    end

    describe "#call" do
      it "calls the function with parameters" do
        get :call, params: { token: api_call.jwt_token, foo: 'bar', use_route: 'panda_pal' }
        expect(response).to be_successful
        expect(json_body["status"]).to eq 'ok'
        expect(json_body["result"]).to eq 'bar_bar'
      end

      it "fails given a bad JWT" do
        get :call, params: { token: "bad.jwt.token", foo: 'bar', use_route: 'panda_pal' }
        expect(response).not_to be_successful
        expect(json_body["status"]).to eq 'error'
        expect(json_body["error"]).to eq 'Invalid JWT'
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
panda_pal-5.12.7 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.12.6 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.12.5 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.12.4 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.12.3 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.12.2 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.12.1 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.12.0 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.11.0 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.10.1 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.10.0 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.8.beta1 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.7 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.6 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.5 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.4 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.3 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.1 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.9.0 spec/controllers/panda_pal/api_call_controller_spec.rb
panda_pal-5.8.5 spec/controllers/panda_pal/api_call_controller_spec.rb