Add tests for all models with includes searches
This commit is contained in:
@@ -3,18 +3,36 @@ require 'test_helper'
|
||||
class ArtistVersionsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "An artist versions controller" do
|
||||
setup do
|
||||
@user = create(:gold_user)
|
||||
@artist = as(@user) { create(:artist) }
|
||||
@user = create(:gold_user, id: 100)
|
||||
@builder = create(:builder_user, name: "danbo")
|
||||
as(@builder) { @artist = create(:artist, name: "masao") }
|
||||
as(@user) { @artist.update(name: "masao_(deleted)", is_deleted: true) }
|
||||
as(@builder) { @artist.update(name: "masao", is_deleted: false, group_name: "the_best") }
|
||||
end
|
||||
|
||||
should "get the index page" do
|
||||
get_auth artist_versions_path, @user
|
||||
assert_response :success
|
||||
end
|
||||
context "index action" do
|
||||
setup do
|
||||
@versions = @artist.versions
|
||||
end
|
||||
|
||||
should "get the index page when searching for something" do
|
||||
get_auth artist_versions_path(search: {name: @artist.name}), @user
|
||||
assert_response :success
|
||||
should "render" do
|
||||
get artist_versions_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should respond_to_search({}).with { @versions.reverse }
|
||||
should respond_to_search(name: "masao").with { [@versions[2], @versions[0]] }
|
||||
should respond_to_search(name_matches: "(deleted)").with { @versions[1] }
|
||||
should respond_to_search(group_name_matches: "the_best").with { @versions[2] }
|
||||
should respond_to_search(is_deleted: "true").with { @versions[1] }
|
||||
|
||||
context "using includes" do
|
||||
should respond_to_search(updater_id: 100).with { @versions[1] }
|
||||
should respond_to_search(updater_name: "danbo").with { [@versions[2], @versions[0]] }
|
||||
should respond_to_search(updater: {level: User::Levels::BUILDER}).with { [@versions[2], @versions[0]] }
|
||||
should respond_to_search(artist: {name: "masao"}).with { @versions.reverse }
|
||||
should respond_to_search(artist: {name: "doesntexist"}).with { [] }
|
||||
end
|
||||
end
|
||||
|
||||
context "show action" do
|
||||
|
||||
Reference in New Issue
Block a user