require 'test_helper'

class PapersControllerTest < ActionController::TestCase
  setup do
    @paper = papers(:one)
  end

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:papers)
  end

  test "should get new" do
    get :new
    assert_response :success
  end

  test "should create paper" do
    assert_difference('Paper.count') do
      post :create, paper: { authors: @paper.authors, issue: @paper.issue, journal: @paper.journal, pages: @paper.pages, project_id: @paper.project_id, published_on: @paper.published_on, title: @paper.title, url: @paper.url, volume: @paper.volume }
    end

    assert_redirected_to paper_path(assigns(:paper))
  end

  test "should show paper" do
    get :show, id: @paper
    assert_response :success
  end

  test "should get edit" do
    get :edit, id: @paper
    assert_response :success
  end

  test "should update paper" do
    patch :update, id: @paper, paper: { authors: @paper.authors, issue: @paper.issue, journal: @paper.journal, pages: @paper.pages, project_id: @paper.project_id, published_on: @paper.published_on, title: @paper.title, url: @paper.url, volume: @paper.volume }
    assert_redirected_to paper_path(assigns(:paper))
  end

  test "should destroy paper" do
    assert_difference('Paper.count', -1) do
      delete :destroy, id: @paper
    end

    assert_redirected_to papers_path
  end
end
