Module: VacancyFactoryMethods

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

Instance Method Summary collapse

Instance Method Details

#new_vacancy(name, state = nil) ⇒ Object



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

def new_vacancy(name, state = nil)
  attributes = { name: name }
  attributes[:state] = state if state
  
  set_vacancy_defaults(attributes)
  
  @vacancy = Factory(:vacancy, attributes)
  @vacancy.reload
end

#set_vacancy_defaults(attributes) ⇒ Object



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

def set_vacancy_defaults(attributes)
  attributes[:user_id] ||= @me.id unless attributes[:user_id] || !@me
  attributes[:project_id] ||= Project.last.id unless attributes[:project_id] || Project.all.none?
end