Sha256: d89ccb93107c9c34f459550aa0c1ac163510486a83d3a1f6f220d0b16af89578

Contents?: true

Size: 1.54 KB

Versions: 22

Compression:

Stored size: 1.54 KB

Contents

require 'rails_helper'
describe "Errors feature" do
  before do
    auth_as_user
  end

  it "returns 404 status code and generic error page for nonexistent records" do
    visit "/admin/users/712323/edit"

    expect(page.status_code).to eq(404)
    within "main" do
      expect(page).to have_text("Page not found")
      expect(page).to have_text("You may have mistyped the address or the page may have moved")
    end
  end

  it "returns 404 status code and generic error page for nonexistent routes" do
    visit(releaf_root_path + "/asdassd")

    expect(page.status_code).to eq(404)
    within "main" do
      expect(page).to have_text("Page not found")
      expect(page).to have_text("You may have mistyped the address or the page may have moved")
    end
  end

  it "returns 403 status code and generic error page for disabled feature" do
    allow_any_instance_of(Releaf::Permissions::RolesController).to receive(:verify_feature_availability!)
      .and_raise(Releaf::FeatureDisabled, "edit")
    visit releaf_permissions_roles_path

    expect(page.status_code).to eq(403)
    within "main" do
      expect(page).to have_text("edit feature disabled for roles")
    end
  end

  it "returns 403 status code and generic error page for restricted content" do
    allow_any_instance_of(Releaf::Permissions::AccessControl).to receive(:controller_permitted?).and_return(false)
    visit releaf_permissions_roles_path

    expect(page.status_code).to eq(403)
    within "main" do
      expect(page).to have_text("You are not authorized to access roles")
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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