Sha256: 250fcb43ff9e1b5400c53b523c3c2a36772f9c3e94819b4099607f30bc9ce7db

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

require 'test_helper'

class InfosourcesControllerTest < ActionController::TestCase

  context "for logged in user" do

    setup do
      activate_authlogic
      @user = User.make
      @user.has_role!(:admin)
      UserSession.create(@user)
    end

    context "on GET to index" do
      setup { get :index }
      should_respond_with :success
      should "have infosources set" do
        assert_not_nil assigns(:infosources)
      end
      should_render_template :index
    end

    context "on GET to new" do
      setup { get :new }
      should_respond_with :success
      should_render_template :new
    end

    context "on POST to create" do
      setup { post :create, :infosource => Infosource.plan }
      should_change('the number of infosources', :by => 1) { Infosource.count }
      should_redirect_to("the newly created infosource") { infosource_path(assigns(:infosource)) }
    end

    context "on POST to create invalid infosource" do
      setup { post :create, :infosource => Infosource.plan(
        :sourcename => 'x' * (Infosource::MIN_SOURCENAME_SIZE-1))}
      should_not_change('the number of infosources') { Infosource.count }
      should_render_template :new
    end

    context "on GET to show" do
      setup { get :show, :id => Infosource.make }
      should_respond_with :success
    end

    context "on GET to edit" do
      setup { get :edit, :id => Infosource.make }
      should_respond_with :success
    end

    context "on PUT to update" do
      setup { put :update, :id => Infosource.make, :infosource => Infosource.plan }
      should_redirect_to("the updated infosource") { infosource_path(assigns(:infosource)) }
    end

    context "on DELETE after destroy action" do
      setup { delete :destroy, :id => (@infosource = Infosource.make) }
      should "not find the destroyed infosource" do
        assert !Infosource.exists?(@infosource)
      end
      should_redirect_to("the list of infosources") { infosources_path }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solarsearch-0.0.10 test/functional/infosources_controller_test.rb
solarsearch-0.0.9 test/functional/infosources_controller_test.rb
solarsearch-0.0.6 test/functional/infosources_controller_test.rb