require 'test_helper' class Api::V1::ComputeResourcesControllerTest < ActionController::TestCase def setup Fog.mock! end def teardown Fog.unmock! end valid_attrs = { :name => 'special_compute', :provider => 'EC2', :region => 'eu-west-1', :user => 'user@example.com', :password => 'secret' } test "should get index" do get :index, { } assert_response :success assert_not_nil assigns(:compute_resources) compute_resources = ActiveSupport::JSON.decode(@response.body) assert !compute_resources.empty? end test "should show compute_resource" do get :show, { :id => compute_resources(:one).to_param } assert_response :success show_response = ActiveSupport::JSON.decode(@response.body) assert !show_response.empty? end test "should create valid compute resource" do post :create, { :compute_resource => valid_attrs } assert_response :success show_response = ActiveSupport::JSON.decode(@response.body) assert !show_response.empty? end test "should update compute resource" do put :update, { :id => compute_resources(:mycompute).to_param, :compute_resource => { :description => "new_description" } } assert_equal "new_description", ComputeResource.find_by_name('mycompute').description assert_response :success end test "should destroy compute resource" do assert_difference('ComputeResource.count', -1) do delete :destroy, { :id => compute_resources(:yourcompute).id } end assert_response :success end end