Skip to content

Commit

Permalink
updates to stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 28, 2024
1 parent 9b816be commit 0432a10
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/models/explainer_item_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,33 @@ def teardown
end

test "should create explainer item" do
Bot::Alegre.stubs(:request).with('post', '/similarity/async/text', anything).returns(true)
assert_difference 'ExplainerItem.count' do
ExplainerItem.create! explainer: @ex, project_media: @pm
end
Bot::Alegre.unstub(:request)
end

test "should be associated with explainers" do
Bot::Alegre.stubs(:request).with('post', '/similarity/async/text', anything).returns(true)
assert_difference 'ExplainerItem.count' do
@ex.project_medias << @pm
end
assert_equal 1, @ex.project_medias.count
Bot::Alegre.unstub(:request)
end

test "should be associated with items" do
Bot::Alegre.stubs(:request).with('post', '/similarity/async/text', anything).returns(true)
assert_difference 'ExplainerItem.count' do
@pm.explainers << @ex
end
assert_equal 1, @pm.explainers.count
Bot::Alegre.unstub(:request)
end

test "should not create explainer item without mandatory fields" do
Bot::Alegre.stubs(:request).with('post', '/similarity/async/text', anything).returns(true)
ei = ExplainerItem.new
assert_not ei.valid?
ei = ExplainerItem.new project_media: @pm
Expand All @@ -39,9 +46,11 @@ def teardown
assert_not ei.valid?
ei = ExplainerItem.new project_media: @pm, explainer: @ex
assert ei.valid?
Bot::Alegre.unstub(:request)
end

test "should not create associate explainer and item from different workspaces" do
Bot::Alegre.stubs(:request).with('post', '/similarity/async/text', anything).returns(true)
t1 = create_team
e1 = create_explainer team: t1
pm1 = create_project_media team: t1
Expand All @@ -52,9 +61,11 @@ def teardown
assert ExplainerItem.new(project_media: pm2, explainer: e2).valid?
assert_not ExplainerItem.new(project_media: pm1, explainer: e2).valid?
assert_not ExplainerItem.new(project_media: pm2, explainer: e1).valid?
Bot::Alegre.unstub(:request)
end

test "should have versions" do
Bot::Alegre.stubs(:request).with('post', '/similarity/async/text', anything).returns(true)
with_versioning do
u = create_user
t = create_team
Expand All @@ -72,9 +83,11 @@ def teardown
end
end
end
Bot::Alegre.unstub(:request)
end

test "should have permission to create explainer item" do
Bot::Alegre.stubs(:request).with('post', '/similarity/async/text', anything).returns(true)
t1 = create_team
u1 = create_user
create_team_user user: u1, team: t1
Expand Down Expand Up @@ -108,5 +121,6 @@ def teardown
pm2.explainers << e2
end
end
Bot::Alegre.unstub(:request)
end
end

0 comments on commit 0432a10

Please sign in to comment.