Besides some other Failures I mainly get this one here:
FAIL["test_should_create_kiga", Minitest::Result, 1.6827512969975942]
test_should_create_kiga#Minitest::Result (1.68s)
"Kiga.count" didn't change by 1.
Expected: 4
Actual: 3
test/controllers/kigas_controller_test.rb:20:in `block in <class:KigasControllerTest>'
I am new to Ruby and I have no idea why it's expecting four kigas instead of three? In the yml file for kigas I only have three samples for kigas:
one:
name: MyString
city: MyString
postalcode: 1
streed: MyString
add_number: 1
capacity: 1
accessible: false
halalkit: false
koschakit: false
vegekit: false
vegankit: false
allday: false
user_id: 8
image_file_name: MyString
image_content_type: MyString
description: MyString
two:
name: MyString
city: MyString
postalcode: 1
streed: MyString
add_number: 1
capacity: 1
accessible: false
halalkit: false
koschakit: false
vegekit: false
vegankit: false
allday: false
user_id: 2
image_file_name: "kiga3.jpeg"
image_content_type: "image/jpeg"
description: MyString
three:
name: MyString
city: MyString
postalcode: 1
streed: MyString
add_number: 1
capacity: 1
accessible: false
halalkit: false
koschakit: false
vegekit: false
vegankit: false
allday: false
user_id: 2
image_file_name: "kiga3.jpeg"
image_content_type: "image/jpeg"
description: MyString
app/test/controllers/kigas_controller_test.rb
require 'test_helper'
class KigasControllerTest < ActionDispatch::IntegrationTest
setup do
@kiga = kigas(:one)
@other_kiga = kigas(:two)
end
[...]
test "should create kiga" do
assert_difference('Kiga.count') do
post kigas_url, params: { kiga: { accessible: @kiga.accessible, add_number: @kiga.add_number, allday: @kiga.allday, capacity: @kiga.capacity, city: @kiga.city, halalkit: @kiga.halalkit, koschakit: @kiga.koschakit, name: @kiga.name, postalcode: @kiga.postalcode, streed: @kiga.streed, vegankit: @kiga.vegankit, vegekit: @kiga.vegekit, user_id: @kiga.user_id } }
end
assert_redirected_to kiga_url(Kiga.last)
end
[...]
end
app/controllers/kigas_controller.rb
class KigasController < ApplicationController
before_action :set_kiga, only: [:show, :edit, :update, :destroy]
before_action :logged_in_user
def create
@kiga = Kiga.new kiga_params
@kiga.user = current_user
@kiga.save
respond_to do |format|
if @kiga.save
format.html { redirect_to @kiga, notice: 'Kiga was successfully created.' }
format.json { render :show, status: :created, location: @kiga }
else
format.html { render :new }
format.json { render json: @kiga.errors, status: :unprocessable_entity }
end
end
end
end
So my Problem is, that I have no clue why the test is expecting four kigas in the create test because I have three samples in the .yml file. I have the same issue for some other objects in my app so maybe it is a fundamental problem I am facing here? I am happy for any help!
Aucun commentaire:
Enregistrer un commentaire