Sha256: 3de2e178483306ee64966ac83653d1f2156c4f48144202703d55e51184576d0b

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe "RailsAdmin Basic Destroy" do

  subject { page }

  describe "destroy" do
    before(:each) do
      @player = FactoryGirl.create :player
      visit delete_path(:model_name => "player", :id => @player.id)
      click_button "Yes, I'm sure"
      @player = RailsAdmin::AbstractModel.new("Player").first
    end

    it "should destroy an object" do
      @player.should be_nil
    end
  end

  describe "destroy with errors" do
    before(:each) do
      Player.any_instance.stub(:destroy).and_return false
      @player = FactoryGirl.create :player
      visit delete_path(:model_name => "player", :id => @player.id)
      click_button "Yes, I'm sure"
    end

    it "should destroy an object" do
      @player.reload.should be
    end
  end

  describe "destroy" do
    before(:each) do
      @player = FactoryGirl.create :player
      visit delete_path(:model_name => "player", :id => @player.id)
      click_button "Cancel"
      @player = RailsAdmin::AbstractModel.new("Player").first
    end

    it "should not destroy an object" do
      @player.should be
    end
  end

  describe "destroy with missing object" do
    before(:each) do
      page.driver.delete(destroy_path(:model_name => "player", :id => 1))
    end

    it "should raise NotFound" do
      page.driver.status_code.should eql(404)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elucid-rails_admin-0.0.1 spec/requests/basic/destroy/rails_admin_basic_destroy_spec.rb