Sha256: 9f580f2f3a2692f160b933e19a6dc2c85344a4145e3ccacfd87d5c074e7d7932
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
require 'test_plugin_helper' module Api module V2 # Tests for the extra methods to play roles on a Host class HostsControllerTest < ActionController::TestCase include ::Dynflow::Testing setup do @host1 = FactoryGirl.create(:host) @host2 = FactoryGirl.create(:host) end after do ::ForemanTasks::Task::DynflowTask.all.each do |task| task.destroy task.delete end end test 'should return an not_found due to non-existent host_id' do post :play_roles, :id => 'non-existent' response = JSON.parse(@response.body) refute_empty response assert_response :not_found end test 'should trigger task on host' do post :play_roles, :id => @host1.id response = JSON.parse(@response.body) assert response['message']['foreman_tasks'].key?('id'), 'task id not contained in response' assert_equal response['message']['host']['name'], @host1.name, 'host name not contained in response' assert_response :success end test 'should trigger two host tasks' do post :multiple_play_roles, :id => [@host1.id, @host2.id] response = JSON.parse(@response.body) assert response['message'].length == 2, 'should trigger two tasks' assert_response :success end end end end
Version data entries
4 entries across 4 versions & 1 rubygems