Sha256: ec88c1566b308a24d58751094c23e45648181e54793442fafe94fd19cbb29187

Contents?: true

Size: 1.98 KB

Versions: 14

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'

describe "RailsAdmin Basic Delete" do

  subject { page }

  describe "delete" do
    it "shows \"Delete model\"" do
      @draft = FactoryGirl.create :draft
      @player = @draft.player
      @comment = @player.comments.create
      visit delete_path(:model_name => "player", :id => @player.id)
      should have_content("delete this player")
      should have_link(@player.name, :href => "/admin/player/#{@player.id}")
      should have_link("Draft ##{@draft.id}", :href => "/admin/draft/#{@draft.id}")
      should have_link("Comment ##{@comment.id}", :href => "/admin/comment/#{@comment.id}")
    end
  end

  describe "delete with missing object" do
    before(:each) do
      visit delete_path(:model_name => "player", :id => 1)
    end

    it "raises NotFound" do
      expect(page.driver.status_code).to eq(404)
    end
  end

  describe "with show action disabled" do
    before(:each) do
      RailsAdmin.config.actions do
        dashboard
        index
        delete
      end
      @draft = FactoryGirl.create :draft
      @player = @draft.player
      @comment = @player.comments.create
      visit delete_path(:model_name => "player", :id => @player.id)
    end

    it "shows \"Delete model\"" do
      should have_content("delete this player")
      should_not have_selector("a[href=\"/admin/player/#{@player.id}\"]")
      should_not have_selector("a[href=\"/admin/draft/#{@draft.id}\"]")
      should_not have_selector("a[href=\"/admin/comment/#{@comment.id}\"]")
    end
  end

  describe "delete of an object which has an associated item without id" do
    before(:each) do
      @player = FactoryGirl.create :player
      Player.any_instance.stub(:draft).and_return(Draft.new)
      visit delete_path(:model_name => "player", :id => @player.id)
    end

    it "shows \"Delete model\"" do
      should_not have_content("Routing Error")
      should have_content("delete this player")
      should have_link(@player.name, :href => "/admin/player/#{@player.id}")
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
rails_admin-0.5.0 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.9 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.8 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.7 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.6 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.5 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.4 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-lbgraham-0.4.2 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.3 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.2 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.1 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.4.0 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.3.0 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
rails_admin-0.2.0 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb