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
052edb3d
Commit
052edb3d
authored
Dec 22, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Append page validation error if view partial is missing
parent
8e5d5d3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
21 deletions
+36
-21
qa/qa/page/view.rb
qa/qa/page/view.rb
+5
-1
qa/spec/page/view_spec.rb
qa/spec/page/view_spec.rb
+31
-20
No files found.
qa/qa/page/view.rb
View file @
052edb3d
...
...
@@ -9,11 +9,15 @@ module QA
end
def
pathname
Pathname
.
new
(
File
.
join
(
__dir__
,
'../../../'
,
@path
))
@pathname
||=
Pathname
.
new
(
File
.
join
(
__dir__
,
'../../../'
,
@path
))
.
cleanpath
.
expand_path
end
def
errors
unless
pathname
.
readable?
return
[
"Missing view partial `
#{
pathname
}
`!"
]
end
##
# Reduce required elements by streaming view and making assertions on
# elements' existence.
...
...
qa/spec/page/view_spec.rb
View file @
052edb3d
...
...
@@ -30,36 +30,47 @@ describe QA::Page::View do
allow
(
File
).
to
receive
(
:new
).
and_return
(
file
)
end
context
'when
pattern is found
'
do
context
'when
view partial is present
'
do
before
do
allow
(
file
).
to
receive
(
:foreach
)
.
and_yield
(
'some element'
).
once
allow
(
element
).
to
receive
(
:matches?
)
.
with
(
'some element'
).
and_return
(
true
)
allow
(
subject
.
pathname
).
to
receive
(
:readable?
)
.
and_return
(
true
)
end
it
'walks through the view and asserts on elements existence'
do
expect
(
subject
.
errors
).
to
be_empty
end
end
context
'when pattern is found'
do
before
do
allow
(
file
).
to
receive
(
:foreach
)
.
and_yield
(
'some element'
).
once
allow
(
element
).
to
receive
(
:matches?
)
.
with
(
'some element'
).
and_return
(
true
)
end
context
'when pattern has not been found'
do
before
do
allow
(
file
).
to
receive
(
:foreach
)
.
and_yield
(
'some element'
).
once
allow
(
element
).
to
receive
(
:matches?
)
.
with
(
'some element'
).
and_return
(
false
)
it
'walks through the view and asserts on elements existence'
do
expect
(
subject
.
errors
).
to
be_empty
end
end
it
'returns an array of errors related to missing elements'
do
expect
(
subject
.
errors
).
not_to
be_empty
expect
(
subject
.
errors
.
first
)
.
to
match
%r(Missing element `.*` in `.*/some/file.html` view)
context
'when pattern has not been found'
do
before
do
allow
(
file
).
to
receive
(
:foreach
)
.
and_yield
(
'some element'
).
once
allow
(
element
).
to
receive
(
:matches?
)
.
with
(
'some element'
).
and_return
(
false
)
end
it
'returns an array of errors related to missing elements'
do
expect
(
subject
.
errors
).
not_to
be_empty
expect
(
subject
.
errors
.
first
)
.
to
match
%r(Missing element `.*` in `.*/some/file.html` view)
end
end
end
context
'when view partial has not been found'
do
pending
it
'returns an error when it is not able to find the partial'
do
expect
(
subject
.
errors
).
to
be_one
expect
(
subject
.
errors
.
first
)
.
to
match
%r(Missing view partial `.*/some/file.html`!)
end
end
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