Sha256: 3b616549b2c96c26072cb5dbdd1895a52c964af3c54231f467e64596d543a03d

Contents?: true

Size: 1002 Bytes

Versions: 10

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true
require 'uri'
require 'test_helper'

module Shipit
  class CCMenuUrlControllerTest < ActionController::TestCase
    setup do
      @stack = shipit_stacks(:shipit)
      @user = shipit_users(:walrus)
      session[:user_id] = @user.id
    end

    test ":fetch returns ok with json" do
      get :fetch, params: { stack_id: @stack.to_param }
      assert_response :ok
      data = JSON.parse(response.body)
      assert_includes data, 'ccmenu_url'
    end

    test ":fetch creates a read only api client" do
      assert_difference 'ApiClient.count' do
        get :fetch, params: { stack_id: @stack.to_param }
      end
    end

    test ":fetch url includes api token on query string" do
      get :fetch, params: { stack_id: @stack.to_param }
      data = JSON.parse(response.body)
      client = ApiClient.last
      query = Rack::Utils.parse_nested_query(URI(data['ccmenu_url']).query)
      assert_equal client.authentication_token, query['token']
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.38.0 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.37.0 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.36.1 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.36.0 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.35.1 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.35.0 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.34.0 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.33.0 test/controllers/ccmenu_controller_test.rb
shipit-engine-0.32.0 test/controllers/ccmenu_controller_test.rb