Sha256: f326e3f4fafa21101577ce7a2c1382e159e2a321f53592a6d3e6ff62b7c41bb8
Contents?: true
Size: 1.99 KB
Versions: 19
Compression:
Stored size: 1.99 KB
Contents
require 'test_helper' module Shipit module Api class CCMenuControllerTest < ActionController::TestCase setup do authenticate! @stack = shipit_stacks(:shipit) end test "a request with insufficient permissions will render a 403" do @client.update!(permissions: []) get :show, params: {stack_id: @stack.to_param} assert_response :forbidden assert_json 'message', 'This operation requires the `read:stack` permission' end test "#show renders the xml" do get :show, params: {stack_id: @stack.to_param} assert_response :ok assert_payload 'name', @stack.to_param end test "can authenticate with query string token" do request.headers['Authorization'] = 'bleh' get :show, params: {stack_id: @stack.to_param, token: @client.authentication_token} assert_response :ok assert_payload 'name', @stack.to_param end test "xml contains required attributes" do get :show, params: {stack_id: @stack.to_param} project = get_project_from_xml(response.body) %w(name activity lastBuildStatus lastBuildLabel lastBuildTime webUrl).each do |attribute| assert_includes project, attribute, "Response missing required attribute: #{attribute}" end end test "locked stacks show as failed" do @stack.lock('test', @user) get :show, params: {stack_id: @stack.to_param} assert_payload 'lastBuildStatus', 'Failure' end test "stacks with no deploys render correctly" do stack = Stack.create!(repo_owner: 'foo', repo_name: 'bar') get :show, params: {stack_id: stack.to_param} assert_payload 'lastBuildStatus', 'Success' end private def get_project_from_xml(xml) Hash.from_xml(xml)['Projects']['Project'] end def assert_payload(k, v) @project ||= get_project_from_xml(response.body) assert_equal v, @project[k] end end end end
Version data entries
19 entries across 19 versions & 1 rubygems