Skip to content

Commit

Permalink
Fixing flaky test (not related to this PR)
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Aug 14, 2024
1 parent 0e5f785 commit 9f39c2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/project_media_creators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ def create_claim_description_and_fact_check
claim_description: cd,
report_status: (fact_check['publish_report'] ? 'published' : 'unpublished'),
rating: self.set_status,
tags: self.set_tags,
tags: self.set_tags.to_a.map(&:strip),
skip_check_ability: true
})
end
fc
end

def create_tags
self.set_tags.each { |tag| Tag.create!(annotated: self, tag: tag, skip_check_ability: true) } if self.set_tags.is_a?(Array)
self.set_tags.each { |tag| Tag.create!(annotated: self, tag: tag.strip, skip_check_ability: true) } if self.set_tags.is_a?(Array)
end
end
8 changes: 5 additions & 3 deletions test/controllers/graphql_controller_12_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ def teardown
end

test "should treat ' tag' and 'tag' as the same tag, and not try to create a new tag" do
Sidekiq::Testing.inline!
t = create_team
a = ApiKey.create!
b = create_bot_user api_key_id: a.id
Expand All @@ -622,7 +623,7 @@ def teardown
createProjectMedia(input: {
project_id: ' + p.id.to_s + ',
media_type: "Blank",
channel: {main: 1},
channel: { main: 1 },
set_tags: ["science"],
set_status: "verified",
set_claim_description: "Claim #1.",
Expand All @@ -647,13 +648,14 @@ def teardown
post :create, params: { query: query1, team: t.slug }
assert_response :success
assert_equal 'science', JSON.parse(@response.body)['data']['createProjectMedia']['project_media']['tags']['edges'][0]['node']['tag_text']
sleep 1

query2 = ' mutation create {
createProjectMedia(input: {
project_id: ' + p.id.to_s + ',
media_type: "Blank",
channel: {main: 1},
set_tags: [" science"],
channel: { main: 1 },
set_tags: ["science "],
set_status: "verified",
set_claim_description: "Claim #2.",
set_fact_check: {
Expand Down

0 comments on commit 9f39c2b

Please sign in to comment.