@@ -16,7 +16,8 @@ use WebGUI::Test;
16
16
17
17
use Test::More; # increment this value for each test you create
18
18
use Test::Deep;
19
- plan tests => 30;
19
+
20
+ plan tests => 31;
20
21
21
22
use WebGUI::Session;
22
23
use WebGUI::Storage;
@@ -172,10 +173,11 @@ $event6->setRelatedLinks([
172
173
sequenceNumber => 2,
173
174
linkurl => ' http://www.somewhere.com' ,
174
175
linktext => ' Another great link' ,
175
- groupIdView => ' 7 ' ,
176
+ groupIdView => ' 2 ' ,
176
177
eventlinkId => ' 28' ,
177
178
},
178
179
]);
180
+ $session -> user({userId => 3}); # admin can see all the links
179
181
cmp_deeply(
180
182
$event6 -> getRelatedLinks(),
181
183
[{
@@ -190,12 +192,25 @@ cmp_deeply(
190
192
sequenceNumber => 2,
191
193
linkURL => ' http://www.somewhere.com' ,
192
194
linktext => ' Another great link' ,
193
- groupIdView => ' 7 ' ,
195
+ groupIdView => ' 2 ' ,
194
196
eventlinkId => ' 28' ,
195
197
assetId => $event6 -> getId,
196
198
}],
197
199
' related links stored in the database correctly'
198
200
);
201
+ $session -> user({userId => 1}); # visitor can only see one link
202
+ cmp_deeply(
203
+ $event6 -> getRelatedLinks(),
204
+ [{
205
+ sequenceNumber => 1,
206
+ linkURL => ' http://www.nowhere.com' ,
207
+ linktext => ' Great link' ,
208
+ groupIdView => ' 7' ,
209
+ eventlinkId => ' 27' ,
210
+ assetId => $event6 -> getId,
211
+ }],
212
+ ' related links:user access restriction works'
213
+ );
199
214
200
215
# ######################################
201
216
#
@@ -206,6 +221,7 @@ cmp_deeply(
206
221
my $event6b = $event6 -> duplicate();
207
222
ok($session -> id-> valid($event6b -> get(' storageId' )), ' duplicated event got a valid storageId' );
208
223
isnt($event6b -> get(' storageId' ), $event6 -> get(' storageId' ), ' duplicating an asset creates a new storage location' );
224
+ $session -> user({userId => 3}); # admin can see all the links
209
225
cmp_deeply(
210
226
$event6b -> getRelatedLinks(),
211
227
[{
@@ -220,12 +236,13 @@ cmp_deeply(
220
236
sequenceNumber => 2,
221
237
linkURL => ' http://www.somewhere.com' ,
222
238
linktext => ' Another great link' ,
223
- groupIdView => ' 7 ' ,
239
+ groupIdView => ' 2 ' ,
224
240
eventlinkId => ignore(),
225
241
assetId => $event6b -> getId,
226
242
}],
227
243
' duplicated event has relatedLinks'
228
244
);
245
+ $session -> user({userId => 1}); # run remaining tests as visitor
229
246
230
247
# ######################################
231
248
#
0 commit comments