Sha256: ffad6e620070942e07a35bbfe1a4aa83ad35d7bed3bd37a20d1213c284f28f7e

Contents?: true

Size: 1.04 KB

Versions: 32

Compression:

Stored size: 1.04 KB

Contents

require "rails_helper"

describe Releaf::Responders::DestroyResponder, type: :controller do
  let(:controller){ Releaf::ActionController.new }
  let(:resource){ Book.new}
  subject{ described_class.new(controller, [resource]) }

  describe "#to_html" do
    before do
      allow(controller).to receive(:request).and_return(request)
      allow(controller).to receive(:formats).and_return([:html])
      allow(subject).to receive(:default_render)
    end

    context "when resource has been successfully destroyed" do
      it "renders success notification" do
        resource.destroy
        expect(subject.controller).to receive(:render_notification).with(true, failure_message_key: "cant destroy, because relations exists")
        subject.to_html
      end
    end

    context "when resource has not been destroyed" do
      it "renders failure notification" do
        expect(subject.controller).to receive(:render_notification).with(false, failure_message_key: "cant destroy, because relations exists")
        subject.to_html
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
releaf-core-2.0.0 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.22 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.21 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.20 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.19 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.18 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.17 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.16 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.15 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.14 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.13 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.12 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.11 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.10 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.9 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.8 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.7 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.6 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.5 spec/lib/releaf/responders/destroy_responder_spec.rb
releaf-core-1.1.4 spec/lib/releaf/responders/destroy_responder_spec.rb