Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F401793
filesets_controller_spec.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Feb 20, 10:14 AM
Size
2 KB
Mime Type
text/x-ruby
Expires
Sat, Feb 22, 10:14 AM (27 m, 41 s)
Engine
blob
Format
Raw Data
Handle
191780
Attached To
rARCHIVING archiving
filesets_controller_spec.rb
View Options
require
'spec_helper'
describe
FilesetsController
do
let
(
:host
)
{
FactoryGirl
.
create
(
:host
)
}
let
(
:user
)
{
FactoryGirl
.
create
(
:user
)
}
before
do
host
.
users
<<
user
controller
.
stub
(
:current_user
)
{
user
}
end
describe
'GET #new'
do
before
{
get
:new
,
host_id
:
host
.
id
}
it
'initializes a fileset'
do
expect
(
assigns
(
:fileset
))
.
to
be
end
it
'sets host the fileset\'s host'
do
expect
(
assigns
(
:fileset
)
.
host
)
.
to
eq
(
host
)
end
it
'renders'
do
expect
(
response
)
.
to
render_template
(
:new
)
end
end
describe
'POST #create'
do
context
'with valid params'
do
let
(
:params
)
do
{
host_id
:
host
.
id
,
fileset
:
{
name
:
FactoryGirl
.
build
(
:fileset
)
.
name
,
exclude_directions
:
[
'/proc'
,
'/tmp'
]
,
include_files
:
[
'/home'
,
'/media'
]
}
}
end
it
'creates the fileset'
do
expect
{
post
:create
,
params
}
.
to
change
{
host
.
filesets
(
true
)
.
count
}
.
by
(
1
)
end
it
'redirects to a new job form'
do
post
:create
,
params
expect
(
response
)
.
to
redirect_to
(
new_host_job_path
(
host
,
fileset_id
:
Fileset
.
last
.
id
))
end
context
'and an existing job'
do
let
(
:job
)
{
FactoryGirl
.
create
(
:job_template
,
host
:
host
)
}
it
'redirects to the job\'s edit form'
do
post
:create
,
params
.
merge
(
job_id
:
job
.
id
)
expect
(
response
)
.
to
redirect_to
(
edit_host_job_path
(
host
,
job
,
fileset_id
:
Fileset
.
last
.
id
))
end
end
end
context
'with invalid params'
do
let
(
:params
)
do
{
host_id
:
host
.
id
,
fileset
:
{
invalid
:
:foo
}
}
end
it
'initializes a fileset with errors'
do
post
:create
,
params
expect
(
assigns
(
:fileset
))
.
to
be
end
it
'sets the host'
do
post
:create
,
params
expect
(
assigns
(
:fileset
)
.
host
)
.
to
eq
(
host
)
end
it
'does not create the fileset'
do
expect
{
post
:create
,
params
}
.
to_not
change
{
Fileset
.
count
}
end
it
'renders :new'
do
post
:create
,
params
expect
(
response
)
.
to
render_template
(
:new
)
end
end
end
end
Event Timeline
Log In to Comment