lib/scaffolding/transformer.rb in bullet_train-super_scaffolding-1.7.13 vs lib/scaffolding/transformer.rb in bullet_train-super_scaffolding-1.7.14
- old
+ new
@@ -1394,19 +1394,14 @@
# Add factory setup in API controller test.
unless cli_options["skip-api"]
test_name = transform_string("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb")
test_lines = File.open(test_name).readlines
- # Shift contents of controller test after skipping `unless scaffolding_things_disabled?` block.
- class_block_index = Scaffolding::FileManipulator.find(test_lines, "class #{transform_string("Api::V1::Scaffolding::CompletelyConcrete::TangibleThingsControllerTest")}")
- new_lines = Scaffolding::BlockManipulator.shift_block(lines: test_lines, block_start: test_lines[class_block_index], shift_contents_only: true)
- Scaffolding::FileManipulator.write(test_name, new_lines)
-
# Ensure variables built with factories are indented properly.
- factory_hook_index = Scaffolding::FileManipulator.find(new_lines, RUBY_FACTORY_SETUP_HOOK)
- factory_hook_indentation = Scaffolding::BlockManipulator.indentation_of(factory_hook_index, new_lines)
+ factory_hook_index = Scaffolding::FileManipulator.find(test_lines, RUBY_FACTORY_SETUP_HOOK)
+ factory_hook_indentation = Scaffolding::BlockManipulator.indentation_of(factory_hook_index, test_lines)
indented_factory_lines = build_factory_setup.map { |line| "#{factory_hook_indentation}#{line}\n" }
- scaffold_replace_line_in_file(test_name, indented_factory_lines.join, new_lines[factory_hook_index])
+ scaffold_replace_line_in_file(test_name, indented_factory_lines.join, test_lines[factory_hook_index])
end
# add children to the show page of their parent.
unless cli_options["skip-parent"] || parent == "None"
scaffold_add_line_to_file(