Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
40a23685
Commit
40a23685
authored
Apr 29, 2021
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add path for fixture for schema json
Add a sample test in survey response controller
parent
4bf5ff00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
ee/spec/controllers/survey_responses_controller_spec.rb
ee/spec/controllers/survey_responses_controller_spec.rb
+2
-0
spec/support/matchers/schema_matcher.rb
spec/support/matchers/schema_matcher.rb
+3
-4
No files found.
ee/spec/controllers/survey_responses_controller_spec.rb
View file @
40a23685
...
...
@@ -28,6 +28,8 @@ RSpec.describe SurveyResponsesController do
action:
'submit_response'
,
context:
[{
schema:
described_class
::
SURVEY_RESPONSE_SCHEMA_URL
,
data:
{
response:
'bar'
,
survey_id:
1
}
}]
)
match_snowplow_context_schema
(
schema_path:
'survey_response_schema'
,
context:
{
:response
=>
'bar'
,
:survey_id
=>
1
,
:instance_id
=>
2
}
)
end
end
...
...
spec/support/matchers/schema_matcher.rb
View file @
40a23685
...
...
@@ -13,6 +13,7 @@ module SchemaPath
end
Rails
.
root
.
join
(
dir
.
to_s
,
'spec'
,
"fixtures/api/schemas/
#{
schema
}
.json"
).
to_s
Rails
.
root
.
join
(
dir
.
to_s
,
'spec'
,
"fixtures/product_intelligence/
#{
schema
}
.json"
).
to_s
end
def
self
.
validator
(
schema_path
)
...
...
@@ -46,13 +47,11 @@ RSpec::Matchers.define :match_response_schema do |schema, dir: nil, **options|
end
RSpec
::
Matchers
.
define
:match_snowplow_schema
do
|
schema
,
dir:
nil
,
**
options
|
match
do
|
response
|
match
do
|
data
|
schema_path
=
Pathname
.
new
(
SchemaPath
.
expand
(
schema
,
dir
))
validator
=
SchemaPath
.
validator
(
schema_path
)
data
=
Gitlab
::
Json
.
parse
(
response
.
body
)
validator
.
valid?
(
data
)
validator
.
valid?
(
data
.
stringify_keys
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment