Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
baf3ebbe
Commit
baf3ebbe
authored
8 years ago
by
Mauricio Giacomini Girardello
Browse files
Options
Downloads
Patches
Plain Diff
authorizing destroy reviews requests
parent
282833dd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/concerns/reviewable_controller.rb
+1
-1
1 addition, 1 deletion
app/controllers/concerns/reviewable_controller.rb
app/policies/review_policy.rb
+6
-4
6 additions, 4 deletions
app/policies/review_policy.rb
config/routes.rb
+0
-1
0 additions, 1 deletion
config/routes.rb
with
7 additions
and
6 deletions
app/controllers/concerns/reviewable_controller.rb
+
1
−
1
View file @
baf3ebbe
...
@@ -45,7 +45,7 @@ module ReviewableController
...
@@ -45,7 +45,7 @@ module ReviewableController
rate
=
Rate
.
where
(
user:
current_user
,
review:
@review
).
first_or_initialize
rate
=
Rate
.
where
(
user:
current_user
,
review:
@review
).
first_or_initialize
if
rate
.
update
(
approves:
approves
)
if
rate
.
update
(
approves:
approves
)
render
json:
rate
,
status: :
ok
render
json:
rate
,
status: :
created
else
else
render
json:
rate
.
errors
,
status: :unprocessable_entity
render
json:
rate
.
errors
,
status: :unprocessable_entity
end
end
...
...
This diff is collapsed.
Click to expand it.
app/policies/review_policy.rb
+
6
−
4
View file @
baf3ebbe
...
@@ -5,18 +5,20 @@ class ReviewPolicy < ApplicationPolicy
...
@@ -5,18 +5,20 @@ class ReviewPolicy < ApplicationPolicy
end
end
def
update?
def
update?
record
if
own
s
?
record
if
own?
end
end
def
destroy?
def
destroy?
record
if
record
.
user
==
user
record
if
own?
end
end
def
rate?
def
rate?
record
if
user_exists?
record
if
user_exists?
end
end
def
owner
private
record
.
users
def
own?
record
.
user
==
user
end
end
end
end
This diff is collapsed.
Click to expand it.
config/routes.rb
+
0
−
1
View file @
baf3ebbe
...
@@ -35,7 +35,6 @@ Rails.application.routes.draw do
...
@@ -35,7 +35,6 @@ Rails.application.routes.draw do
mount_devise_token_auth_for
'User'
,
skip:
[
:omniauth_callbacks
],
at: :auth
mount_devise_token_auth_for
'User'
,
skip:
[
:omniauth_callbacks
],
at: :auth
end
end
# devise_for :users, :controllers => { :omniauth_callbacks => "callbacks" }
namespace
:v1
do
namespace
:v1
do
resources
:users
,
concerns: :followable
do
resources
:users
,
concerns: :followable
do
member
do
member
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment