Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Controller
module JsonApi
# Configuration for OpenAPI controller action
class ActionConfiguration < GraphqlToRest::Controller::Basic::ActionConfiguration
def model
controller_config.model
def model(name = nil)
@model ||= name.present? ? ModelConfiguration.new(name: name) : controller_config.model
end

def fieldset_parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,26 @@
end
end
end

describe '#model' do
subject(:model) { action_configuration.model }

before { controller_config.model('User') }

it 'returns the model configuration' do
expect(model).to be_a(GraphqlToRest::Controller::JsonApi::ModelConfiguration)
end

it 'inherits the model name from a controller configuration' do
expect(model.name).to eq('User')
end

context 'when the model name is provided' do
subject(:model) { action_configuration.model('AnotherResponse') }

it 'overrides the model name' do
expect(model.name).to eq('AnotherResponse')
end
end
end
end
Loading