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
b95b2413
Commit
b95b2413
authored
9 years ago
by
Mauricio Giacomini Girardello
Browse files
Options
Downloads
Patches
Plain Diff
serializing complaint model for orientdb
parent
bebbf08d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/complaint.rb
+7
-2
7 additions, 2 deletions
app/models/complaint.rb
test/models/complaint_test.rb
+41
-0
41 additions, 0 deletions
test/models/complaint_test.rb
with
48 additions
and
2 deletions
app/models/complaint.rb
+
7
−
2
View file @
b95b2413
class
Complaint
class
Complaint
include
ActiveModel
::
Model
include
ActiveModel
::
Model
include
OrientDbSerializable
attr_accessor
:user
,
:object
,
:message
,
:description
attr_accessor
:user
,
:object
,
:message
,
:description
validates_presence_of
:user
,
:object
,
:message
validates_presence_of
:user
,
:object
,
:message
def
self
.
copyrights
def
self
.
copyrights
ComplaintMessage
.
new
(
"Objeto viola direitos autorais"
)
ComplaintMessage
.
new
(
"Objeto viola direitos autorais"
)
...
@@ -19,4 +20,8 @@ class Complaint
...
@@ -19,4 +20,8 @@ class Complaint
def
self
.
fake_user
def
self
.
fake_user
ComplaintMessage
.
new
"Usuário falso"
ComplaintMessage
.
new
"Usuário falso"
end
end
def
to_orientdb_hash
super
.
merge
(
"user"
=>
@user
.
rid
,
"object"
=>
@object
.
id
,
"message"
=>
@message
.
to_s
)
end
end
end
This diff is collapsed.
Click to expand it.
test/models/complaint_test.rb
0 → 100644
+
41
−
0
View file @
b95b2413
require
'test_helper'
class
ComplaintTest
<
ActiveSupport
::
TestCase
should
validate_presence_of
:user
should
validate_presence_of
:object
should
validate_presence_of
:message
test
'serialize for orientdb'
do
complaint
=
Complaint
.
new
(
user:
User
.
new
(
rid:
'#14:15'
),
object:
LearningObject
.
new
(
id:
'#16:43'
),
message:
Complaint
.
copyrights
,
description:
'teste'
)
expected_hash
=
{
"@class"
=>
"Complaint"
,
"user"
=>
complaint
.
user
.
rid
,
"object"
=>
complaint
.
object
.
id
,
"description"
=>
complaint
.
description
,
"message"
=>
complaint
.
message
.
to_s
}
assert_equal
(
expected_hash
,
complaint
.
to_orientdb_hash
)
end
test
'should returns copyright message'
do
assert_complaint_message
Complaint
.
copyrights
end
test
'should returns ofensive content message'
do
assert_complaint_message
Complaint
.
ofensive_content
end
test
'should returns ofensive user message'
do
assert_complaint_message
Complaint
.
ofensive_user
end
test
'should returns fake user message'
do
assert_complaint_message
Complaint
.
fake_user
end
private
def
assert_complaint_message
(
complaint_message
)
assert_instance_of
ComplaintMessage
,
complaint_message
end
end
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