Skip to content

Instantly share code, notes, and snippets.

@noili
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save noili/07aedc468907a4f6f7a7 to your computer and use it in GitHub Desktop.

Select an option

Save noili/07aedc468907a4f6f7a7 to your computer and use it in GitHub Desktop.
steps_test.rb
class StepTest < ActiveSupport::TestCase
test "create step with unexistant office" do
step = Step.create name: 'Computo'
assert step.office.name == 'Computo'
end
test "create step with existant office" do
office = offices :computo
step = Step.create office: office
assert step.office.name == 'Computo'
end
end
no sería asi el test del controller?
require 'test_helper'
class StepsControllerTest < ActionController::TestCase
test "move file record through offices" do
file_record = file_records(:legal)
office = offices :computo
step = {office_id: office.id}
post :create, step: step, file_record_id: file_record.id
assert file_record.steps.last.office.name == 'Computo'
end
end
@olvap

olvap commented Sep 17, 2014

Copy link
Copy Markdown

si no te anda, probá con esta modificación

assert file_record.steps(true).last.office.name == 'Computos'

cuando a la relación le mandás true, vuelve a hacer la consulta. o sea, la actualiza.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment