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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
1f7490a2
Commit
1f7490a2
authored
May 23, 2015
by
Robert Speicher
Committed by
Dmitriy Zaporozhets
Jun 22, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update spec/features/security specs
parent
20a871cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
43 deletions
+26
-43
spec/features/security/profile_access_spec.rb
spec/features/security/profile_access_spec.rb
+1
-1
spec/support/matchers.rb
spec/support/matchers.rb
+25
-42
No files found.
spec/features/security/profile_access_spec.rb
View file @
1f7490a2
...
@@ -6,7 +6,7 @@ describe "Profile access", feature: true do
...
@@ -6,7 +6,7 @@ describe "Profile access", feature: true do
end
end
describe
"GET /login"
do
describe
"GET /login"
do
it
{
expect
(
new_user_session_path
).
not_to
be_
404
_for
:visitor
}
it
{
expect
(
new_user_session_path
).
not_to
be_
not_found
_for
:visitor
}
end
end
describe
"GET /profile/keys"
do
describe
"GET /profile/keys"
do
...
...
spec/support/matchers.rb
View file @
1f7490a2
RSpec
::
Matchers
.
define
:be_valid_commit
do
RSpec
::
Matchers
.
define
:be_valid_commit
do
match
do
|
actual
|
match
do
|
actual
|
actual
!=
nil
actual
&&
actual
.
id
==
ValidCommit
::
ID
actual
.
id
==
ValidCommit
::
ID
&&
actual
.
message
==
ValidCommit
::
MESSAGE
actual
.
message
==
ValidCommit
::
MESSAGE
&&
actual
.
author_name
==
ValidCommit
::
AUTHOR_FULL_NAME
actual
.
author_name
==
ValidCommit
::
AUTHOR_FULL_NAME
end
end
end
end
def
emulate_user
(
user
)
user
=
case
user
when
:user
then
create
(
:user
)
when
:visitor
then
nil
when
:admin
then
create
(
:admin
)
else
user
end
login_with
(
user
)
if
user
end
RSpec
::
Matchers
.
define
:be_allowed_for
do
|
user
|
RSpec
::
Matchers
.
define
:be_allowed_for
do
|
user
|
match
do
|
url
|
match
do
|
url
|
include
UrlAccess
emulate_user
(
user
)
url_allowed?
(
user
,
url
)
visit
url
status_code
!=
404
&&
current_path
!=
new_user_session_path
end
end
end
end
RSpec
::
Matchers
.
define
:be_denied_for
do
|
user
|
RSpec
::
Matchers
.
define
:be_denied_for
do
|
user
|
match
do
|
url
|
match
do
|
url
|
include
UrlAccess
emulate_user
(
user
)
url_denied?
(
user
,
url
)
visit
url
status_code
==
404
||
current_path
==
new_user_session_path
end
end
end
end
RSpec
::
Matchers
.
define
:be_
404
_for
do
|
user
|
RSpec
::
Matchers
.
define
:be_
not_found
_for
do
|
user
|
match
do
|
url
|
match
do
|
url
|
include
UrlAccess
emulate_user
(
user
)
url_404?
(
user
,
url
)
visit
url
status_code
==
404
end
end
end
end
...
@@ -34,7 +47,7 @@ RSpec::Matchers.define :include_module do |expected|
...
@@ -34,7 +47,7 @@ RSpec::Matchers.define :include_module do |expected|
end
end
description
do
description
do
"include the
#{
expected
}
module"
"include
s
the
#{
expected
}
module"
end
end
failure_message
do
failure_message
do
...
@@ -42,36 +55,6 @@ RSpec::Matchers.define :include_module do |expected|
...
@@ -42,36 +55,6 @@ RSpec::Matchers.define :include_module do |expected|
end
end
end
end
module
UrlAccess
def
url_allowed?
(
user
,
url
)
emulate_user
(
user
)
visit
url
(
status_code
!=
404
&&
current_path
!=
new_user_session_path
)
end
def
url_denied?
(
user
,
url
)
emulate_user
(
user
)
visit
url
(
status_code
==
404
||
current_path
==
new_user_session_path
)
end
def
url_404?
(
user
,
url
)
emulate_user
(
user
)
visit
url
status_code
==
404
end
def
emulate_user
(
user
)
user
=
case
user
when
:user
then
create
(
:user
)
when
:visitor
then
nil
when
:admin
then
create
(
:admin
)
else
user
end
login_with
(
user
)
if
user
end
end
# Extend shoulda-matchers
# Extend shoulda-matchers
module
Shoulda::Matchers::ActiveModel
module
Shoulda::Matchers::ActiveModel
class
ValidateLengthOfMatcher
class
ValidateLengthOfMatcher
...
...
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