Sha256: 228004478e8beb67b4baaf6fa93488875e7df431c7a100ced53c170f1858699c

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'

module Plotline
  class EntriesControllerTest < ActionController::TestCase
    setup do
      @entry = plotline_entries(:sample)
      @routes = Engine.routes

      EntriesController.any_instance.stubs(:current_user).returns(Plotline::User.new)
    end

    test "should redirect to sign_in_url if not logged in" do
      EntriesController.any_instance.stubs(:current_user).returns(nil)

      get :index, params: { content_class: 'BlogPost' }
      assert_redirected_to '/plotline/sign-in'
    end

    test "should get index" do
      get :index, params: { content_class: 'BlogPost' }
      assert_response :success
      assert_not_nil assigns(:entries)
    end

    test "should show entry" do
      get :show, params: { id: @entry, content_class: 'BlogPost' }
      assert_response :success
    end

    test "should destroy entry" do
      assert_difference('Entry.count', -1) do
        delete :destroy, params: { content_class: 'BlogPost', id: @entry }
      end

      assert_redirected_to entries_path(content_class: 'blog_posts')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plotline-0.1.1 test/controllers/plotline/entries_controller_test.rb
plotline-0.1.0 test/controllers/plotline/entries_controller_test.rb