API: ensure nsfw field in post is returned as a boolean

This commit is contained in:
Jonne Haß 2020-02-01 21:00:31 +01:00
parent 0754c92116
commit b921b71b97
2 changed files with 3 additions and 3 deletions

View file

@ -58,7 +58,7 @@ class StatusMessage < Post
end
def nsfw
text.try(:match, /#nsfw/i) || super
!!(text.try(:match, /#nsfw/i) || super) # rubocop:disable Style/DoubleNegation
end
def comment_email_subject

View file

@ -80,7 +80,7 @@ describe Api::V1::PostsController do
context "access full post by post ID" do
it "gets post" do
base_params = {status_message: {text: "myText"}, public: true}
base_params = {status_message: {text: "myText #nsfw"}, public: true}
poll_params = {poll_question: "something?", poll_answers: %w[yes no maybe]}
location_params = {location_address: "somewhere", location_coords: "1,2"}
merged_params = base_params.merge(location_params)
@ -704,7 +704,7 @@ describe Api::V1::PostsController do
expect(post["post_type"]).to eq(reference_post.post_type)
expect(post["provider_display_name"]).to eq(reference_post.provider_display_name)
expect(post["public"]).to eq(reference_post.public)
expect(post["nsfw"]).to eq(reference_post.nsfw)
expect(post["nsfw"]).to eq(!!reference_post.nsfw) # rubocop:disable Style/DoubleNegation
end
def confirm_interactions(interactions, reference_post)