-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
1,082 additions
and
944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
priv/repo/migrations/20240315115937_add_non_nullable_checks.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
defmodule Accent.Repo.Migrations.AddNonNullableChecks do | ||
@moduledoc false | ||
use Ecto.Migration | ||
|
||
def down do | ||
end | ||
|
||
# credo:disable-for-next-line | ||
def up do | ||
drop(constraint(:documents, :documents_project_id_fkey)) | ||
|
||
alter table(:documents) do | ||
modify(:path, :string, null: false) | ||
modify(:format, :string, null: false) | ||
modify(:project_id, references(:projects, type: :uuid), null: false) | ||
end | ||
|
||
alter table(:languages) do | ||
modify(:name, :string, null: false) | ||
modify(:slug, :string, null: false) | ||
modify(:iso_639_1, :string, null: false) | ||
modify(:iso_639_3, :string, null: false) | ||
modify(:locale, :string, null: false) | ||
modify(:android_code, :string, null: false) | ||
modify(:osx_code, :string, null: false) | ||
modify(:osx_locale, :string, null: false) | ||
end | ||
|
||
drop(constraint(:auth_access_tokens, :auth_access_tokens_user_id_fkey)) | ||
|
||
alter table(:auth_access_tokens) do | ||
modify(:token, :string, null: false) | ||
modify(:user_id, references(:users, type: :uuid), null: false) | ||
end | ||
|
||
drop(constraint(:auth_providers, :auth_providers_user_id_fkey)) | ||
|
||
alter table(:auth_providers) do | ||
modify(:name, :string, null: false) | ||
modify(:uid, :string, null: false) | ||
modify(:user_id, references(:users, type: :uuid), null: false) | ||
end | ||
|
||
drop(constraint(:collaborators, :collaborators_project_id_fkey)) | ||
|
||
alter table(:collaborators) do | ||
modify(:role, :string, null: false) | ||
modify(:project_id, references(:projects, type: :uuid), null: false) | ||
end | ||
|
||
drop(constraint(:comments, :comments_user_id_fkey)) | ||
|
||
alter table(:comments) do | ||
modify(:text, :text, null: false) | ||
modify(:user_id, references(:users, type: :uuid), null: false) | ||
end | ||
|
||
alter table(:projects) do | ||
modify(:name, :string, null: false) | ||
modify(:locked_file_operations, :boolean, null: false, default: false) | ||
modify(:sync_lock_version, :integer, null: false, default: 1) | ||
end | ||
|
||
drop(constraint(:revisions, :revisions_project_id_fkey)) | ||
drop(constraint(:revisions, :revisions_language_id_fkey)) | ||
|
||
alter table(:revisions) do | ||
modify(:project_id, references(:projects, type: :uuid), null: false) | ||
modify(:language_id, references(:languages, type: :uuid), null: false) | ||
modify(:master, :boolean, null: false, default: true) | ||
end | ||
|
||
alter table(:operations) do | ||
modify(:rollbacked, :boolean, null: false, default: false) | ||
modify(:batch, :boolean, null: false, default: false) | ||
modify(:action, :string, null: false) | ||
end | ||
|
||
alter table(:translations) do | ||
modify(:key, :string, null: false) | ||
modify(:removed, :boolean, null: false, default: false) | ||
modify(:conflicted, :boolean, null: false, default: false) | ||
modify(:comments_count, :integer, null: false, default: 0) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,9 @@ defmodule AccentTest.UserRemote.Authenticator do | |
end | ||
|
||
test "normalize collaborators with email" do | ||
assigner = Repo.insert!(%User{email: "[email protected]"}) | ||
language = Repo.insert!(%Language{name: "french"}) | ||
project = Repo.insert!(%Project{main_color: "#f00", name: "My project", language_id: language.id}) | ||
assigner = Factory.insert(User, email: "[email protected]") | ||
language = Factory.insert(Language) | ||
project = Factory.insert(Project, language_id: language.id) | ||
|
||
collaborator = | ||
Repo.insert!(%Collaborator{ | ||
|
@@ -45,9 +45,9 @@ defmodule AccentTest.UserRemote.Authenticator do | |
end | ||
|
||
test "normalize collaborators with uppercased email" do | ||
assigner = Repo.insert!(%User{email: "[email protected]"}) | ||
language = Repo.insert!(%Language{name: "french"}) | ||
project = Repo.insert!(%Project{main_color: "#f00", name: "My project", language_id: language.id}) | ||
assigner = Factory.insert(User, email: "[email protected]") | ||
language = Factory.insert(Language) | ||
project = Factory.insert(Project, language_id: language.id) | ||
|
||
collaborator = | ||
Repo.insert!(%Collaborator{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,14 @@ defmodule AccentTest.UserRemote.TokenGiver do | |
alias Accent.User | ||
alias Accent.UserRemote.TokenGiver | ||
|
||
@user %User{email: "[email protected]"} | ||
@token %AccessToken{revoked_at: nil, token: "1234"} | ||
|
||
test "revoke existing token" do | ||
user = Repo.insert!(@user) | ||
user = Factory.insert(User) | ||
token = Repo.insert!(Map.put(@token, :user_id, user.id)) | ||
|
||
existing_revoked_token = | ||
Repo.insert!(%AccessToken{token: "revoked", revoked_at: NaiveDateTime.utc_now(:second), user_id: user.id}) | ||
Factory.insert(AccessToken, token: "revoked", revoked_at: NaiveDateTime.utc_now(:second), user_id: user.id) | ||
|
||
TokenGiver.grant_token(user) | ||
|
||
|
@@ -27,7 +26,7 @@ defmodule AccentTest.UserRemote.TokenGiver do | |
end | ||
|
||
test "create token" do | ||
user = Repo.insert!(@user) | ||
user = Factory.insert(User) | ||
|
||
TokenGiver.grant_token(user) | ||
|
||
|
Oops, something went wrong.