diff --git a/test/models/explainer_item_test.rb b/test/models/explainer_item_test.rb index 39fff5a3c..c73a98875 100644 --- a/test/models/explainer_item_test.rb +++ b/test/models/explainer_item_test.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -108,5 +121,6 @@ def teardown pm2.explainers << e2 end end + Bot::Alegre.unstub(:request) end end