code climate improvements

pull/4441/head
Jens Ulferts 9 years ago
parent 8063bc9d87
commit de8087e149
  1. 10
      app/models/work_package.rb
  2. 4
      spec/requests/api/v3/work_packages/create_form_resource_spec.rb

@ -763,13 +763,15 @@ class WorkPackage < ActiveRecord::Base
if new_record? # set default values for new records only
self.status ||= Status.default
self.priority ||= IssuePriority.active.default
if project
self.type ||= project.types.default.order(:position).first ||
project.types.order(:position).first
end
set_default_type if project
end
end
def set_default_type
self.type ||= project.types.default.order(:position).first ||
project.types.order(:position).first
end
def add_time_entry_for(user, attributes)
return if time_entry_blank?(attributes)

@ -105,7 +105,9 @@ describe ::API::V3::WorkPackages::CreateProjectFormAPI do
title: type.name
}
expect(subject.body).to be_json_eql(type_link.to_json).at_path('_embedded/payload/_links/type')
expect(subject.body)
.to be_json_eql(type_link.to_json)
.at_path('_embedded/payload/_links/type')
end
end
end

Loading…
Cancel
Save