Sha256: 3918cf37cd8530a26fcd1e86023a7413d66217f19dfcee4da38c94655046706e

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

require 'test_helper'

class Api::V1::ModelsControllerTest < ActionController::TestCase

  valid_attrs = { :name => "new model" }

  test "should get index" do
    get :index, { }
    assert_response :success
    assert_not_nil assigns(:models)
  end

  test "should show model" do
    get :show, { :id => models(:one).to_param }
    assert_not_nil assigns(:model)
    assert_response :success
    show_response = ActiveSupport::JSON.decode(@response.body)
    assert !show_response.empty?
  end

  test "should create model" do
    assert_difference('Model.count', +1) do
      post :create, { :model => valid_attrs }
    end
    assert_response :created
    assert_not_nil assigns(:model)
  end

  test "should update model" do
    name = Model.first.name
    put :update, { :id => Model.first.to_param, :name => "#{name}".to_param }
    assert_response :success
  end

  test "should destroy model" do
    id = Model.first.id
    assert_difference('Model.count', -1) do
      delete :destroy, { :id => models(:one).to_param }
    end
    assert_response :success
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/test/functional/api/v1/models_controller_test.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/test/functional/api/v1/models_controller_test.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/test/functional/api/v1/models_controller_test.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/test/functional/api/v1/models_controller_test.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/test/functional/api/v1/models_controller_test.rb