Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Greenlight
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
Container 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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arbeitsgruppe Hardwarenahe IT-Systeme
Greenlight
Commits
ba4b7a01
Commit
ba4b7a01
authored
6 years ago
by
Joshua Arts
Browse files
Options
Downloads
Patches
Plain Diff
make user_controller tests not env dependent
parent
71395003
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
spec/controllers/users_controller_spec.rb
+40
-21
40 additions, 21 deletions
spec/controllers/users_controller_spec.rb
with
40 additions
and
21 deletions
spec/controllers/users_controller_spec.rb
+
40
−
21
View file @
ba4b7a01
...
...
@@ -43,6 +43,8 @@ describe UsersController, type: :controller do
end
describe
"GET #new"
do
before
{
allow
(
Rails
.
configuration
).
to
receive
(
:allow_user_signup
).
and_return
(
true
)
}
it
"assigns a blank user to the view"
do
get
:new
expect
(
assigns
(
:user
)).
to
be_a_new
(
User
)
...
...
@@ -50,7 +52,10 @@ describe UsersController, type: :controller do
end
describe
"POST #create"
do
it
"redirects to user room on succesful create"
do
context
"allow greenlight accounts"
do
before
{
allow
(
Rails
.
configuration
).
to
receive
(
:allow_user_signup
).
and_return
(
true
)
}
it
"redirects to user room on successful create"
do
params
=
random_valid_user_params
post
:create
,
params:
params
...
...
@@ -61,14 +66,6 @@ describe UsersController, type: :controller do
expect
(
response
).
to
redirect_to
(
room_path
(
u
.
main_room
))
end
it
"redirects to main room if already authenticated"
do
user
=
create
(
:user
)
@request
.
session
[
:user_id
]
=
user
.
id
post
:create
,
params:
random_valid_user_params
expect
(
response
).
to
redirect_to
(
room_path
(
user
.
main_room
))
end
it
"user saves with greenlight provider"
do
params
=
random_valid_user_params
post
:create
,
params:
params
...
...
@@ -85,6 +82,28 @@ describe UsersController, type: :controller do
end
end
context
"disallow greenlight accounts"
do
before
{
allow
(
Rails
.
configuration
).
to
receive
(
:allow_user_signup
).
and_return
(
false
)
}
it
"redirect to root on attempted create"
do
params
=
random_valid_user_params
post
:create
,
params:
params
u
=
User
.
find_by
(
name:
params
[
:user
][
:name
],
email:
params
[
:user
][
:email
])
expect
(
u
).
to
be_nil
end
end
it
"redirects to main room if already authenticated"
do
user
=
create
(
:user
)
@request
.
session
[
:user_id
]
=
user
.
id
post
:create
,
params:
random_valid_user_params
expect
(
response
).
to
redirect_to
(
room_path
(
user
.
main_room
))
end
end
describe
"PATCH #update"
do
it
"properly updates user attributes"
do
user
=
create
(
:user
)
...
...
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