Sha256: 8aaf07288464a0190c1b67ee848de1fd6e465a78ad21b451155cab38f5c944a0

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

module Prosperity
  describe DashboardsController do
    let!(:dashboard) { Dashboard.create! title: "My Dashboard", default: false }
    routes { Prosperity::Engine.routes }

    describe "GET 'index'" do
      it "returns http success" do
        get 'index'
        response.should be_success
        assigns(:dashboards).should be_present
      end
    end

    describe "GET 'show'" do
      it "returns http success" do
        get 'show', id: dashboard.id
        response.should be_success
        assigns(:dashboard).should == dashboard
      end
    end

    describe "GET 'edit'" do
      it "returns http success" do
        get 'edit', id: dashboard.id
        response.should be_success
        assigns(:dashboard).should == dashboard
      end
    end

    describe "GET 'new'" do
      it "returns http success" do
        get 'new'
        response.should be_success
      end
    end

    describe "POST 'create'" do
      it "creates a new dashboard" do
        expect do
          post 'create', dashboard: {title: 'test'}
        end.to change(Dashboard, :count).by(1)
        response.should redirect_to(action: :index)
      end

      it "should handle validation error" do
        post 'create', dashboard: {title: ''}
        response.status.should == 200
        flash[:error].should be_present
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prosperity-0.0.5 spec/controllers/prosperity/dashboards_controller_spec.rb
prosperity-0.0.4 spec/controllers/prosperity/dashboards_controller_spec.rb
prosperity-0.0.3 spec/controllers/prosperity/dashboards_controller_spec.rb
prosperity-0.0.2 spec/controllers/prosperity/dashboards_controller_spec.rb