Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Pierre Boudes
mastodon
Commits
6ec1aa37
Commit
6ec1aa37
authored
7 years ago
by
abcang
Committed by
Eugen Rochko
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Validate data of Imports (#4782)
parent
2c3544ee
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/import.rb
+1
-0
1 addition, 0 deletions
app/models/import.rb
spec/models/import_spec.rb
+19
-0
19 additions, 0 deletions
spec/models/import_spec.rb
with
20 additions
and
0 deletions
app/models/import.rb
+
1
−
0
View file @
6ec1aa37
...
...
@@ -28,4 +28,5 @@ class Import < ApplicationRecord
has_attached_file
:data
,
url:
'/system/:hash.:extension'
,
hash_secret:
ENV
[
'PAPERCLIP_SECRET'
]
validates_attachment_content_type
:data
,
content_type:
FILE_TYPES
validates_attachment_presence
:data
end
This diff is collapsed.
Click to expand it.
spec/models/import_spec.rb
+
19
−
0
View file @
6ec1aa37
require
'rails_helper'
RSpec
.
describe
Import
,
type: :model
do
let
(
:account
)
{
Fabricate
(
:account
)
}
let
(
:type
)
{
'following'
}
let
(
:data
)
{
attachment_fixture
(
'imports.txt'
)
}
describe
'validations'
do
it
'has a valid parameters'
do
import
=
Import
.
create
(
account:
account
,
type:
type
,
data:
data
)
expect
(
import
).
to
be_valid
end
it
'is invalid without an type'
do
import
=
Import
.
create
(
account:
account
,
data:
data
)
expect
(
import
).
to
model_have_error_on_field
(
:type
)
end
it
'is invalid without a data'
do
import
=
Import
.
create
(
account:
account
,
type:
type
)
expect
(
import
).
to
model_have_error_on_field
(
:data
)
end
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