Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Com2025-Coursework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Butler, Alexis (UG - Computer Science)
Com2025-Coursework
Commits
f6b49a8a
Commit
f6b49a8a
authored
4 years ago
by
Butler, Alexis (UG - Computer Science)
Browse files
Options
Downloads
Patches
Plain Diff
Wrote and passed admin order controller tests
parent
9b408177
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/routes.rb
+1
-1
1 addition, 1 deletion
config/routes.rb
test/controllers/admin/orders_controller_test.rb
+29
-9
29 additions, 9 deletions
test/controllers/admin/orders_controller_test.rb
with
30 additions
and
10 deletions
config/routes.rb
+
1
−
1
View file @
f6b49a8a
...
...
@@ -13,7 +13,7 @@ Rails.application.routes.draw do
namespace
:admin
do
root
to:
'dashboard#index'
resources
:products
,
:sections
,
:users
,
except:
%i[edit update show]
resources
:orders
,
only:
%i[index
show
destroy]
resources
:orders
,
only:
%i[index destroy]
end
...
...
This diff is collapsed.
Click to expand it.
test/controllers/admin/orders_controller_test.rb
+
29
−
9
View file @
f6b49a8a
require
'test_helper'
#TODO: write order admin tests
class
Admin::OrdersControllerTest
<
ActionDispatch
::
IntegrationTest
test
"should get index"
do
test
'should get table of orders if admin'
do
sign_in_as_admin
get
admin_orders_url
assert_response
(
:success
)
assert_select
'body.orders'
do
assert_select
'a.btn.btn-sm.btn-danger'
,
Order
.
count
end
end
test
"should get create"
do
test
'should not get table of orders if not admin'
do
sign_in_as_tester
get
admin_orders_url
assert_response
(
:redirect
)
assert_redirected_to
(
root_url
)
assert_equal
'You must be admin to go there!'
,
flash
[
:danger
]
end
test
"should get new"
do
test
'should delete an order'
do
sign_in_as_admin
assert_difference
(
'Order.count'
,
-
1
)
do
delete
admin_order_url
(
id:
orders
(
:one
))
end
assert_response
(
:redirect
)
assert_redirected_to
(
admin_orders_url
)
assert_equal
'Order deleted'
,
flash
[
:success
]
end
test
"should get destroy"
do
test
'should not delete an order if not an admin'
do
sign_in_as_tester
assert_no_difference
(
'Order.count'
)
do
delete
admin_order_url
(
id:
orders
(
:one
))
end
assert_response
(
:redirect
)
assert_redirected_to
(
root_url
)
assert_equal
'You must be admin to go there!'
,
flash
[
:danger
]
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