Sha256: be5cd2359c497e4109312878689ebc23f91bb94b7c1d33354f1236f371c03767

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

require "rails_helper"

RSpec.describe Fume::Cancan::WithScope, type: :controller do
  describe "#with_scope" do
    controller(ApplicationController) {}
    let!(:topic) { Topic.create!(title: "TITLE", online: false) }
    let(:params) { { id: topic.id } }

    action { get :show, Rails.version.start_with?("4.") ? params : { params: params } }

    context "when undefine with_scope option" do
      controller { load_and_authorize_resource :topic, parent: false }
      it { expect(response.body).to eq "FOUND" }
    end

    context "when define with_scope option" do
      controller { load_and_authorize_resource :topic, parent: false, with_scope: -> (base) { base.online } }
      skip_do_action
      it { expect { do_action }.to raise_error(ActiveRecord::RecordNotFound) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fume-cancan-0.1.0 spec/lib/fume/cancan/with_scope_spec.rb