Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
d9d816bd
Commit
d9d816bd
authored
10 years ago
by
Vincent Petry
Browse files
Options
Downloads
Patches
Plain Diff
Unit tests for share dropdown with nested link share
parent
0bd17eff
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
core/js/share.js
+2
-0
2 additions, 0 deletions
core/js/share.js
core/js/tests/specs/shareSpec.js
+145
-1
145 additions, 1 deletion
core/js/tests/specs/shareSpec.js
with
147 additions
and
1 deletion
core/js/share.js
+
2
−
0
View file @
d9d816bd
...
...
@@ -620,6 +620,7 @@ OC.Share={
var
file
=
$
(
'
#dir
'
).
val
()
+
'
/
'
+
filename
;
}
file
=
'
/
'
+
OC
.
currentUser
+
'
/files
'
+
file
;
// TODO: use oc webroot ?
var
link
=
parent
.
location
.
protocol
+
'
//
'
+
location
.
host
+
OC
.
linkTo
(
''
,
'
public.php
'
)
+
'
?service=files&
'
+
type
+
'
=
'
+
encodeURIComponent
(
file
);
}
else
{
//TODO add path param when showing a link to file in a subfolder of a public link share
...
...
@@ -630,6 +631,7 @@ OC.Share={
service
=
linkSharetype
;
}
// TODO: use oc webroot ?
var
link
=
parent
.
location
.
protocol
+
'
//
'
+
location
.
host
+
OC
.
linkTo
(
''
,
'
public.php
'
)
+
'
?service=
'
+
service
+
'
&t=
'
+
token
;
}
...
...
This diff is collapsed.
Click to expand it.
core/js/tests/specs/shareSpec.js
+
145
−
1
View file @
d9d816bd
...
...
@@ -96,7 +96,6 @@ describe('OC.Share tests', function() {
describe
(
'
Share with link
'
,
function
()
{
// TODO: test ajax calls
// TODO: test password field visibility (whenever enforced or not)
// TODO: check public upload visibility based on config
it
(
'
shows share with link checkbox when allowed
'
,
function
()
{
$
(
'
#allowShareWithLink
'
).
val
(
'
yes
'
);
OC
.
Share
.
showDropDown
(
...
...
@@ -121,6 +120,151 @@ describe('OC.Share tests', function() {
);
expect
(
$
(
'
#dropdown #linkCheckbox
'
).
length
).
toEqual
(
0
);
});
it
(
'
shows populated link share when a link share exists
'
,
function
()
{
loadItemStub
.
returns
({
reshare
:
[],
/* jshint camelcase: false */
shares
:
[{
displayname_owner
:
'
root
'
,
expiration
:
null
,
file_source
:
123
,
file_target
:
'
/folder
'
,
id
:
20
,
item_source
:
'
123
'
,
item_type
:
'
folder
'
,
mail_send
:
'
0
'
,
parent
:
null
,
path
:
'
/folder
'
,
permissions
:
OC
.
PERMISSION_READ
,
share_type
:
OC
.
Share
.
SHARE_TYPE_LINK
,
share_with
:
null
,
stime
:
1403884258
,
storage
:
1
,
token
:
'
tehtoken
'
,
uid_owner
:
'
root
'
}]
});
OC
.
Share
.
showDropDown
(
'
file
'
,
123
,
$container
,
'
http://localhost/dummylink
'
,
31
,
'
folder
'
);
expect
(
$
(
'
#dropdown #linkCheckbox
'
).
prop
(
'
checked
'
)).
toEqual
(
true
);
// this is how the OC.Share class does it...
var
link
=
parent
.
location
.
protocol
+
'
//
'
+
location
.
host
+
OC
.
linkTo
(
''
,
'
public.php
'
)
+
'
?service=files&t=tehtoken
'
;
expect
(
$
(
'
#dropdown #linkText
'
).
val
()).
toEqual
(
link
);
});
it
(
'
does not show populated link share when a link share exists for a different file
'
,
function
()
{
loadItemStub
.
returns
({
reshare
:
[],
/* jshint camelcase: false */
shares
:
[{
displayname_owner
:
'
root
'
,
expiration
:
null
,
file_source
:
123
,
file_target
:
'
/folder
'
,
id
:
20
,
item_source
:
'
123
'
,
item_type
:
'
folder
'
,
mail_send
:
'
0
'
,
parent
:
null
,
path
:
'
/folder
'
,
permissions
:
OC
.
PERMISSION_READ
,
share_type
:
OC
.
Share
.
SHARE_TYPE_LINK
,
share_with
:
null
,
stime
:
1403884258
,
storage
:
1
,
token
:
'
tehtoken
'
,
uid_owner
:
'
root
'
}]
});
OC
.
Share
.
showDropDown
(
'
file
'
,
456
,
// another file
$container
,
'
http://localhost/dummylink
'
,
31
,
'
folder
'
);
expect
(
$
(
'
#dropdown #linkCheckbox
'
).
prop
(
'
checked
'
)).
toEqual
(
false
);
});
it
(
'
shows correct link share when a nest link share exists along with parent one
'
,
function
()
{
loadItemStub
.
returns
({
reshare
:
[],
/* jshint camelcase: false */
shares
:
[{
displayname_owner
:
'
root
'
,
expiration
:
null
,
file_source
:
123
,
file_target
:
'
/folder
'
,
id
:
20
,
item_source
:
'
123
'
,
item_type
:
'
file
'
,
mail_send
:
'
0
'
,
parent
:
null
,
path
:
'
/folder
'
,
permissions
:
OC
.
PERMISSION_READ
,
share_type
:
OC
.
Share
.
SHARE_TYPE_LINK
,
share_with
:
null
,
stime
:
1403884258
,
storage
:
1
,
token
:
'
tehtoken
'
,
uid_owner
:
'
root
'
},
{
displayname_owner
:
'
root
'
,
expiration
:
null
,
file_source
:
456
,
file_target
:
'
/file_in_folder.txt
'
,
id
:
21
,
item_source
:
'
456
'
,
item_type
:
'
file
'
,
mail_send
:
'
0
'
,
parent
:
null
,
path
:
'
/folder/file_in_folder.txt
'
,
permissions
:
OC
.
PERMISSION_READ
,
share_type
:
OC
.
Share
.
SHARE_TYPE_LINK
,
share_with
:
null
,
stime
:
1403884509
,
storage
:
1
,
token
:
'
anothertoken
'
,
uid_owner
:
'
root
'
}]
});
// parent one
OC
.
Share
.
showDropDown
(
'
folder
'
,
123
,
$container
,
'
http://localhost/dummylink
'
,
31
,
'
folder
'
);
expect
(
$
(
'
#dropdown #linkCheckbox
'
).
prop
(
'
checked
'
)).
toEqual
(
true
);
// this is how the OC.Share class does it...
var
link
=
parent
.
location
.
protocol
+
'
//
'
+
location
.
host
+
OC
.
linkTo
(
''
,
'
public.php
'
)
+
'
?service=files&t=tehtoken
'
;
expect
(
$
(
'
#dropdown #linkText
'
).
val
()).
toEqual
(
link
);
// nested one
OC
.
Share
.
showDropDown
(
'
file
'
,
456
,
$container
,
'
http://localhost/dummylink
'
,
31
,
'
file_in_folder.txt
'
);
expect
(
$
(
'
#dropdown #linkCheckbox
'
).
prop
(
'
checked
'
)).
toEqual
(
true
);
// this is how the OC.Share class does it...
link
=
parent
.
location
.
protocol
+
'
//
'
+
location
.
host
+
OC
.
linkTo
(
''
,
'
public.php
'
)
+
'
?service=files&t=anothertoken
'
;
expect
(
$
(
'
#dropdown #linkText
'
).
val
()).
toEqual
(
link
);
});
});
describe
(
'
"sharesChanged" event
'
,
function
()
{
var
autocompleteOptions
;
...
...
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