Skip to content
Snippets Groups Projects
ratings_controller_test.rb 1.63 KiB
Newer Older
require 'test_helper'

class V1::RatingControllerTest < ActionController::TestCase
  tests V1::RatingsController
  include Devise::TestHelpers

  test 'should get index' do
    skip('Unsolved issue: ArgumentError: wrong number of arguments (2 for 0)')
  end

  test 'should user show rating' do
    auth_application
    usability = ratings(:usability)
    get :show, id: usability.id
    assert_response :ok
  end

  test 'should user post rating to create and return :unauthorized' do
    post :create, rating: {name: 'my rating',description: 'testing rating'}
    assert_response :unauthorized
  end

  test 'should user post rating to create and return :created code' do
    auth_request users(:jack)
    post :create, rating: {name: 'my rating',description: 'testing rating'}
    assert_response :created
  end

  test 'should user put rating to update and return :ok' do
    auth_request users(:jack)
    usability = ratings(:usability)
    put :update, id: usability.id , rating: { description: 'testing rating'}
    assert_response :ok
  end

  test 'should user put rating to update and return :unauthorized' do
    usability = ratings(:usability)
    put :update, id: usability.id , rating: { description: 'testing rating'}
    assert_response :unauthorized
  end

  test 'should user delete rating to destroy and return :ok' do
    auth_request users(:jack)
    usability = ratings(:usability)
    delete :destroy, id: usability.id
    assert_response :ok
  end

  test 'should user delete rating to destroy and return :unauthorized' do
    usability = ratings(:usability)
    delete :destroy, id: usability.id
    assert_response :unauthorized
  end

end