mirror of https://github.com/LemmyNet/lemmy.git
clippy
parent
990b2dc106
commit
ae94f53900
|
@ -778,19 +778,19 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Data {
|
impl Data {
|
||||||
fn default_post_query<'a>(
|
#[allow(clippy::type_complexity)]
|
||||||
&'a self,
|
fn default_post_query(
|
||||||
local_user: Option<&'a LocalUserView>,
|
local_user: Option<&LocalUserView>,
|
||||||
) -> PostQueryBuilder<
|
) -> PostQueryBuilder<
|
||||||
'_,
|
'_,
|
||||||
(
|
(
|
||||||
(LocalSite,),
|
(LocalSite,),
|
||||||
(),
|
(),
|
||||||
(std::option::Option<SortType>,),
|
(Option<SortType>,),
|
||||||
(),
|
(),
|
||||||
(),
|
(),
|
||||||
(),
|
(),
|
||||||
(std::option::Option<&LocalUserView>,),
|
(Option<&LocalUserView>,),
|
||||||
(),
|
(),
|
||||||
(),
|
(),
|
||||||
(),
|
(),
|
||||||
|
@ -932,8 +932,7 @@ mod tests {
|
||||||
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form).await?;
|
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form).await?;
|
||||||
data.local_user_view.local_user = inserted_local_user;
|
data.local_user_view.local_user = inserted_local_user;
|
||||||
|
|
||||||
let read_post_listing = data
|
let read_post_listing = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
|
@ -967,8 +966,7 @@ mod tests {
|
||||||
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form).await?;
|
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form).await?;
|
||||||
data.local_user_view.local_user = inserted_local_user;
|
data.local_user_view.local_user = inserted_local_user;
|
||||||
|
|
||||||
let post_listings_with_bots = data
|
let post_listings_with_bots = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
|
@ -986,8 +984,7 @@ mod tests {
|
||||||
let pool = &mut pool.into();
|
let pool = &mut pool.into();
|
||||||
let data = init_data(pool).await?;
|
let data = init_data(pool).await?;
|
||||||
|
|
||||||
let read_post_listing_multiple_no_person = data
|
let read_post_listing_multiple_no_person = Data::default_post_query(None)
|
||||||
.default_post_query(None)
|
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
|
@ -1029,8 +1026,8 @@ mod tests {
|
||||||
};
|
};
|
||||||
CommunityBlock::block(pool, &community_block).await?;
|
CommunityBlock::block(pool, &community_block).await?;
|
||||||
|
|
||||||
let read_post_listings_with_person_after_block = data
|
let read_post_listings_with_person_after_block =
|
||||||
.default_post_query(Some(&data.local_user_view))
|
Data::default_post_query(Some(&data.local_user_view))
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
|
@ -1087,16 +1084,14 @@ mod tests {
|
||||||
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form).await?;
|
LocalUser::update(pool, data.local_user_view.local_user.id, &local_user_form).await?;
|
||||||
data.local_user_view.local_user = inserted_local_user;
|
data.local_user_view.local_user = inserted_local_user;
|
||||||
|
|
||||||
let read_post_listing = data
|
let read_post_listing = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
assert_eq!(vec![expected_post_with_upvote], read_post_listing);
|
assert_eq!(vec![expected_post_with_upvote], read_post_listing);
|
||||||
|
|
||||||
let read_liked_post_listing = data
|
let read_liked_post_listing = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.liked_only(true)
|
.liked_only(true)
|
||||||
.build()
|
.build()
|
||||||
|
@ -1104,8 +1099,7 @@ mod tests {
|
||||||
.await?;
|
.await?;
|
||||||
assert_eq!(read_post_listing, read_liked_post_listing);
|
assert_eq!(read_post_listing, read_liked_post_listing);
|
||||||
|
|
||||||
let read_disliked_post_listing = data
|
let read_disliked_post_listing = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.disliked_only(true)
|
.disliked_only(true)
|
||||||
.build()
|
.build()
|
||||||
|
@ -1135,8 +1129,7 @@ mod tests {
|
||||||
};
|
};
|
||||||
CommunityModerator::join(pool, &form).await?;
|
CommunityModerator::join(pool, &form).await?;
|
||||||
|
|
||||||
let post_listing = data
|
let post_listing = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.community_id(Some(data.inserted_community.id))
|
.community_id(Some(data.inserted_community.id))
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
|
@ -1181,8 +1174,7 @@ mod tests {
|
||||||
|
|
||||||
Post::create(pool, &post_spanish).await?;
|
Post::create(pool, &post_spanish).await?;
|
||||||
|
|
||||||
let post_listings_all = data
|
let post_listings_all = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -1192,8 +1184,7 @@ mod tests {
|
||||||
|
|
||||||
LocalUserLanguage::update(pool, vec![french_id], data.local_user_view.local_user.id).await?;
|
LocalUserLanguage::update(pool, vec![french_id], data.local_user_view.local_user.id).await?;
|
||||||
|
|
||||||
let post_listing_french = data
|
let post_listing_french = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -1211,8 +1202,7 @@ mod tests {
|
||||||
data.local_user_view.local_user.id,
|
data.local_user_view.local_user.id,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let post_listings_french_und = data
|
let post_listings_french_und = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?
|
.await?
|
||||||
|
@ -1249,8 +1239,7 @@ mod tests {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Make sure you don't see the removed post in the results
|
// Make sure you don't see the removed post in the results
|
||||||
let post_listings_no_admin = data
|
let post_listings_no_admin = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -1258,8 +1247,7 @@ mod tests {
|
||||||
|
|
||||||
// Removed bot post is shown to admins on its profile page
|
// Removed bot post is shown to admins on its profile page
|
||||||
data.local_user_view.local_user.admin = true;
|
data.local_user_view.local_user.admin = true;
|
||||||
let post_listings_is_admin = data
|
let post_listings_is_admin = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.creator_id(Some(data.inserted_bot.id))
|
.creator_id(Some(data.inserted_bot.id))
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
|
@ -1293,8 +1281,7 @@ mod tests {
|
||||||
(Some(&data.blocked_local_user_view), false),
|
(Some(&data.blocked_local_user_view), false),
|
||||||
(Some(&data.local_user_view), true),
|
(Some(&data.local_user_view), true),
|
||||||
] {
|
] {
|
||||||
let contains_deleted = data
|
let contains_deleted = Data::default_post_query(local_user)
|
||||||
.default_post_query(local_user)
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?
|
.await?
|
||||||
|
@ -1336,8 +1323,7 @@ mod tests {
|
||||||
let post_from_blocked_instance = Post::create(pool, &post_form).await?;
|
let post_from_blocked_instance = Post::create(pool, &post_form).await?;
|
||||||
|
|
||||||
// no instance block, should return all posts
|
// no instance block, should return all posts
|
||||||
let post_listings_all = data
|
let post_listings_all = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -1354,8 +1340,7 @@ mod tests {
|
||||||
InstanceBlock::block(pool, &block_form).await?;
|
InstanceBlock::block(pool, &block_form).await?;
|
||||||
|
|
||||||
// now posts from communities on that instance should be hidden
|
// now posts from communities on that instance should be hidden
|
||||||
let post_listings_blocked = data
|
let post_listings_blocked = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -1366,8 +1351,7 @@ mod tests {
|
||||||
|
|
||||||
// after unblocking it should return all posts again
|
// after unblocking it should return all posts again
|
||||||
InstanceBlock::unblock(pool, &block_form).await?;
|
InstanceBlock::unblock(pool, &block_form).await?;
|
||||||
let post_listings_blocked = data
|
let post_listings_blocked = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -1480,8 +1464,7 @@ mod tests {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Make sure you don't see the read post in the results
|
// Make sure you don't see the read post in the results
|
||||||
let post_listings_hide_read = data
|
let post_listings_hide_read = Data::default_post_query(Some(&data.local_user_view))
|
||||||
.default_post_query(Some(&data.local_user_view))
|
|
||||||
.build()
|
.build()
|
||||||
.list(pool)
|
.list(pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
Loading…
Reference in New Issue