0
Railsでのテストは非常に新しいです。私はアルバムコントローラのインデックスアクションのための非常に基本的なテストを作成しようとしています。私はこのテストではなく、すべてのテストでエラーが発生しています。エラーは次のようになります。Railsテストエラー
bin/rails test test/controllers/albums_controller_test.rb:18
E
Error:
AlbumsControllerTest#test_should_get_edit:
ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: UNIQUE constraintfailed: users.email: INSERT INTO "users" ("created_at", "updated_at", "id") VALUES ('2017-01-11 21:54:05.906006', '2017-01-11 21:54:05.906006', 298486374)
私のテストでは、このエラーだけでなく、このエラーが発生します。
require 'test_helper'
class AlbumTest < ActiveSupport::TestCase
test "index action should work" do
get :index
assert_response :success
end
end
はここに私のアルバムコントローラ内のindexアクションである:これは、私は上記の例を実行しようとしたテストである
def index
@albums = Album.all.order(year: :desc).order(title: :asc)
end
何が起こっているのかわかりません。助けていただければ幸いです!
あなたは 'albums_controller_test.rb'コードで編集できますか –