forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWikiPageViewSpec.coffee
More file actions
170 lines (149 loc) · 4.69 KB
/
Copy pathWikiPageViewSpec.coffee
File metadata and controls
170 lines (149 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
define [
'underscore'
'compiled/models/WikiPage'
'compiled/views/wiki/WikiPageView'
], (_, WikiPage, WikiPageView) ->
QUnit.module 'WikiPageView'
test 'display_show_all_pages makes it through constructor', ->
model = new WikiPage
view = new WikiPageView
model: model
display_show_all_pages: true
equal(true, view.display_show_all_pages)
test 'model.view maintained by item view', ->
model = new WikiPage
view = new WikiPageView
model: model
strictEqual model.view, view, 'model.view is set to the item view'
view.render()
strictEqual model.view, view, 'model.view is set to the item view'
test 'detach/reattach the publish icon view', ->
model = new WikiPage
view = new WikiPageView
model: model
view.render()
$previousEl = view.$el.find('> *:first-child')
view.publishButtonView.$el.data('test-data', 'test-is-good')
view.render()
equal $previousEl.parent().length, 0, 'previous content removed'
equal view.publishButtonView.$el.data('test-data'), 'test-is-good', 'test data preserved (by detach)'
QUnit.module 'WikiPageView:JSON'
test 'modules_path', ->
model = new WikiPage
view = new WikiPageView
model: model
modules_path: '/courses/73/modules'
strictEqual view.toJSON().modules_path, '/courses/73/modules', 'modules_path represented in toJSON'
test 'wiki_pages_path', ->
model = new WikiPage
view = new WikiPageView
model: model
wiki_pages_path: '/groups/73/pages'
strictEqual view.toJSON().wiki_pages_path, '/groups/73/pages', 'wiki_pages_path represented in toJSON'
test 'wiki_page_edit_path', ->
model = new WikiPage
view = new WikiPageView
model: model
wiki_page_edit_path: '/groups/73/pages/37'
strictEqual view.toJSON().wiki_page_edit_path, '/groups/73/pages/37', 'wiki_page_edit_path represented in toJSON'
test 'wiki_page_history_path', ->
model = new WikiPage
view = new WikiPageView
model: model
wiki_page_edit_path: '/groups/73/pages/37/revisions'
strictEqual view.toJSON().wiki_page_edit_path, '/groups/73/pages/37/revisions', 'wiki_page_history_path represented in toJSON'
test 'lock_info.unlock_at', ->
clock = sinon.useFakeTimers(new Date(2012, 0, 31).getTime())
model = new WikiPage
locked_for_user: true
lock_info:
unlock_at: '2012-02-15T12:00:00Z'
view = new WikiPageView
model: model
ok !!view.toJSON().lock_info?.unlock_at.match('Feb'), 'lock_info.unlock_at reformatted and represented in toJSON'
clock.restore()
testRights = (subject, options) ->
test "#{subject}", ->
model = new WikiPage options.attributes, contextAssetString: options.contextAssetString
view = new WikiPageView
model: model
WIKI_RIGHTS: options.WIKI_RIGHTS
PAGE_RIGHTS: options.PAGE_RIGHTS
course_home: options.course_home
json = view.toJSON()
for key of options.CAN
strictEqual json.CAN[key], options.CAN[key], "#{subject} - CAN.#{key}"
testRights 'CAN (manage)',
contextAssetString: 'course_73'
WIKI_RIGHTS:
read: true
manage: true
PAGE_RIGHTS:
update: true
delete: true
read_revisions: true
CAN:
VIEW_PAGES: true
PUBLISH: true
VIEW_UNPUBLISHED: true
UPDATE_CONTENT: true
DELETE: true
READ_REVISIONS: true
ACCESS_GEAR_MENU: true
testRights 'CAN (update)',
contextAssetString: 'group_73'
WIKI_RIGHTS:
read: true
manage: true
PAGE_RIGHTS:
update_content: true
read_revisions: true
CAN:
VIEW_PAGES: true
PUBLISH: false
VIEW_UNPUBLISHED: true
UPDATE_CONTENT: true
DELETE: false
READ_REVISIONS: true
ACCESS_GEAR_MENU: true
testRights 'CAN (read)',
contextAssetString: 'course_73'
WIKI_RIGHTS:
read: true
PAGE_RIGHTS:
read: true
CAN:
VIEW_PAGES: true
PUBLISH: false
VIEW_UNPUBLISHED: false
UPDATE_CONTENT: false
DELETE: false
READ_REVISIONS: false
ACCESS_GEAR_MENU: false
testRights 'CAN (null)',
CAN:
VIEW_PAGES: false
PUBLISH: false
VIEW_UNPUBLISHED: false
UPDATE_CONTENT: false
DELETE: false
READ_REVISIONS: false
ACCESS_GEAR_MENU: false
testRights 'CAN (manage, course home page)',
contextAssetString: 'course_73'
course_home: true
WIKI_RIGHTS:
read: true
manage: true
PAGE_RIGHTS:
update: true
delete: true
read_revisions: true
CAN:
VIEW_PAGES: true
PUBLISH: true
VIEW_UNPUBLISHED: true
UPDATE_CONTENT: true
DELETE: false
READ_REVISIONS: true
ACCESS_GEAR_MENU: true