diff --git a/bin/evening_detective_server b/bin/evening_detective_server index 2205cf5..13cf3d3 100755 Binary files a/bin/evening_detective_server and b/bin/evening_detective_server differ diff --git a/internal/repos/scenarios_repo/repo.go b/internal/repos/scenarios_repo/repo.go index 228b91e..833f796 100644 --- a/internal/repos/scenarios_repo/repo.go +++ b/internal/repos/scenarios_repo/repo.go @@ -277,7 +277,7 @@ func (r *ScenariosRepo) UpdateScenarioStatusByID( ELSE published_at END, updated_at = NOW() - WHERE id = $2 AND ($3 OR status <> 'public')`, + WHERE id = $2 AND ($3 OR status IS DISTINCT FROM 'public')`, status, id, allowPublished, diff --git a/internal/services/scenarios_service/service_test.go b/internal/services/scenarios_service/service_test.go index 42a88a8..ca19b4c 100644 --- a/internal/services/scenarios_service/service_test.go +++ b/internal/services/scenarios_service/service_test.go @@ -229,6 +229,21 @@ func newTestService(repo *fakeScenariosRepo, storage *fakeStorage) *ScenarioServ return NewScenarioService(repo, nil, testDomain, storage, scenario_archive.NewScenarioArchive()) } +func TestPublishDraftScenario(t *testing.T) { + repo := newFakeScenariosRepo() + id, err := repo.AddScenario(context.Background(), "Дело", 7) + if err != nil { + t.Fatal(err) + } + + if err := newTestService(repo, nil).UpdateScenarioStatusByID(context.Background(), id, "public", 7, false); err != nil { + t.Fatalf("publish: %v", err) + } + if repo.get(id).Status != "public" { + t.Fatalf("status = %q, want public", repo.get(id).Status) + } +} + // seedScenario кладёт в repo сценарий с историей и изображениями в storage. func seedScenario(t *testing.T, repo *fakeScenariosRepo, storage *fakeStorage) *repos.Scenario { t.Helper()