mirror of https://github.com/LemmyNet/lemmy.git
make it compile, move user languages to separate table
parent
fb8c05d6ba
commit
d3f3cbb8df
|
@ -178,12 +178,14 @@ pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> String {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use language_tags::LanguageTag;
|
|
||||||
use lemmy_api_common::check_validator_time;
|
use lemmy_api_common::check_validator_time;
|
||||||
use lemmy_db_queries::{establish_unpooled_connection, source::local_user::LocalUser_, Crud};
|
use lemmy_db_queries::{establish_unpooled_connection, source::local_user::LocalUser_, Crud};
|
||||||
use lemmy_db_schema::source::{
|
use lemmy_db_schema::{
|
||||||
local_user::{LocalUser, LocalUserForm},
|
source::{
|
||||||
person::{Person, PersonForm},
|
local_user::{LocalUser, LocalUserForm},
|
||||||
|
person::{Person, PersonForm},
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use lemmy_utils::claims::Claims;
|
use lemmy_utils::claims::Claims;
|
||||||
|
|
||||||
|
@ -201,7 +203,7 @@ mod tests {
|
||||||
let local_user_form = LocalUserForm {
|
let local_user_form = LocalUserForm {
|
||||||
person_id: inserted_person.id,
|
person_id: inserted_person.id,
|
||||||
password_encrypted: "123456".to_string(),
|
password_encrypted: "123456".to_string(),
|
||||||
discussion_languages: Some(vec![LanguageTag::parse("en").unwrap().into()]),
|
discussion_languages: Some(vec![PrimaryLanguageTag("en".to_string())]),
|
||||||
..LocalUserForm::default()
|
..LocalUserForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,14 @@ mod tests {
|
||||||
Crud,
|
Crud,
|
||||||
Likeable,
|
Likeable,
|
||||||
};
|
};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::{Person, PersonForm},
|
person::{Person, PersonForm},
|
||||||
post::{Post, PostForm},
|
post::{Post, PostForm},
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,7 +92,7 @@ mod tests {
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
parent_id: Some(inserted_comment.id),
|
parent_id: Some(inserted_comment.id),
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,14 @@ mod tests {
|
||||||
Crud,
|
Crud,
|
||||||
Followable,
|
Followable,
|
||||||
};
|
};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
|
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
|
||||||
person::{Person, PersonForm},
|
person::{Person, PersonForm},
|
||||||
post::{Post, PostForm},
|
post::{Post, PostForm},
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -105,7 +107,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,7 +117,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,7 +128,7 @@ mod tests {
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
parent_id: Some(inserted_comment.id),
|
parent_id: Some(inserted_comment.id),
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,14 @@ mod tests {
|
||||||
Crud,
|
Crud,
|
||||||
Likeable,
|
Likeable,
|
||||||
};
|
};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::{Person, PersonForm},
|
person::{Person, PersonForm},
|
||||||
post::{Post, PostForm, PostLike, PostLikeForm},
|
post::{Post, PostForm, PostLike, PostLikeForm},
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,7 +109,7 @@ mod tests {
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
parent_id: Some(inserted_comment.id),
|
parent_id: Some(inserted_comment.id),
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,14 @@ mod tests {
|
||||||
Crud,
|
Crud,
|
||||||
Likeable,
|
Likeable,
|
||||||
};
|
};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::{Person, PersonForm},
|
person::{Person, PersonForm},
|
||||||
post::{Post, PostForm, PostLike, PostLikeForm},
|
post::{Post, PostForm, PostLike, PostLikeForm},
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -73,7 +75,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,7 +96,7 @@ mod tests {
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
parent_id: Some(inserted_comment.id),
|
parent_id: Some(inserted_comment.id),
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,15 @@ impl SiteAggregates {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{aggregates::site_aggregates::SiteAggregates, establish_unpooled_connection, Crud};
|
use crate::{aggregates::site_aggregates::SiteAggregates, establish_unpooled_connection, Crud};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::{Person, PersonForm},
|
person::{Person, PersonForm},
|
||||||
post::{Post, PostForm},
|
post::{Post, PostForm},
|
||||||
site::{Site, SiteForm},
|
site::{Site, SiteForm},
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +101,7 @@ mod tests {
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
parent_id: Some(inserted_comment.id),
|
parent_id: Some(inserted_comment.id),
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -231,12 +231,14 @@ impl Saveable<CommentSavedForm> for CommentSaved {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, Crud, Likeable, Saveable};
|
use crate::{establish_unpooled_connection, Crud, Likeable, Saveable};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::*,
|
comment::*,
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::{Person, PersonForm},
|
person::{Person, PersonForm},
|
||||||
post::*,
|
post::*,
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -264,7 +266,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -274,7 +276,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -293,7 +295,7 @@ mod tests {
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: inserted_comment.ap_id.to_owned(),
|
ap_id: inserted_comment.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
language: LanguageTag::parse("en").unwrap().into(),
|
language: PrimaryLanguageTag("en".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let child_comment_form = CommentForm {
|
let child_comment_form = CommentForm {
|
||||||
|
@ -301,7 +303,7 @@ mod tests {
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
parent_id: Some(inserted_comment.id),
|
parent_id: Some(inserted_comment.id),
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -198,8 +198,10 @@ impl Crud<ModAddForm, i32> for ModAdd {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, Crud};
|
use crate::{establish_unpooled_connection, Crud};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{comment::*, community::*, moderator::*, person::*, post::*};
|
source::{comment::*, community::*, moderator::*, person::*, post::*},
|
||||||
|
PrimaryLanguageTag,
|
||||||
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
// use Crud;
|
// use Crud;
|
||||||
|
@ -234,7 +236,7 @@ mod tests {
|
||||||
name: "A test post thweep".into(),
|
name: "A test post thweep".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -244,7 +246,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,13 @@ mod tests {
|
||||||
source::password_reset_request::PasswordResetRequest_,
|
source::password_reset_request::PasswordResetRequest_,
|
||||||
Crud,
|
Crud,
|
||||||
};
|
};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
local_user::{LocalUser, LocalUserForm},
|
local_user::{LocalUser, LocalUserForm},
|
||||||
password_reset_request::PasswordResetRequest,
|
password_reset_request::PasswordResetRequest,
|
||||||
person::*,
|
person::*,
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ mod tests {
|
||||||
let new_local_user = LocalUserForm {
|
let new_local_user = LocalUserForm {
|
||||||
person_id: inserted_person.id,
|
person_id: inserted_person.id,
|
||||||
password_encrypted: "pass".to_string(),
|
password_encrypted: "pass".to_string(),
|
||||||
discussion_languages: Some(vec![LanguageTag::parse("en").unwrap().into()]),
|
discussion_languages: Some(vec![PrimaryLanguageTag("en".to_string())]),
|
||||||
..LocalUserForm::default()
|
..LocalUserForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -74,13 +74,15 @@ impl PersonMention_ for PersonMention {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, Crud};
|
use crate::{establish_unpooled_connection, Crud};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::*,
|
comment::*,
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::*,
|
person::*,
|
||||||
person_mention::*,
|
person_mention::*,
|
||||||
post::*,
|
post::*,
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -115,7 +117,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,7 +127,7 @@ mod tests {
|
||||||
content: "A test comment".into(),
|
content: "A test comment".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -260,10 +260,12 @@ impl Readable<PostReadForm> for PostRead {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, source::post::*};
|
use crate::{establish_unpooled_connection, source::post::*};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::*,
|
person::*,
|
||||||
|
},
|
||||||
|
PrimaryLanguageTag,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
|
@ -291,7 +293,7 @@ mod tests {
|
||||||
name: "A test post".into(),
|
name: "A test post".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -317,7 +319,7 @@ mod tests {
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: inserted_post.ap_id.to_owned(),
|
ap_id: inserted_post.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
language: LanguageTag::parse("en").unwrap().into(),
|
language: PrimaryLanguageTag("en".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Post Like
|
// Post Like
|
||||||
|
|
|
@ -140,8 +140,10 @@ impl PrivateMessage_ for PrivateMessage {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, source::private_message::PrivateMessage_, Crud};
|
use crate::{establish_unpooled_connection, source::private_message::PrivateMessage_, Crud};
|
||||||
use language_tags::LanguageTag;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{person::*, private_message::*};
|
source::{person::*, private_message::*},
|
||||||
|
PrimaryLanguageTag,
|
||||||
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -167,7 +169,7 @@ mod tests {
|
||||||
content: "A test private message".into(),
|
content: "A test private message".into(),
|
||||||
creator_id: inserted_creator.id,
|
creator_id: inserted_creator.id,
|
||||||
recipient_id: inserted_recipient.id,
|
recipient_id: inserted_recipient.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PrivateMessageForm::default()
|
..PrivateMessageForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,7 +186,7 @@ mod tests {
|
||||||
published: inserted_private_message.published,
|
published: inserted_private_message.published,
|
||||||
ap_id: inserted_private_message.ap_id.to_owned(),
|
ap_id: inserted_private_message.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
language: LanguageTag::parse("en").unwrap().into(),
|
language: PrimaryLanguageTag("en".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let read_private_message = PrivateMessage::read(&conn, inserted_private_message.id).unwrap();
|
let read_private_message = PrivateMessage::read(&conn, inserted_private_message.id).unwrap();
|
||||||
|
|
|
@ -124,7 +124,7 @@ pub fn naive_now() -> NaiveDateTime {
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
|
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
|
||||||
pub struct PrimaryLanguageTag(String);
|
pub struct PrimaryLanguageTag(pub String);
|
||||||
|
|
||||||
impl TryFrom<LanguageTag> for PrimaryLanguageTag {
|
impl TryFrom<LanguageTag> for PrimaryLanguageTag {
|
||||||
type Error = ValidationError;
|
type Error = ValidationError;
|
||||||
|
|
|
@ -438,14 +438,16 @@ impl ViewToVec for CommentView {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::comment_view::*;
|
use crate::comment_view::*;
|
||||||
use language_tags::LanguageTag;
|
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_queries::{
|
||||||
aggregates::comment_aggregates::CommentAggregates,
|
aggregates::comment_aggregates::CommentAggregates,
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
Crud,
|
Crud,
|
||||||
Likeable,
|
Likeable,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::{comment::*, community::*, person::*, post::*};
|
use lemmy_db_schema::{
|
||||||
|
source::{comment::*, community::*, person::*, post::*},
|
||||||
|
PrimaryLanguageTag,
|
||||||
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -472,7 +474,7 @@ mod tests {
|
||||||
name: "A test post 2".into(),
|
name: "A test post 2".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -482,7 +484,7 @@ mod tests {
|
||||||
content: "A test comment 32".into(),
|
content: "A test comment 32".into(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..CommentForm::default()
|
..CommentForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -517,7 +519,7 @@ mod tests {
|
||||||
ap_id: inserted_comment.ap_id,
|
ap_id: inserted_comment.ap_id,
|
||||||
updated: None,
|
updated: None,
|
||||||
local: true,
|
local: true,
|
||||||
language: LanguageTag::parse("en").unwrap().into(),
|
language: PrimaryLanguageTag("en".to_string()),
|
||||||
},
|
},
|
||||||
creator: PersonSafe {
|
creator: PersonSafe {
|
||||||
id: inserted_person.id,
|
id: inserted_person.id,
|
||||||
|
@ -558,7 +560,7 @@ mod tests {
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: inserted_post.ap_id.to_owned(),
|
ap_id: inserted_post.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
language: LanguageTag::parse("en").unwrap().into(),
|
language: PrimaryLanguageTag("en".to_string()),
|
||||||
},
|
},
|
||||||
community: CommunitySafe {
|
community: CommunitySafe {
|
||||||
id: inserted_community.id,
|
id: inserted_community.id,
|
||||||
|
|
|
@ -444,7 +444,6 @@ impl ViewToVec for PostView {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::post_view::{PostQueryBuilder, PostView};
|
use crate::post_view::{PostQueryBuilder, PostView};
|
||||||
use language_tags::LanguageTag;
|
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_queries::{
|
||||||
aggregates::post_aggregates::PostAggregates,
|
aggregates::post_aggregates::PostAggregates,
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
|
@ -453,7 +452,10 @@ mod tests {
|
||||||
ListingType,
|
ListingType,
|
||||||
SortType,
|
SortType,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::{community::*, person::*, post::*};
|
use lemmy_db_schema::{
|
||||||
|
source::{community::*, person::*, post::*},
|
||||||
|
PrimaryLanguageTag,
|
||||||
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -484,7 +486,7 @@ mod tests {
|
||||||
name: post_name.to_owned(),
|
name: post_name.to_owned(),
|
||||||
creator_id: inserted_person.id,
|
creator_id: inserted_person.id,
|
||||||
community_id: inserted_community.id,
|
community_id: inserted_community.id,
|
||||||
language: Some(LanguageTag::parse("en").unwrap().into()),
|
language: Some(PrimaryLanguageTag("en".to_string())),
|
||||||
..PostForm::default()
|
..PostForm::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -549,7 +551,7 @@ mod tests {
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: inserted_post.ap_id.to_owned(),
|
ap_id: inserted_post.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
language: LanguageTag::parse("en").unwrap().into(),
|
language: PrimaryLanguageTag("en".to_string()),
|
||||||
},
|
},
|
||||||
my_vote: None,
|
my_vote: None,
|
||||||
creator: PersonSafe {
|
creator: PersonSafe {
|
||||||
|
|
Loading…
Reference in New Issue