Sha256: 25be3cfbba7b7d89387b7e883c8c10042c8a10536f309af8f2f4b66f6b82a41d

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Rearview::DashboardChildrenController do

  let(:parent) { create(:dashboard) }
  before do
    @routes = Rearview::Engine.routes
    sign_in_as create(:user)
  end

  context "GET /children" do
    it "renders the dashboards index view" do
      get :index, dashboard_id: parent.id, format: :json
      expect(response).to render_template("rearview/dashboards/index")
    end
  end

  context "POST /children" do
    it "renders the dashboards show view" do
      json = JsonFactory::Dashboard.create(build(:dashboard))
      json[:dashboard_id] = parent.id
      post :create, json
      expect(response).to render_template("rearview/dashboards/show")
    end
    it "creates the child association to the parent" do
      dashboard = build(:dashboard)
      json = JsonFactory::Dashboard.create(build(:dashboard))
      json[:dashboard_id] = parent.id
      Rearview::Dashboard.stubs(:new).returns(dashboard)
      dashboard.expects(:parent=).with(parent)
      post :create, json
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rearview-1.2.3-jruby spec/controllers/dashboard_children_controller_spec.rb
rearview-1.2.2.rc.2-jruby spec/controllers/dashboard_children_controller_spec.rb
rearview-1.2.2.rc.1-jruby spec/controllers/dashboard_children_controller_spec.rb
rearview-1.2.1-jruby spec/controllers/dashboard_children_controller_spec.rb