Fixing some specs

pull/5212/head
Wieland Lindenthal 8 years ago committed by Oliver Günther
parent 9152b60321
commit e7825c7755
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 2
      app/services/base_type_service.rb
  2. 10
      spec/controllers/types_controller_spec.rb
  3. 18
      spec/services/shared_type_service.rb

@ -36,7 +36,7 @@ class BaseTypeService
private
def update(permitted_params, unsafe_params)
def update(permitted_params = {}, unsafe_params = {})
success = Type.transaction do
permitted = permitted_params
permitted.delete(:attribute_groups)

@ -139,7 +139,10 @@ describe TypesController, type: :controller do
end
it { expect(response).to be_redirect }
it { expect(response).to redirect_to(types_path) }
it do
type = ::Type.find_by(name: 'New type')
expect(response).to redirect_to(action: 'edit', tab: 'settings', id: type.id)
end
end
describe 'WITH an empty name' do
@ -182,7 +185,10 @@ describe TypesController, type: :controller do
end
it { expect(response).to be_redirect }
it { expect(response).to redirect_to(types_path) }
it do
type = ::Type.find_by(name: 'New type')
expect(response).to redirect_to(action: 'edit', tab: 'settings', id: type.id)
end
it 'should have the copied workflows' do
expect(::Type.find_by(name: 'New type')
.workflows.count).to eq(existing_type.workflows.count)

@ -42,15 +42,15 @@ shared_examples_for 'type service' do
end
it 'set the values provided on the call' do
attributes = { name: 'blubs blubs' }
permitted_params = { name: 'blubs blubs' }
instance.call(attributes: attributes)
instance.call(permitted_params: permitted_params)
expect(type.name).to eql attributes[:name]
expect(type.name).to eql permitted_params[:name]
end
it 'enables the custom fields that are passed via attribute_visibility' do
attributes = { 'attribute_visibility' => { 'custom_field_3' => 'visible',
permitted_params = { 'attribute_visibility' => { 'custom_field_3' => 'visible',
'custom_field_54' => 'default',
'custom_field_86' => 'hidden' } }
@ -58,7 +58,7 @@ shared_examples_for 'type service' do
.to receive(:custom_field_ids=)
.with([3, 54])
instance.call(attributes: attributes)
instance.call(permitted_params: permitted_params)
end
context 'for a milestone' do
@ -67,10 +67,10 @@ shared_examples_for 'type service' do
end
it 'takes the values from the start and due_date if no value is set for date' do
attributes = { 'attribute_visibility' => { 'start_date' => 'visible',
permitted_params = { 'attribute_visibility' => { 'start_date' => 'visible',
'due_date' => 'visible' } }
instance.call(attributes: attributes)
instance.call(permitted_params: permitted_params)
expect(type.attribute_visibility).not_to include('start_date')
expect(type.attribute_visibility).not_to include('due_date')
@ -85,9 +85,9 @@ shared_examples_for 'type service' do
end
it 'takes the values from the date for start and due_date if no value is set' do
attributes = { 'attribute_visibility' => { 'date' => 'visible' } }
permitted_params = { 'attribute_visibility' => { 'date' => 'visible' } }
instance.call(attributes: attributes)
instance.call(permitted_params: permitted_params)
expect(type.attribute_visibility).not_to include('date')

Loading…
Cancel
Save