Commit 84737d91 authored by lauraMon's avatar lauraMon

Fixes bug with action_icon

* Adds more comprehensive spec
* Adds resolve_field helper
parent 3dcc22a2
......@@ -30,7 +30,7 @@ module Types
if obj.has_action?
{
button_title: obj.action_button_title,
icon: obj.icon,
icon: obj.action_icon,
method: obj.action_method,
path: obj.action_path,
title: obj.action_title
......
......@@ -3,11 +3,30 @@
require 'spec_helper'
RSpec.describe Types::Ci::DetailedStatusType do
include GraphqlHelpers
specify { expect(described_class.graphql_name).to eq('DetailedStatus') }
it "has all fields" do
it 'has all fields' do
expect(described_class).to have_graphql_fields(:group, :icon, :favicon,
:details_path, :has_details,
:label, :text, :tooltip, :action)
end
describe 'action field' do
it 'correctly renders the field' do
stage = create(:ci_stage_entity, status: :skipped)
status = stage.detailed_status(stage.pipeline.user)
expected_status = {
button_title: status.action_button_title,
icon: status.action_icon,
method: status.action_method,
path: status.action_path,
title: status.action_title
}
expect(resolve_field('action', status)).to eq(expected_status)
end
end
end
......@@ -112,6 +112,16 @@ module GraphqlHelpers
end
end
def resolve_field(name, object, args = {})
context = double("Context",
schema: GitlabSchema,
query: GraphQL::Query.new(GitlabSchema),
parent: nil)
field = described_class.fields[name]
instance = described_class.authorized_new(object, context)
field.resolve_field(instance, {}, context)
end
# Recursively convert a Hash with Ruby-style keys to GraphQL fieldname-style keys
#
# prepare_input_for_mutation({ 'my_key' => 1 })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment