mumuki-laboratory 9.12.1 → 9.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. data/app/controllers/application_controller.rb +7 -3
  4. data/app/controllers/book_controller.rb +6 -0
  5. data/app/controllers/chapters_controller.rb +9 -0
  6. data/app/controllers/discussions_controller.rb +9 -0
  7. data/app/controllers/exercises_controller.rb +5 -0
  8. data/app/controllers/faqs_controller.rb +4 -0
  9. data/app/controllers/lessons_controller.rb +9 -0
  10. data/app/controllers/users_controller.rb +4 -0
  11. data/app/helpers/concerns/with_student_path_navigation.rb +1 -1
  12. data/app/helpers/content_view_helper.rb +8 -0
  13. data/app/helpers/discussions_helper.rb +1 -1
  14. data/app/helpers/links_helper.rb +5 -1
  15. data/app/helpers/menu_bar_helper.rb +2 -3
  16. data/app/helpers/overlapped_buttons_helper.rb +2 -1
  17. data/app/views/book/show.html.erb +16 -7
  18. data/app/views/chapters/show.html.erb +1 -0
  19. data/app/views/discussions/_new_message.html.erb +1 -1
  20. data/app/views/discussions/show.html.erb +5 -5
  21. data/app/views/exercise_solutions/_results.html.erb +1 -1
  22. data/app/views/guides/_guide.html.erb +2 -2
  23. data/app/views/layouts/_progress_bar.html.erb +1 -0
  24. data/app/views/layouts/_progress_listing.html.erb +1 -0
  25. data/app/views/layouts/application.html.erb +4 -0
  26. data/app/views/layouts/exercise_inputs/forms/_kids_form.html.erb +1 -1
  27. data/app/views/layouts/exercise_inputs/forms/_problem_form.html.erb +6 -2
  28. data/app/views/layouts/exercise_inputs/read_only_editors/_hidden.html.erb +0 -0
  29. data/app/views/layouts/exercise_inputs/read_only_editors/_upload.html.erb +0 -0
  30. data/lib/mumuki/laboratory/controllers.rb +1 -0
  31. data/lib/mumuki/laboratory/controllers/authorization.rb +5 -1
  32. data/lib/mumuki/laboratory/controllers/validate_access_mode.rb +15 -0
  33. data/lib/mumuki/laboratory/version.rb +1 -1
  34. data/spec/features/menu_bar_spec.rb +3 -2
  35. data/spec/features/not_found_private_flow_spec.rb +1 -1
  36. data/spec/features/read_only_flow_spec.rb +920 -0
  37. metadata +13 -14
@@ -14,3 +14,4 @@ require_relative './controllers/nested_in_exercise'
14
14
  require_relative './controllers/results_rendering'
15
15
  require_relative './controllers/exercise_seed'
16
16
  require_relative './controllers/content'
17
+ require_relative './controllers/validate_access_mode'
@@ -1,10 +1,14 @@
1
1
  module Mumuki::Laboratory::Controllers::Authorization
2
2
  def authorize_if_private!
3
3
  return if Organization.current.public? || from_sessions?
4
- authorize! :student
4
+ authorize! authorization_minimum_role
5
5
  end
6
6
 
7
7
  def authorization_slug
8
8
  Organization.current.slug
9
9
  end
10
+
11
+ def authorization_minimum_role
12
+ :student
13
+ end
10
14
  end
@@ -0,0 +1,15 @@
1
+ module Mumuki::Laboratory::Controllers::ValidateAccessMode
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :validate_accessible!, only: :show
6
+ end
7
+
8
+ def validate_accessible!
9
+ current_access_mode.validate_content_here! subject_container
10
+ end
11
+
12
+ def subject_container
13
+ subject
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Laboratory
3
- VERSION = '9.12.1'
3
+ VERSION = '9.13.0'
4
4
  end
5
5
  end
@@ -50,11 +50,11 @@ feature 'menu bar' do
50
50
  let(:admin) { create(:user, permissions: {student: 'private/*', admin: 'private/*'}) }
51
51
  let(:owner) { create(:user, permissions: {student: 'private/*', owner: 'private/*'}) }
52
52
 
53
- scenario 'visitor should only see their account' do
53
+ scenario 'visitor should only see sing out' do
54
54
  set_current_user! visitor
55
55
 
56
56
  visit '/'
57
- expect(page).to have_text('My account')
57
+ expect(page).not_to have_text('My account')
58
58
  expect(page).not_to have_text('Classroom')
59
59
  expect(page).not_to have_text('Bibliotheca')
60
60
  expect(page).not_to have_text('Solve other\'s doubts')
@@ -93,6 +93,7 @@ feature 'menu bar' do
93
93
  before { Organization.current.update! faqs: "Some faqs" }
94
94
 
95
95
  scenario 'should see FAQs link' do
96
+ set_current_user! student
96
97
  visit '/'
97
98
 
98
99
  expect(page).to have_text('FAQs')
@@ -30,7 +30,7 @@ feature 'not found private on app', organization_workspace: :base do
30
30
  expect(page.text).to json_eq errors: [
31
31
  'The operation on organization base' +
32
32
  ' was forbidden to user foo+1@bar.com' +
33
- ' with permissions !student:central/*;teacher:;headmaster:;janitor:;admin:;owner:']
33
+ ' with permissions !student:central/*;teacher:;headmaster:;janitor:;admin:;owner:;ex_student:']
34
34
  end
35
35
 
36
36
  scenario 'api with authentication', :json_eq_error do
@@ -0,0 +1,920 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Read Only Flow' do
4
+
5
+ let(:organization) { create :organization, name: 'private', forum_enabled: true, public: false, faqs: 'FAQs', book: book }
6
+ let(:user) { create :user }
7
+ let(:other_user) { create :user }
8
+
9
+ let(:slug) { Mumukit::Auth::Slug.join_s organization.name, 'foo' }
10
+
11
+ let(:exercise111) { create :exercise, name: 'Exercise 111' }
12
+ let(:exercise112) { create :exercise, name: 'Exercise 112' }
13
+ let(:exercise121) { create :exercise, name: 'Exercise 121' }
14
+ let(:exercise122) { create :exercise, name: 'Exercise 122' }
15
+ let(:exercise211) { create :exercise, name: 'Exercise 211' }
16
+ let(:exercise212) { create :exercise, name: 'Exercise 212' }
17
+ let(:lesson11) { create :lesson, name: 'Lesson 11', exercises: [exercise111, exercise112] }
18
+ let(:lesson12) { create :lesson, name: 'Lesson 12', exercises: [exercise121, exercise122] }
19
+ let(:lesson21) { create :lesson, name: 'Lesson 21', exercises: [exercise211, exercise212] }
20
+ let(:chapter1) { create :chapter, name: 'Chapter 1', lessons: [lesson11, lesson12] }
21
+ let(:chapter2) { create :chapter, name: 'Chapter 2', lessons: [lesson21] }
22
+ let(:book) { create :book, chapters: [chapter1, chapter2] }
23
+
24
+ let(:assignment111) { build :assignment, submitter: user, organization: organization, exercise: exercise111, status: :failed }
25
+ let(:discussion111) { build :discussion, initiator: assignment111.user, item: assignment111.exercise, organization: assignment111.organization }
26
+
27
+ let(:assignment112) { build :assignment, submitter: other_user, organization: organization, exercise: exercise112, status: :failed }
28
+ let(:discussion112) { build :discussion, initiator: assignment112.user, item: assignment112.exercise, organization: assignment112.organization }
29
+
30
+ before { set_subdomain_host! organization.name }
31
+
32
+ before { set_current_user! user }
33
+
34
+ before { assignment111.save! }
35
+ before { discussion111.save! }
36
+ before { discussion112.save! }
37
+
38
+ context 'in private organization' do
39
+ context 'when organization is enabled' do
40
+ context 'and user is teacher of organization' do
41
+ before { user.update! permissions: { teacher: slug } }
42
+ scenario 'avatar dorpdown' do
43
+ visit "/"
44
+ find('#profileDropdown').click
45
+ expect(page).to have_text('My account')
46
+ expect(page).to have_text('FAQs')
47
+ expect(page).to have_text('Classroom')
48
+ expect(page).to have_text('Solve other\'s doubts')
49
+ expect(page).to have_text('My doubts')
50
+ expect(page).not_to have_text('Bibliotheca')
51
+ expect(page).to have_text('Sign Out')
52
+ end
53
+ scenario 'show book' do
54
+ visit "/"
55
+ expect(page).to have_text('Chapter 1')
56
+ expect(page).to have_text('Chapter 2')
57
+ expect(page).to have_text('Practicing!')
58
+ end
59
+ scenario 'show chapter' do
60
+ visit "/chapters/#{chapter1.id}"
61
+ expect(page).to have_text('Lesson 11')
62
+ expect(page).to have_text('Lesson 12')
63
+ expect(page).to have_text('Exercise 111')
64
+ expect(page).to have_text('Exercise 112')
65
+ expect(page).to have_text('Exercise 121')
66
+ expect(page).to have_text('Exercise 122')
67
+ end
68
+ scenario 'show lesson' do
69
+ visit "/lessons/#{lesson11.id}"
70
+ expect(page).to have_text('Lesson 11')
71
+ expect(page).to have_text('Exercise 111')
72
+ expect(page).to have_text('Exercise 112')
73
+ expect(page).to have_text('Continue this lesson!')
74
+ end
75
+ scenario 'show exercise 111' do
76
+ visit "/exercises/#{exercise111.id}"
77
+ expect(page).to have_text('Exercise 111')
78
+ expect(page).to have_selector(:link_or_button, 'Submit')
79
+ expect(page).to have_text('Solve your doubts')
80
+ end
81
+ scenario 'show exercise 112' do
82
+ visit "/exercises/#{exercise112.id}"
83
+ expect(page).to have_text('Exercise 112')
84
+ expect(page).to have_selector(:link_or_button, 'Submit')
85
+ expect(page).not_to have_text('Solve your doubts')
86
+ end
87
+ scenario 'show profile' do
88
+ visit "/user"
89
+ expect(page).to have_text('My profile')
90
+ end
91
+ scenario 'show faqs' do
92
+ visit "/faqs"
93
+ expect(page).to have_text('FAQs')
94
+ end
95
+ scenario 'show discussion' do
96
+ visit "/discussions"
97
+ expect(page).not_to have_text('You are not allowed to see this content')
98
+ end
99
+ scenario 'show discussion in existent exercise' do
100
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
101
+ expect(page).to have_text('Exercise 111')
102
+ expect(page).to have_selector(:link_or_button, 'Comment')
103
+ end
104
+ scenario 'show discussion in existent exercise' do
105
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
106
+ expect(page).not_to have_text('You are not allowed to see this content')
107
+ end
108
+ scenario 'new discussion' do
109
+ visit "/exercises/#{exercise112.id}/discussions/new"
110
+ expect(page).not_to have_text('You are not allowed to see this content')
111
+ end
112
+ end
113
+
114
+ context 'and user is student of organization' do
115
+ before { user.update! permissions: { student: slug } }
116
+ scenario 'avatar dorpdown' do
117
+ visit "/"
118
+ find('#profileDropdown').click
119
+ expect(page).to have_text('My account')
120
+ expect(page).to have_text('FAQs')
121
+ expect(page).to have_text('Solve other\'s doubts')
122
+ expect(page).to have_text('My doubts')
123
+ expect(page).not_to have_text('Classroom')
124
+ expect(page).not_to have_text('Bibliotheca')
125
+ expect(page).to have_text('Sign Out')
126
+ end
127
+ scenario 'show book' do
128
+ visit "/"
129
+ expect(page).to have_text('Chapter 1')
130
+ expect(page).to have_text('Chapter 2')
131
+ expect(page).to have_text('Practicing!')
132
+ end
133
+ scenario 'show chapter' do
134
+ visit "/chapters/#{chapter1.id}"
135
+ expect(page).to have_text('Lesson 11')
136
+ expect(page).to have_text('Lesson 12')
137
+ expect(page).to have_text('Exercise 111')
138
+ expect(page).to have_text('Exercise 112')
139
+ expect(page).to have_text('Exercise 121')
140
+ expect(page).to have_text('Exercise 122')
141
+ end
142
+ scenario 'show lesson' do
143
+ visit "/lessons/#{lesson11.id}"
144
+ expect(page).to have_text('Lesson 11')
145
+ expect(page).to have_text('Exercise 111')
146
+ expect(page).to have_text('Exercise 112')
147
+ expect(page).to have_text('Continue this lesson!')
148
+ end
149
+ scenario 'show exercise 111' do
150
+ visit "/exercises/#{exercise111.id}"
151
+ expect(page).to have_text('Exercise 111')
152
+ expect(page).to have_selector(:link_or_button, 'Submit')
153
+ expect(page).to have_text('Solve your doubts')
154
+ end
155
+ scenario 'show exercise 112' do
156
+ visit "/exercises/#{exercise112.id}"
157
+ expect(page).to have_text('Exercise 112')
158
+ expect(page).to have_selector(:link_or_button, 'Submit')
159
+ expect(page).not_to have_text('Solve your doubts')
160
+ end
161
+ scenario 'show profile' do
162
+ visit "/user"
163
+ expect(page).to have_text('My profile')
164
+ end
165
+ scenario 'show faqs' do
166
+ visit "/faqs"
167
+ expect(page).to have_text('FAQs')
168
+ end
169
+ scenario 'show discussion' do
170
+ visit "/discussions"
171
+ expect(page).to have_text('Discussions')
172
+ end
173
+ scenario 'show discussion in existent exercise' do
174
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
175
+ expect(page).to have_text('Exercise 111')
176
+ expect(page).to have_selector(:link_or_button, 'Comment')
177
+ end
178
+ scenario 'show discussion in existent exercise' do
179
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
180
+ expect(page).to have_text('Exercise 112')
181
+ expect(page).to have_selector(:link_or_button, 'Comment')
182
+ end
183
+ scenario 'new discussion' do
184
+ visit "/exercises/#{exercise112.id}/discussions/new"
185
+ expect(page).to have_text('Exercise 112')
186
+ expect(page).to have_selector(:link_or_button, 'Publish discussion')
187
+ end
188
+ end
189
+
190
+ context 'and user is ex student of organization' do
191
+ before { user.update! permissions: { ex_student: slug } }
192
+ scenario 'avatar dorpdown' do
193
+ visit "/"
194
+ find('#profileDropdown').click
195
+ expect(page).to have_text('My account')
196
+ expect(page).to have_text('FAQs')
197
+ expect(page).to have_text('My doubts')
198
+ expect(page).not_to have_text('Solve other\'s doubts')
199
+ expect(page).not_to have_text('Classroom')
200
+ expect(page).not_to have_text('Bibliotheca')
201
+ expect(page).to have_text('Sign Out')
202
+ end
203
+ scenario 'show book' do
204
+ visit "/"
205
+ expect(page).to have_text('Chapter 1')
206
+ expect(page).not_to have_text('Chapter 2')
207
+ expect(page).not_to have_text('Practicing!')
208
+ end
209
+ scenario 'show chapter' do
210
+ visit "/chapters/#{chapter1.id}"
211
+ expect(page).to have_text('Lesson 11')
212
+ expect(page).not_to have_text('Lesson 12')
213
+ expect(page).to have_text('Exercise 111')
214
+ expect(page).not_to have_text('Exercise 112')
215
+ expect(page).not_to have_text('Exercise 121')
216
+ expect(page).not_to have_text('Exercise 122')
217
+ end
218
+ scenario 'show lesson' do
219
+ visit "/lessons/#{lesson11.id}"
220
+ expect(page).to have_text('Lesson 11')
221
+ expect(page).to have_text('Exercise 111')
222
+ expect(page).not_to have_text('Exercise 112')
223
+ expect(page).not_to have_text('Continue this lesson!')
224
+ end
225
+ scenario 'show exercise 111' do
226
+ visit "/exercises/#{exercise111.id}"
227
+ expect(page).to have_text('Exercise 111')
228
+ expect(page).not_to have_selector(:link_or_button, 'Submit')
229
+ expect(page).not_to have_text('Solve your doubts')
230
+ end
231
+ scenario 'show exercise 112' do
232
+ visit "/exercises/#{exercise112.id}"
233
+ expect(page).to have_text('You are not allowed to see this content')
234
+ end
235
+ scenario 'show profile' do
236
+ visit "/user"
237
+ expect(page).to have_text('My profile')
238
+ end
239
+ scenario 'show faqs' do
240
+ visit "/faqs"
241
+ expect(page).to have_text('FAQs')
242
+ end
243
+ scenario 'show discussion' do
244
+ visit "/discussions"
245
+ expect(page).to have_text('You are not allowed to see this content')
246
+ end
247
+ scenario 'show discussion in existent exercise' do
248
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
249
+ expect(page).to have_text('Exercise 111')
250
+ expect(page).not_to have_selector(:link_or_button, 'Comment')
251
+ end
252
+ scenario 'show discussion in existent exercise' do
253
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
254
+ expect(page).to have_text('You are not allowed to see this content')
255
+ end
256
+ scenario 'new discussion' do
257
+ visit "/exercises/#{exercise112.id}/discussions/new"
258
+ expect(page).to have_text('You are not allowed to see this content')
259
+ end
260
+ end
261
+
262
+ context 'and user is outsider of organization' do
263
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
264
+ scenario 'avatar dorpdown' do
265
+ visit "/"
266
+ find('#profileDropdown').click
267
+ expect(page).not_to have_text('My account')
268
+ expect(page).not_to have_text('FAQs')
269
+ expect(page).not_to have_text('My doubts')
270
+ expect(page).not_to have_text('Classroom')
271
+ expect(page).not_to have_text('Bibliotheca')
272
+ expect(page).not_to have_text('Solve other\'s doubts')
273
+ expect(page).to have_text('Sign Out')
274
+ end
275
+ scenario 'show book' do
276
+ visit "/"
277
+ expect(page).to have_text('You are not allowed to see this content')
278
+ end
279
+ scenario 'show chapter' do
280
+ visit "/chapters/#{chapter1.id}"
281
+ expect(page).to have_text('You are not allowed to see this content')
282
+ end
283
+ scenario 'show lesson' do
284
+ visit "/lessons/#{lesson11.id}"
285
+ expect(page).to have_text('You are not allowed to see this content')
286
+ end
287
+ scenario 'show exercise 111' do
288
+ visit "/exercises/#{exercise111.id}"
289
+ expect(page).to have_text('You are not allowed to see this content')
290
+ end
291
+ scenario 'show exercise 112' do
292
+ visit "/exercises/#{exercise112.id}"
293
+ expect(page).to have_text('You are not allowed to see this content')
294
+ end
295
+ scenario 'show profile' do
296
+ visit "/user"
297
+ expect(page).to have_text('You are not allowed to see this content')
298
+ end
299
+ scenario 'show faqs' do
300
+ visit "/faqs"
301
+ expect(page).to have_text('You are not allowed to see this content')
302
+ end
303
+ scenario 'show discussion' do
304
+ visit "/discussions"
305
+ expect(page).to have_text('You are not allowed to see this content')
306
+ end
307
+ scenario 'show discussion in existent exercise' do
308
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
309
+ expect(page).to have_text('You are not allowed to see this content')
310
+ end
311
+ scenario 'show discussion in existent exercise' do
312
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
313
+ expect(page).to have_text('You are not allowed to see this content')
314
+ end
315
+ scenario 'new discussion' do
316
+ visit "/exercises/#{exercise112.id}/discussions/new"
317
+ expect(page).to have_text('You are not allowed to see this content')
318
+ end
319
+ end
320
+ end
321
+
322
+ context 'when organization is in preparation' do
323
+ before { organization.update! in_preparation_until: 1.day.since }
324
+
325
+ context 'and user is teacher of organization' do
326
+ before { user.update! permissions: { teacher: slug } }
327
+ scenario 'avatar dorpdown' do
328
+ visit "/"
329
+ find('#profileDropdown').click
330
+ expect(page).to have_text('My account')
331
+ expect(page).to have_text('FAQs')
332
+ expect(page).to have_text('Classroom')
333
+ expect(page).to have_text('Solve other\'s doubts')
334
+ expect(page).to have_text('My doubts')
335
+ expect(page).not_to have_text('Bibliotheca')
336
+ expect(page).to have_text('Sign Out')
337
+ end
338
+ scenario 'show book' do
339
+ visit "/"
340
+ expect(page).to have_text('Chapter 1')
341
+ expect(page).to have_text('Chapter 2')
342
+ expect(page).to have_text('Practicing!')
343
+ end
344
+ scenario 'show chapter' do
345
+ visit "/chapters/#{chapter1.id}"
346
+ expect(page).to have_text('Lesson 11')
347
+ expect(page).to have_text('Lesson 12')
348
+ expect(page).to have_text('Exercise 111')
349
+ expect(page).to have_text('Exercise 112')
350
+ expect(page).to have_text('Exercise 121')
351
+ expect(page).to have_text('Exercise 122')
352
+ end
353
+ scenario 'show lesson' do
354
+ visit "/lessons/#{lesson11.id}"
355
+ expect(page).to have_text('Lesson 11')
356
+ expect(page).to have_text('Exercise 111')
357
+ expect(page).to have_text('Exercise 112')
358
+ expect(page).to have_text('Continue this lesson!')
359
+ end
360
+ scenario 'show exercise 111' do
361
+ visit "/exercises/#{exercise111.id}"
362
+ expect(page).to have_text('Exercise 111')
363
+ expect(page).to have_selector(:link_or_button, 'Submit')
364
+ expect(page).to have_text('Solve your doubts')
365
+ end
366
+ scenario 'show exercise 112' do
367
+ visit "/exercises/#{exercise112.id}"
368
+ expect(page).to have_text('Exercise 112')
369
+ expect(page).to have_selector(:link_or_button, 'Submit')
370
+ expect(page).not_to have_text('Solve your doubts')
371
+ end
372
+ scenario 'show profile' do
373
+ visit "/user"
374
+ expect(page).to have_text('My profile')
375
+ end
376
+ scenario 'show faqs' do
377
+ visit "/faqs"
378
+ expect(page).to have_text('FAQs')
379
+ end
380
+ scenario 'show discussion' do
381
+ visit "/discussions"
382
+ expect(page).not_to have_text('You are not allowed to see this content')
383
+ end
384
+ scenario 'show discussion in existent exercise' do
385
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
386
+ expect(page).to have_text('Exercise 111')
387
+ expect(page).to have_selector(:link_or_button, 'Comment')
388
+ end
389
+ scenario 'show discussion in existent exercise' do
390
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
391
+ expect(page).not_to have_text('You are not allowed to see this content')
392
+ end
393
+ scenario 'new discussion' do
394
+ visit "/exercises/#{exercise112.id}/discussions/new"
395
+ expect(page).not_to have_text('You are not allowed to see this content')
396
+ end
397
+ end
398
+
399
+ context 'and user is student of organization' do
400
+ before { user.update! permissions: { student: slug } }
401
+ scenario 'avatar dorpdown' do
402
+ visit "/"
403
+ find('#profileDropdown').click
404
+ expect(page).not_to have_text('My account')
405
+ expect(page).not_to have_text('FAQs')
406
+ expect(page).not_to have_text('Classroom')
407
+ expect(page).not_to have_text('Solve other\'s doubts')
408
+ expect(page).not_to have_text('My doubts')
409
+ expect(page).not_to have_text('Bibliotheca')
410
+ expect(page).to have_text('Sign Out')
411
+ end
412
+ scenario 'show book' do
413
+ visit "/"
414
+ expect(page).to have_text('This path hasn\'t started yet')
415
+ end
416
+ scenario 'show chapter' do
417
+ visit "/chapters/#{chapter1.id}"
418
+ expect(page).to have_text('This path hasn\'t started yet')
419
+ end
420
+ scenario 'show lesson' do
421
+ visit "/lessons/#{lesson11.id}"
422
+ expect(page).to have_text('This path hasn\'t started yet')
423
+ end
424
+ scenario 'show exercise 111' do
425
+ visit "/exercises/#{exercise111.id}"
426
+ expect(page).to have_text('This path hasn\'t started yet')
427
+ end
428
+ scenario 'show exercise 112' do
429
+ visit "/exercises/#{exercise112.id}"
430
+ expect(page).to have_text('This path hasn\'t started yet')
431
+ end
432
+ scenario 'show profile' do
433
+ visit "/user"
434
+ expect(page).to have_text('This path hasn\'t started yet')
435
+ end
436
+ scenario 'show faqs' do
437
+ visit "/faqs"
438
+ expect(page).to have_text('This path hasn\'t started yet')
439
+ end
440
+ scenario 'show discussion' do
441
+ visit "/discussions"
442
+ expect(page).to have_text('This path hasn\'t started yet')
443
+ end
444
+ scenario 'show discussion in existent exercise' do
445
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
446
+ expect(page).to have_text('This path hasn\'t started yet')
447
+ end
448
+ scenario 'show discussion in existent exercise' do
449
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
450
+ expect(page).to have_text('This path hasn\'t started yet')
451
+ end
452
+ scenario 'new discussion' do
453
+ visit "/exercises/#{exercise112.id}/discussions/new"
454
+ expect(page).to have_text('This path hasn\'t started yet')
455
+ end
456
+ end
457
+
458
+ context 'and user is ex student of organization' do
459
+ before { user.update! permissions: { ex_student: slug } }
460
+ scenario 'avatar dorpdown' do
461
+ visit "/"
462
+ find('#profileDropdown').click
463
+ expect(page).not_to have_text('My account')
464
+ expect(page).not_to have_text('FAQs')
465
+ expect(page).not_to have_text('Classroom')
466
+ expect(page).not_to have_text('Solve other\'s doubts')
467
+ expect(page).not_to have_text('My doubts')
468
+ expect(page).not_to have_text('Bibliotheca')
469
+ expect(page).to have_text('Sign Out')
470
+ end
471
+ scenario 'show book' do
472
+ visit "/"
473
+ expect(page).to have_text('You are not allowed to see this content')
474
+ end
475
+ scenario 'show chapter' do
476
+ visit "/chapters/#{chapter1.id}"
477
+ expect(page).to have_text('You are not allowed to see this content')
478
+ end
479
+ scenario 'show lesson' do
480
+ visit "/lessons/#{lesson11.id}"
481
+ expect(page).to have_text('You are not allowed to see this content')
482
+ end
483
+ scenario 'show exercise 111' do
484
+ visit "/exercises/#{exercise111.id}"
485
+ expect(page).to have_text('You are not allowed to see this content')
486
+ end
487
+ scenario 'show exercise 112' do
488
+ visit "/exercises/#{exercise112.id}"
489
+ expect(page).to have_text('You are not allowed to see this content')
490
+ end
491
+ scenario 'show profile' do
492
+ visit "/user"
493
+ expect(page).to have_text('You are not allowed to see this content')
494
+ end
495
+ scenario 'show faqs' do
496
+ visit "/faqs"
497
+ expect(page).to have_text('You are not allowed to see this content')
498
+ end
499
+ scenario 'show discussion' do
500
+ visit "/discussions"
501
+ expect(page).to have_text('You are not allowed to see this content')
502
+ end
503
+ scenario 'show discussion in existent exercise' do
504
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
505
+ expect(page).to have_text('You are not allowed to see this content')
506
+ end
507
+ scenario 'show discussion in existent exercise' do
508
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
509
+ expect(page).to have_text('You are not allowed to see this content')
510
+ end
511
+ scenario 'new discussion' do
512
+ visit "/exercises/#{exercise112.id}/discussions/new"
513
+ expect(page).to have_text('You are not allowed to see this content')
514
+ end
515
+ end
516
+
517
+ context 'and user is outsider of organization' do
518
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
519
+ scenario 'avatar dorpdown' do
520
+ visit "/"
521
+ find('#profileDropdown').click
522
+ expect(page).not_to have_text('My account')
523
+ expect(page).not_to have_text('FAQs')
524
+ expect(page).not_to have_text('My doubts')
525
+ expect(page).not_to have_text('Classroom')
526
+ expect(page).not_to have_text('Bibliotheca')
527
+ expect(page).not_to have_text('Solve other\'s doubts')
528
+ expect(page).to have_text('Sign Out')
529
+ end
530
+ scenario 'show book' do
531
+ visit "/"
532
+ expect(page).to have_text('You are not allowed to see this content')
533
+ end
534
+ scenario 'show chapter' do
535
+ visit "/chapters/#{chapter1.id}"
536
+ expect(page).to have_text('You are not allowed to see this content')
537
+ end
538
+ scenario 'show lesson' do
539
+ visit "/lessons/#{lesson11.id}"
540
+ expect(page).to have_text('You are not allowed to see this content')
541
+ end
542
+ scenario 'show exercise 111' do
543
+ visit "/exercises/#{exercise111.id}"
544
+ expect(page).to have_text('You are not allowed to see this content')
545
+ end
546
+ scenario 'show exercise 112' do
547
+ visit "/exercises/#{exercise112.id}"
548
+ expect(page).to have_text('You are not allowed to see this content')
549
+ end
550
+ scenario 'show profile' do
551
+ visit "/user"
552
+ expect(page).to have_text('You are not allowed to see this content')
553
+ end
554
+ scenario 'show faqs' do
555
+ visit "/faqs"
556
+ expect(page).to have_text('You are not allowed to see this content')
557
+ end
558
+ scenario 'show discussion' do
559
+ visit "/discussions"
560
+ expect(page).to have_text('You are not allowed to see this content')
561
+ end
562
+ scenario 'show discussion in existent exercise' do
563
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
564
+ expect(page).to have_text('You are not allowed to see this content')
565
+ end
566
+ scenario 'show discussion in existent exercise' do
567
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
568
+ expect(page).to have_text('You are not allowed to see this content')
569
+ end
570
+ scenario 'new discussion' do
571
+ visit "/exercises/#{exercise112.id}/discussions/new"
572
+ expect(page).to have_text('You are not allowed to see this content')
573
+ end
574
+ end
575
+ end
576
+
577
+ context 'when organization is disabled' do
578
+ before { organization.update! disabled_from: 1.day.ago }
579
+
580
+ context 'and user is teacher of organization' do
581
+ before { user.update! permissions: { teacher: slug } }
582
+ scenario 'avatar dorpdown' do
583
+ visit "/"
584
+ find('#profileDropdown').click
585
+ expect(page).to have_text('My account')
586
+ expect(page).to have_text('FAQs')
587
+ expect(page).to have_text('Classroom')
588
+ expect(page).to have_text('Solve other\'s doubts')
589
+ expect(page).to have_text('My doubts')
590
+ expect(page).not_to have_text('Bibliotheca')
591
+ expect(page).to have_text('Sign Out')
592
+ end
593
+ scenario 'show book' do
594
+ visit "/"
595
+ expect(page).to have_text('Chapter 1')
596
+ expect(page).to have_text('Chapter 2')
597
+ expect(page).to have_text('Practicing!')
598
+ end
599
+ scenario 'show chapter' do
600
+ visit "/chapters/#{chapter1.id}"
601
+ expect(page).to have_text('Lesson 11')
602
+ expect(page).to have_text('Lesson 12')
603
+ expect(page).to have_text('Exercise 111')
604
+ expect(page).to have_text('Exercise 112')
605
+ expect(page).to have_text('Exercise 121')
606
+ expect(page).to have_text('Exercise 122')
607
+ end
608
+ scenario 'show lesson' do
609
+ visit "/lessons/#{lesson11.id}"
610
+ expect(page).to have_text('Lesson 11')
611
+ expect(page).to have_text('Exercise 111')
612
+ expect(page).to have_text('Exercise 112')
613
+ expect(page).to have_text('Continue this lesson!')
614
+ end
615
+ scenario 'show exercise 111' do
616
+ visit "/exercises/#{exercise111.id}"
617
+ expect(page).to have_text('Exercise 111')
618
+ expect(page).to have_selector(:link_or_button, 'Submit')
619
+ expect(page).to have_text('Solve your doubts')
620
+ end
621
+ scenario 'show exercise 112' do
622
+ visit "/exercises/#{exercise112.id}"
623
+ expect(page).to have_text('Exercise 112')
624
+ expect(page).to have_selector(:link_or_button, 'Submit')
625
+ expect(page).not_to have_text('Solve your doubts')
626
+ end
627
+ scenario 'show profile' do
628
+ visit "/user"
629
+ expect(page).to have_text('My profile')
630
+ end
631
+ scenario 'show faqs' do
632
+ visit "/faqs"
633
+ expect(page).to have_text('FAQs')
634
+ end
635
+ scenario 'show discussion' do
636
+ visit "/discussions"
637
+ expect(page).not_to have_text('You are not allowed to see this content')
638
+ end
639
+ scenario 'show discussion in existent exercise' do
640
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
641
+ expect(page).to have_text('Exercise 111')
642
+ expect(page).to have_selector(:link_or_button, 'Comment')
643
+ end
644
+ scenario 'show discussion in existent exercise' do
645
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
646
+ expect(page).not_to have_text('You are not allowed to see this content')
647
+ end
648
+ scenario 'new discussion' do
649
+ visit "/exercises/#{exercise112.id}/discussions/new"
650
+ expect(page).not_to have_text('You are not allowed to see this content')
651
+ end
652
+ end
653
+
654
+ context 'and user is student of organization' do
655
+ before { user.update! permissions: { student: slug } }
656
+ scenario 'avatar dorpdown' do
657
+ visit "/"
658
+ find('#profileDropdown').click
659
+ expect(page).to have_text('My account')
660
+ expect(page).to have_text('FAQs')
661
+ expect(page).to have_text('My doubts')
662
+ expect(page).not_to have_text('Classroom')
663
+ expect(page).not_to have_text('Bibliotheca')
664
+ expect(page).not_to have_text('Solve other\'s doubts')
665
+ expect(page).to have_text('Sign Out')
666
+ end
667
+ scenario 'show book' do
668
+ visit "/"
669
+ expect(page).to have_text('Chapter 1')
670
+ expect(page).to have_text('Chapter 2')
671
+ expect(page).not_to have_text('Practicing!')
672
+ end
673
+ scenario 'show chapter' do
674
+ visit "/chapters/#{chapter1.id}"
675
+ expect(page).to have_text('Lesson 11')
676
+ expect(page).to have_text('Lesson 12')
677
+ expect(page).to have_text('Exercise 111')
678
+ expect(page).to have_text('Exercise 112')
679
+ expect(page).to have_text('Exercise 121')
680
+ expect(page).to have_text('Exercise 122')
681
+ end
682
+ scenario 'show lesson' do
683
+ visit "/lessons/#{lesson11.id}"
684
+ expect(page).to have_text('Lesson 11')
685
+ expect(page).to have_text('Exercise 111')
686
+ expect(page).to have_text('Exercise 112')
687
+ expect(page).not_to have_text('Continue this lesson!')
688
+ end
689
+ scenario 'show exercise 111' do
690
+ visit "/exercises/#{exercise111.id}"
691
+ expect(page).to have_text('Exercise 111')
692
+ expect(page).not_to have_selector(:link_or_button, 'Comment')
693
+ expect(page).not_to have_text('Solve your doubts')
694
+ end
695
+ scenario 'show exercise 112' do
696
+ visit "/exercises/#{exercise112.id}"
697
+ expect(page).to have_text('Exercise 112')
698
+ expect(page).not_to have_selector(:link_or_button, 'Comment')
699
+ expect(page).not_to have_text('Solve your doubts')
700
+ end
701
+ scenario 'show profile' do
702
+ visit "/user"
703
+ expect(page).to have_text('My profile')
704
+ end
705
+ scenario 'show faqs' do
706
+ visit "/faqs"
707
+ expect(page).to have_text('FAQs')
708
+ end
709
+ scenario 'show discussion' do
710
+ visit "/discussions"
711
+ expect(page).to have_text('You are not allowed to see this content')
712
+ end
713
+ scenario 'show discussion in existent exercise' do
714
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
715
+ expect(page).to have_text('Exercise 111')
716
+ expect(page).not_to have_selector(:link_or_button, 'Comment')
717
+ end
718
+ scenario 'show discussion in existent exercise' do
719
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
720
+ expect(page).to have_text('You are not allowed to see this content')
721
+ end
722
+ scenario 'new discussion' do
723
+ visit "/exercises/#{exercise112.id}/discussions/new"
724
+ expect(page).to have_text('You are not allowed to see this content')
725
+ end
726
+ end
727
+
728
+ context 'and user is ex student of organization' do
729
+ before { user.update! permissions: { ex_student: slug } }
730
+ scenario 'avatar dorpdown' do
731
+ visit "/"
732
+ find('#profileDropdown').click
733
+ expect(page).to have_text('My account')
734
+ expect(page).to have_text('FAQs')
735
+ expect(page).not_to have_text('My doubts')
736
+ expect(page).not_to have_text('Classroom')
737
+ expect(page).not_to have_text('Bibliotheca')
738
+ expect(page).not_to have_text('Solve other\'s doubts')
739
+ expect(page).to have_text('Sign Out')
740
+ end
741
+ scenario 'show book' do
742
+ visit "/"
743
+ expect(page).not_to have_text('Chapter 1')
744
+ expect(page).not_to have_text('Chapter 2')
745
+ expect(page).not_to have_text('Practicing!')
746
+ end
747
+ scenario 'show chapter' do
748
+ visit "/chapters/#{chapter1.id}"
749
+ expect(page).to have_text('You are not allowed to see this content')
750
+ end
751
+ scenario 'show lesson' do
752
+ visit "/lessons/#{lesson11.id}"
753
+ expect(page).to have_text('You are not allowed to see this content')
754
+ end
755
+ scenario 'show exercise 111' do
756
+ visit "/exercises/#{exercise111.id}"
757
+ expect(page).to have_text('You are not allowed to see this content')
758
+ end
759
+ scenario 'show exercise 112' do
760
+ visit "/exercises/#{exercise112.id}"
761
+ expect(page).to have_text('You are not allowed to see this content')
762
+ end
763
+ scenario 'show profile' do
764
+ visit "/user"
765
+ expect(page).to have_text('My profile')
766
+ end
767
+ scenario 'show faqs' do
768
+ visit "/faqs"
769
+ expect(page).to have_text('FAQs')
770
+ end
771
+ scenario 'show discussion in existent exercise' do
772
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
773
+ expect(page).to have_text('Page was not found')
774
+ end
775
+ scenario 'show discussion in existent exercise' do
776
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
777
+ expect(page).to have_text('Page was not found')
778
+ end
779
+ scenario 'new discussion' do
780
+ visit "/exercises/#{exercise112.id}/discussions/new"
781
+ expect(page).to have_text('Page was not found')
782
+ end
783
+ end
784
+
785
+ context 'and user is outsider of organization' do
786
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
787
+ scenario 'avatar dorpdown' do
788
+ visit "/"
789
+ find('#profileDropdown').click
790
+ expect(page).not_to have_text('My account')
791
+ expect(page).not_to have_text('Classroom')
792
+ expect(page).not_to have_text('Bibliotheca')
793
+ expect(page).not_to have_text('FAQs')
794
+ expect(page).not_to have_text('My doubts')
795
+ expect(page).not_to have_text('Solve other\'s doubts')
796
+ expect(page).to have_text('Sign Out')
797
+ expect(page).to have_text('You are not allowed to see this content')
798
+ end
799
+ scenario 'show book' do
800
+ visit "/"
801
+ expect(page).to have_text('You are not allowed to see this content')
802
+ end
803
+ scenario 'show chapter' do
804
+ visit "/chapters/#{chapter1.id}"
805
+ expect(page).to have_text('You are not allowed to see this content')
806
+ end
807
+ scenario 'show lesson' do
808
+ visit "/lessons/#{lesson11.id}"
809
+ expect(page).to have_text('You are not allowed to see this content')
810
+ end
811
+ scenario 'show exercise 111' do
812
+ visit "/exercises/#{exercise111.id}"
813
+ expect(page).to have_text('You are not allowed to see this content')
814
+ end
815
+ scenario 'show exercise 112' do
816
+ visit "/exercises/#{exercise112.id}"
817
+ expect(page).to have_text('You are not allowed to see this content')
818
+ end
819
+ scenario 'show profile' do
820
+ visit "/user"
821
+ expect(page).to have_text('You are not allowed to see this content')
822
+ end
823
+ scenario 'show faqs' do
824
+ visit "/faqs"
825
+ expect(page).to have_text('You are not allowed to see this content')
826
+ end
827
+ scenario 'show discussion in existent exercise' do
828
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
829
+ expect(page).to have_text('You are not allowed to see this content')
830
+ end
831
+ scenario 'show discussion in existent exercise' do
832
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
833
+ expect(page).to have_text('You are not allowed to see this content')
834
+ end
835
+ scenario 'new discussion' do
836
+ visit "/exercises/#{exercise112.id}/discussions/new"
837
+ expect(page).to have_text('You are not allowed to see this content')
838
+ end
839
+ end
840
+ end
841
+ end
842
+
843
+ context 'in public organization' do
844
+ let(:organization) { create :public_organization, book: book }
845
+ context 'when organization is enabled' do
846
+ context 'and user is outsider of organization' do
847
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
848
+ scenario 'avatar dorpdown' do
849
+ visit "/"
850
+ find('#profileDropdown').click
851
+ expect(page).to have_text('My account')
852
+ expect(page).not_to have_text('Classroom')
853
+ expect(page).not_to have_text('Bibliotheca')
854
+ expect(page).not_to have_text('FAQs')
855
+ expect(page).not_to have_text('My doubts')
856
+ expect(page).not_to have_text('Solve other\'s doubts')
857
+ expect(page).to have_text('Sign Out')
858
+ end
859
+ scenario 'show book' do
860
+ visit "/"
861
+ expect(page).to have_text('Chapter 1')
862
+ expect(page).to have_text('Chapter 2')
863
+ expect(page).to have_text('Practicing!')
864
+ end
865
+ scenario 'show chapter' do
866
+ visit "/chapters/#{chapter1.id}"
867
+ expect(page).to have_text('Lesson 11')
868
+ expect(page).to have_text('Lesson 12')
869
+ expect(page).to have_text('Exercise 111')
870
+ expect(page).to have_text('Exercise 112')
871
+ expect(page).to have_text('Exercise 121')
872
+ expect(page).to have_text('Exercise 122')
873
+ end
874
+ scenario 'show lesson' do
875
+ visit "/lessons/#{lesson11.id}"
876
+ expect(page).to have_text('Lesson 11')
877
+ expect(page).to have_text('Exercise 111')
878
+ expect(page).to have_text('Exercise 112')
879
+ expect(page).to have_text('Continue this lesson!')
880
+ end
881
+ scenario 'show exercise 111' do
882
+ visit "/exercises/#{exercise111.id}"
883
+ expect(page).to have_text('Exercise 111')
884
+ expect(page).to have_selector(:link_or_button, 'Submit')
885
+ expect(page).not_to have_text('Solve your doubts')
886
+ end
887
+ scenario 'show exercise 112' do
888
+ visit "/exercises/#{exercise112.id}"
889
+ expect(page).to have_text('Exercise 112')
890
+ expect(page).to have_selector(:link_or_button, 'Submit')
891
+ expect(page).not_to have_text('Solve your doubts')
892
+ end
893
+ scenario 'show profile' do
894
+ visit "/user"
895
+ expect(page).to have_text('My profile')
896
+ end
897
+ scenario 'show faqs' do
898
+ visit "/faqs"
899
+ expect(page).to have_text('Page was not found')
900
+ end
901
+ scenario 'show discussion' do
902
+ visit "/discussions"
903
+ expect(page).to have_text('Page was not found')
904
+ end
905
+ scenario 'show discussion in existent exercise' do
906
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
907
+ expect(page).to have_text('Page was not found')
908
+ end
909
+ scenario 'show discussion in existent exercise' do
910
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
911
+ expect(page).to have_text('Page was not found')
912
+ end
913
+ scenario 'new discussion' do
914
+ visit "/exercises/#{exercise112.id}/discussions/new"
915
+ expect(page).to have_text('Page was not found')
916
+ end
917
+ end
918
+ end
919
+ end
920
+ end