Sha256: 280c389aafdea9c49048e4dceb4dfbe0df9e19311362741da2a0583a81c1b10e
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require 'capybara/dsl' module Balboa module Interactor module Command class FillPunchCommand include Capybara::DSL TIME_TEMPLATE = '%02d:00'.freeze SUCCESS_MESSAGE = 'Punch foi criado com sucesso.'.freeze PunchCreationError = Class.new(RuntimeError) def initialize(schedule, project) @schedule = schedule @project = project end def execute(date) visit_new_punch_path fill_first_shift(date) visit_new_punch_path fill_second_shift(date) end private def visit_new_punch_path visit('/punches/new') end def fill_first_shift(date) fill_form(date, @schedule.start_at, @schedule.lunch_at) end def fill_second_shift(date) fill_form(date, @schedule.restart_at, @schedule.leave_at) end def fill_form(date, start_time, finish_time) fill_in 'punch[from_time]', with: TIME_TEMPLATE % start_time fill_in 'punch[to_time]', with: TIME_TEMPLATE % finish_time fill_in 'punch[when_day]', with: date.to_s select @project, from: 'punch[project_id]' confirm end def confirm click_button 'Criar Punch' raise PunchCreationError unless body[SUCCESS_MESSAGE] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
balboa-0.1.7 | lib/balboa/interactor/command/fill_punch_command.rb |