releaf-core 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/releaf/action_controller.rb +1 -5
- data/app/lib/releaf/action_controller/exceptions.rb +16 -0
- data/app/lib/releaf/action_controller/resources.rb +5 -1
- data/app/views/releaf/error_pages/_error.html.haml +0 -3
- data/app/views/releaf/error_pages/page_not_found.html.haml +1 -2
- data/lib/releaf/exceptions.rb +1 -0
- data/lib/releaf/route_mapper.rb +1 -1
- data/spec/features/errors_spec.rb +21 -4
- data/spec/routing/route_mapper_spec.rb +4 -4
- metadata +3 -3
- data/app/controllers/releaf/errors_controller.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5ef038649618995ad1209f4a69a9f07dcc563e0
|
4
|
+
data.tar.gz: 1c0d5ffc66e4b4245775fcc2b83d5cabed419384
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a59ef4a453d8c06295572feb9937184cf899f87f6ad362e61063873ced9632dd5790dd9c2d5f29845c98262ee7463e0fb661e88352b3777867451531399fee
|
7
|
+
data.tar.gz: 7e0c50a17a024c48b342e8781087d9fee73cdfee8e6e68f2cba0b97684e1e6ddeb65e0614ea34e72df5a484b87f8b8e98598627f023448a03f15baaa5e5cb697
|
@@ -14,10 +14,10 @@ class Releaf::ActionController < ActionController::Base
|
|
14
14
|
include Releaf::ActionController::RichtextAttachments
|
15
15
|
include Releaf::ActionController::Views
|
16
16
|
include Releaf::ActionController::Layout
|
17
|
+
include Releaf::ActionController::Exceptions
|
17
18
|
include Releaf::Responders
|
18
19
|
|
19
20
|
helper_method :controller_scope_name, :page_title
|
20
|
-
rescue_from Releaf::AccessDenied, with: :access_denied
|
21
21
|
|
22
22
|
respond_to :html
|
23
23
|
respond_to :json, only: [:create, :update]
|
@@ -138,10 +138,6 @@ class Releaf::ActionController < ActionController::Base
|
|
138
138
|
params[:after_save] == "create_another" && feature_available?(:create_another)
|
139
139
|
end
|
140
140
|
|
141
|
-
def access_denied
|
142
|
-
respond_with(nil, responder: action_responder(:access_denied))
|
143
|
-
end
|
144
|
-
|
145
141
|
# Check if @resource has existing restrict relation and it can be deleted
|
146
142
|
#
|
147
143
|
# @return boolean true or false
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Releaf::ActionController::Exceptions
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
rescue_from Releaf::AccessDenied, with: :access_denied
|
6
|
+
rescue_from Releaf::RecordNotFound, with: :page_not_found
|
7
|
+
end
|
8
|
+
|
9
|
+
def page_not_found
|
10
|
+
respond_with(nil, responder: action_responder(:page_not_found))
|
11
|
+
end
|
12
|
+
|
13
|
+
def access_denied
|
14
|
+
respond_with(nil, responder: action_responder(:access_denied))
|
15
|
+
end
|
16
|
+
end
|
@@ -37,7 +37,11 @@ module Releaf::ActionController::Resources
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def load_resource
|
40
|
-
|
40
|
+
begin
|
41
|
+
@resource = resource_class.find(params[:id])
|
42
|
+
rescue ActiveRecord::RecordNotFound
|
43
|
+
raise Releaf::RecordNotFound
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
# Returns true if @resource is assigned (even if it's nil)
|
@@ -1,2 +1 @@
|
|
1
|
-
= render 'releaf/error_pages/error', message: t('Page not found', scope: controller_scope_name), description: t('
|
2
|
-
|
1
|
+
= render 'releaf/error_pages/error', message: t('Page not found', scope: controller_scope_name), description: t('You may have mistyped the address or the page may have moved.', scope: controller_scope_name)
|
data/lib/releaf/exceptions.rb
CHANGED
data/lib/releaf/route_mapper.rb
CHANGED
@@ -4,11 +4,24 @@ describe "Errors feature" do
|
|
4
4
|
auth_as_user
|
5
5
|
end
|
6
6
|
|
7
|
-
it "returns 404 status code and generic error page for nonexistent
|
7
|
+
it "returns 404 status code and generic error page for nonexistent records" do
|
8
|
+
visit "/admin/users/712323/edit"
|
9
|
+
|
10
|
+
expect(page.status_code).to eq(404)
|
11
|
+
within "main" do
|
12
|
+
expect(page).to have_text("Page not found")
|
13
|
+
expect(page).to have_text("You may have mistyped the address or the page may have moved")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns 404 status code and generic error page for nonexistent routes" do
|
8
18
|
visit(releaf_root_path + "/asdassd")
|
9
19
|
|
10
20
|
expect(page.status_code).to eq(404)
|
11
|
-
|
21
|
+
within "main" do
|
22
|
+
expect(page).to have_text("Page not found")
|
23
|
+
expect(page).to have_text("You may have mistyped the address or the page may have moved")
|
24
|
+
end
|
12
25
|
end
|
13
26
|
|
14
27
|
it "returns 403 status code and generic error page for disabled feature" do
|
@@ -17,7 +30,9 @@ describe "Errors feature" do
|
|
17
30
|
visit releaf_permissions_roles_path
|
18
31
|
|
19
32
|
expect(page.status_code).to eq(403)
|
20
|
-
|
33
|
+
within "main" do
|
34
|
+
expect(page).to have_text("edit feature disabled for roles")
|
35
|
+
end
|
21
36
|
end
|
22
37
|
|
23
38
|
it "returns 403 status code and generic error page for restricted content" do
|
@@ -25,6 +40,8 @@ describe "Errors feature" do
|
|
25
40
|
visit releaf_permissions_roles_path
|
26
41
|
|
27
42
|
expect(page.status_code).to eq(403)
|
28
|
-
|
43
|
+
within "main" do
|
44
|
+
expect(page).to have_text("You are not authorized to access roles")
|
45
|
+
end
|
29
46
|
end
|
30
47
|
end
|
@@ -111,7 +111,7 @@ describe Releaf::RouteMapper do
|
|
111
111
|
|
112
112
|
it "route to page not found" do
|
113
113
|
expect(get: "/admin/books/1/toolbox")
|
114
|
-
.to route_to(controller: "releaf/
|
114
|
+
.to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/toolbox")
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -126,7 +126,7 @@ describe Releaf::RouteMapper do
|
|
126
126
|
|
127
127
|
it "route to page not found" do
|
128
128
|
expect(get: "/admin/books/1/toolbox")
|
129
|
-
.to route_to(controller: "releaf/
|
129
|
+
.to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/toolbox")
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -141,7 +141,7 @@ describe Releaf::RouteMapper do
|
|
141
141
|
|
142
142
|
it "does not mount destroy confirm route" do
|
143
143
|
expect(get: "/admin/books/1/confirm_destroy")
|
144
|
-
.to route_to(controller: "releaf/
|
144
|
+
.to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/confirm_destroy")
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -156,7 +156,7 @@ describe Releaf::RouteMapper do
|
|
156
156
|
|
157
157
|
it "does not mount destroy confirm route" do
|
158
158
|
expect(get: "/admin/books/1/confirm_destroy")
|
159
|
-
.to route_to(controller: "releaf/
|
159
|
+
.to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/confirm_destroy")
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: releaf-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CubeSystems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -386,7 +386,6 @@ files:
|
|
386
386
|
- app/builders/releaf/settings/form_builder.rb
|
387
387
|
- app/builders/releaf/settings/table_builder.rb
|
388
388
|
- app/controllers/releaf/action_controller.rb
|
389
|
-
- app/controllers/releaf/errors_controller.rb
|
390
389
|
- app/controllers/releaf/root_controller.rb
|
391
390
|
- app/controllers/releaf/settings_controller.rb
|
392
391
|
- app/helpers/releaf/application_helper.rb
|
@@ -394,6 +393,7 @@ files:
|
|
394
393
|
- app/lib/releaf/action_controller/ajax.rb
|
395
394
|
- app/lib/releaf/action_controller/breadcrumbs.rb
|
396
395
|
- app/lib/releaf/action_controller/builders.rb
|
396
|
+
- app/lib/releaf/action_controller/exceptions.rb
|
397
397
|
- app/lib/releaf/action_controller/features.rb
|
398
398
|
- app/lib/releaf/action_controller/layout.rb
|
399
399
|
- app/lib/releaf/action_controller/notifications.rb
|