Module: CandidatureFactoryMethods

Defined in:
lib/generators/voluntary/product_dummy/templates/features/step_definitions/candidature_steps.rb

Instance Method Summary collapse

Instance Method Details

#new_candidature(name, state = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/voluntary/product_dummy/templates/features/step_definitions/candidature_steps.rb', line 8

def new_candidature(name, state = nil)
  attributes = { name: name }
  attributes[:state] = state if state
  
  set_candidature_defaults(attributes)
  
  @candidature = Factory(:candidature, attributes)
  
  @candidature.reload
end

#set_candidature_defaults(attributes) ⇒ Object



2
3
4
5
6
# File 'lib/generators/voluntary/product_dummy/templates/features/step_definitions/candidature_steps.rb', line 2

def set_candidature_defaults(attributes)
  attributes[:user_id] ||= @me.id unless attributes[:user] || attributes[:user_id] || !@me
  attributes[:vacancy_id] ||= Vacancy.last.id unless attributes[:vacancy_id] || Vacancy.all.none?
  attributes[:offeror_id] ||= Vacancy.find(attributes[:vacancy_id]).project.user_id if attributes[:vacancy_id]
end