add tests
This commit is contained in:
Vendored
+2
-2
@@ -3,11 +3,11 @@
|
|||||||
one:
|
one:
|
||||||
entry: one
|
entry: one
|
||||||
user: one
|
user: one
|
||||||
changes_made:
|
changes_made: "{}"
|
||||||
change_type: MyString
|
change_type: MyString
|
||||||
|
|
||||||
two:
|
two:
|
||||||
entry: two
|
entry: two
|
||||||
user: two
|
user: two
|
||||||
changes_made:
|
changes_made: "{}"
|
||||||
change_type: MyString
|
change_type: MyString
|
||||||
|
|||||||
Vendored
+4
-8
@@ -2,26 +2,22 @@
|
|||||||
|
|
||||||
one:
|
one:
|
||||||
entry: one
|
entry: one
|
||||||
language_code: MyString
|
language_code: "en"
|
||||||
alternative_translation: MyString
|
alternative_translation: MyString
|
||||||
context: MyText
|
context: MyText
|
||||||
reasoning: MyText
|
reasoning: MyText
|
||||||
source: MyString
|
source: MyString
|
||||||
region: MyString
|
region: MyString
|
||||||
status: 1
|
status: :pending
|
||||||
submitted_by: one
|
submitted_by: one
|
||||||
reviewed_by: one
|
|
||||||
reviewed_at: 2026-01-22 13:38:22
|
|
||||||
|
|
||||||
two:
|
two:
|
||||||
entry: two
|
entry: two
|
||||||
language_code: MyString
|
language_code: "fi"
|
||||||
alternative_translation: MyString
|
alternative_translation: MyString
|
||||||
context: MyText
|
context: MyText
|
||||||
reasoning: MyText
|
reasoning: MyText
|
||||||
source: MyString
|
source: MyString
|
||||||
region: MyString
|
region: MyString
|
||||||
status: 1
|
status: :pending
|
||||||
submitted_by: two
|
submitted_by: two
|
||||||
reviewed_by: two
|
|
||||||
reviewed_at: 2026-01-22 13:38:22
|
|
||||||
|
|||||||
+9
-9
@@ -1,15 +1,15 @@
|
|||||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
one:
|
one:
|
||||||
code: MyString
|
code: "en"
|
||||||
name: MyString
|
name: "English"
|
||||||
native_name: MyString
|
native_name: "English"
|
||||||
sort_order: 1
|
sort_order: 1
|
||||||
active: false
|
active: true
|
||||||
|
|
||||||
two:
|
two:
|
||||||
code: MyString
|
code: "fi"
|
||||||
name: MyString
|
name: "Finnish"
|
||||||
native_name: MyString
|
native_name: "Suomi"
|
||||||
sort_order: 1
|
sort_order: 2
|
||||||
active: false
|
active: true
|
||||||
|
|||||||
Vendored
+10
-10
@@ -1,23 +1,23 @@
|
|||||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
one:
|
one:
|
||||||
email: MyString
|
email: "one@example.com"
|
||||||
password_digest: MyString
|
password_digest: <%= BCrypt::Password.create('password') %>
|
||||||
name: MyString
|
name: "User One"
|
||||||
role: 1
|
role: 1
|
||||||
primary_language: MyString
|
primary_language: "en"
|
||||||
invitation_token: MyString
|
invitation_token: "one"
|
||||||
invitation_sent_at: 2026-01-22 13:38:37
|
invitation_sent_at: 2026-01-22 13:38:37
|
||||||
invitation_accepted_at: 2026-01-22 13:38:37
|
invitation_accepted_at: 2026-01-22 13:38:37
|
||||||
invited_by: one
|
invited_by: one
|
||||||
|
|
||||||
two:
|
two:
|
||||||
email: MyString
|
email: "two@example.com"
|
||||||
password_digest: MyString
|
password_digest: <%= BCrypt::Password.create('password') %>
|
||||||
name: MyString
|
name: "User Two"
|
||||||
role: 1
|
role: 1
|
||||||
primary_language: MyString
|
primary_language: "fi"
|
||||||
invitation_token: MyString
|
invitation_token: "two"
|
||||||
invitation_sent_at: 2026-01-22 13:38:37
|
invitation_sent_at: 2026-01-22 13:38:37
|
||||||
invitation_accepted_at: 2026-01-22 13:38:37
|
invitation_accepted_at: 2026-01-22 13:38:37
|
||||||
invited_by: two
|
invited_by: two
|
||||||
|
|||||||
@@ -1,7 +1,29 @@
|
|||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class CommentTest < ActiveSupport::TestCase
|
class CommentTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test "should be valid with a user, body, and commentable" do
|
||||||
# assert true
|
user = users(:one)
|
||||||
# end
|
entry = entries(:one)
|
||||||
|
comment = Comment.new(user: user, body: "This is a comment.", commentable: entry)
|
||||||
|
assert comment.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without a body" do
|
||||||
|
user = users(:one)
|
||||||
|
entry = entries(:one)
|
||||||
|
comment = Comment.new(user: user, commentable: entry)
|
||||||
|
assert_not comment.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without a user" do
|
||||||
|
entry = entries(:one)
|
||||||
|
comment = Comment.new(body: "This is a comment.", commentable: entry)
|
||||||
|
assert_not comment.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without a commentable" do
|
||||||
|
user = users(:one)
|
||||||
|
comment = Comment.new(user: user, body: "This is a comment.")
|
||||||
|
assert_not comment.valid?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,43 @@
|
|||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class EntryTest < ActiveSupport::TestCase
|
class EntryTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test "should be valid with a category" do
|
||||||
# assert true
|
entry = Entry.new(category: :word)
|
||||||
# end
|
assert entry.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without a category" do
|
||||||
|
entry = Entry.new(category: nil)
|
||||||
|
assert_not entry.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be a word" do
|
||||||
|
entry = Entry.new(category: :word)
|
||||||
|
assert entry.word?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be a phrase" do
|
||||||
|
entry = Entry.new(category: :phrase)
|
||||||
|
assert entry.phrase?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be a proper_name" do
|
||||||
|
entry = Entry.new(category: :proper_name)
|
||||||
|
assert entry.proper_name?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be a title" do
|
||||||
|
entry = Entry.new(category: :title)
|
||||||
|
assert entry.title?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be a reference" do
|
||||||
|
entry = Entry.new(category: :reference)
|
||||||
|
assert entry.reference?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be other" do
|
||||||
|
entry = Entry.new(category: :other)
|
||||||
|
assert entry.other?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,36 @@
|
|||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class EntryVersionTest < ActiveSupport::TestCase
|
class EntryVersionTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test "should be valid with all attributes" do
|
||||||
# assert true
|
version = EntryVersion.new(
|
||||||
# end
|
entry: entries(:one),
|
||||||
|
user: users(:one),
|
||||||
|
changes_made: { "fi" => "uusi sana" }
|
||||||
|
)
|
||||||
|
assert version.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without changes_made" do
|
||||||
|
version = EntryVersion.new(
|
||||||
|
entry: entries(:one),
|
||||||
|
user: users(:one)
|
||||||
|
)
|
||||||
|
assert_not version.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without an entry" do
|
||||||
|
version = EntryVersion.new(
|
||||||
|
user: users(:one),
|
||||||
|
changes_made: { "fi" => "uusi sana" }
|
||||||
|
)
|
||||||
|
assert_not version.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without a user" do
|
||||||
|
version = EntryVersion.new(
|
||||||
|
entry: entries(:one),
|
||||||
|
changes_made: { "fi" => "uusi sana" }
|
||||||
|
)
|
||||||
|
assert_not version.valid?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,63 @@
|
|||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class SuggestedMeaningTest < ActiveSupport::TestCase
|
class SuggestedMeaningTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test "should be valid with all attributes" do
|
||||||
# assert true
|
meaning = SuggestedMeaning.new(
|
||||||
# end
|
entry: entries(:one),
|
||||||
|
language_code: supported_languages(:one).code,
|
||||||
|
alternative_translation: "New Translation",
|
||||||
|
submitted_by: users(:one)
|
||||||
|
)
|
||||||
|
assert meaning.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without a language_code" do
|
||||||
|
meaning = SuggestedMeaning.new(
|
||||||
|
entry: entries(:one),
|
||||||
|
alternative_translation: "New Translation",
|
||||||
|
submitted_by: users(:one)
|
||||||
|
)
|
||||||
|
assert_not meaning.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without an alternative_translation" do
|
||||||
|
meaning = SuggestedMeaning.new(
|
||||||
|
entry: entries(:one),
|
||||||
|
language_code: supported_languages(:one).code,
|
||||||
|
submitted_by: users(:one)
|
||||||
|
)
|
||||||
|
assert_not meaning.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should have a default status of pending" do
|
||||||
|
meaning = SuggestedMeaning.new(
|
||||||
|
entry: entries(:one),
|
||||||
|
language_code: supported_languages(:one).code,
|
||||||
|
alternative_translation: "New Translation",
|
||||||
|
submitted_by: users(:one)
|
||||||
|
)
|
||||||
|
assert meaning.pending?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be accepted" do
|
||||||
|
meaning = SuggestedMeaning.new(
|
||||||
|
entry: entries(:one),
|
||||||
|
language_code: supported_languages(:one).code,
|
||||||
|
alternative_translation: "New Translation",
|
||||||
|
submitted_by: users(:one),
|
||||||
|
status: :accepted
|
||||||
|
)
|
||||||
|
assert meaning.accepted?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be rejected" do
|
||||||
|
meaning = SuggestedMeaning.new(
|
||||||
|
entry: entries(:one),
|
||||||
|
language_code: supported_languages(:one).code,
|
||||||
|
alternative_translation: "New Translation",
|
||||||
|
submitted_by: users(:one),
|
||||||
|
status: :rejected
|
||||||
|
)
|
||||||
|
assert meaning.rejected?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class SupportedLanguageTest < ActiveSupport::TestCase
|
class SupportedLanguageTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test "should be valid with all attributes" do
|
||||||
# assert true
|
language = SupportedLanguage.new(code: "es", name: "Spanish", native_name: "Español")
|
||||||
# end
|
assert language.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid with a duplicate code" do
|
||||||
|
SupportedLanguage.create(code: "de", name: "German", native_name: "Deutsch")
|
||||||
|
language = SupportedLanguage.new(code: "de", name: "German", native_name: "Deutsch")
|
||||||
|
assert_not language.valid?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,34 @@
|
|||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class UserTest < ActiveSupport::TestCase
|
class UserTest < ActiveSupport::TestCase
|
||||||
# test "the truth" do
|
test "should be valid with an email and password" do
|
||||||
# assert true
|
user = User.new(email: "test@example.com", password: "password")
|
||||||
# end
|
assert user.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid without an email" do
|
||||||
|
user = User.new(password: "password")
|
||||||
|
assert_not user.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should be invalid with a duplicate email" do
|
||||||
|
User.create(email: "test@example.com", password: "password")
|
||||||
|
user = User.new(email: "test@example.com", password: "password")
|
||||||
|
assert_not user.valid?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should have a default role of contributor" do
|
||||||
|
user = User.new(email: "test@example.com", password: "password")
|
||||||
|
assert user.contributor?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be a reviewer" do
|
||||||
|
user = User.new(email: "test@example.com", password: "password", role: :reviewer)
|
||||||
|
assert user.reviewer?
|
||||||
|
end
|
||||||
|
|
||||||
|
test "can be an admin" do
|
||||||
|
user = User.new(email: "test@example.com", password: "password", role: :admin)
|
||||||
|
assert user.admin?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user