Skip to content

Commit

Permalink
move tests from TagTest to ProjectMedia8Test
Browse files Browse the repository at this point in the history
What we are testing is that tags are being created when we create a
project media.

The method we use to do that is a method called by project_media,
so I thought it made more sense to move the tests.
  • Loading branch information
vasconsaurus committed Sep 2, 2024
1 parent 23315b0 commit 158e8f6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
29 changes: 29 additions & 0 deletions test/models/project_media_8_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative '../test_helper'

class ProjectMedia8Test < ActiveSupport::TestCase
def setup
super
require 'sidekiq/testing'
end

test "when creating an item with tag/tags, tags should be created in the background" do
Sidekiq::Testing.inline!

t = create_team
p = create_project team: t
assert_nothing_raised do
create_project_media project: p, tags: ['one']
end
end

test "when creating an item with multiple tags, only one job should be scheduled" do
Sidekiq::Testing.fake!

t = create_team
p = create_project team: t
assert_nothing_raised do
create_project_media project: p, tags: ['one', 'two', 'three']
end
assert_equal 1, GenericWorker.jobs.size
end
end
21 changes: 0 additions & 21 deletions test/models/tag_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,25 +284,4 @@ def setup
create_tag tag: ' foo', annotated: pm2
end
end

test "tags should be created in the background" do
Sidekiq::Testing.inline!

t = create_team
p = create_project team: t
assert_nothing_raised do
create_project_media project: p, tags: ['one']
end
end

test "when creating multiple tags for the same item only one job should be scheduled" do
Sidekiq::Testing.fake!

t = create_team
p = create_project team: t
assert_nothing_raised do
create_project_media project: p, tags: ['one', 'two', 'three']
end
assert_equal 1, GenericWorker.jobs.size
end
end

0 comments on commit 158e8f6

Please sign in to comment.