mumuki-laboratory 9.12.1 → 9.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. data/app/assets/javascripts/mumuki_laboratory/application/codemirror-builder.js +9 -0
  4. data/app/assets/javascripts/mumuki_laboratory/application/discussions.js +5 -4
  5. data/app/assets/javascripts/mumuki_laboratory/application/results-renderer.js +6 -5
  6. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_breadcrumb.scss +11 -0
  7. data/app/controllers/application_controller.rb +15 -4
  8. data/app/controllers/book_controller.rb +6 -0
  9. data/app/controllers/chapters_controller.rb +9 -0
  10. data/app/controllers/discussions_controller.rb +20 -9
  11. data/app/controllers/exam_authorization_requests_controller.rb +1 -1
  12. data/app/controllers/exercise_solutions_controller.rb +1 -1
  13. data/app/controllers/exercises_controller.rb +5 -0
  14. data/app/controllers/faqs_controller.rb +4 -0
  15. data/app/controllers/lessons_controller.rb +9 -0
  16. data/app/controllers/users_controller.rb +8 -1
  17. data/app/helpers/concerns/with_student_path_navigation.rb +1 -1
  18. data/app/helpers/content_view_helper.rb +8 -0
  19. data/app/helpers/discussions_helper.rb +1 -1
  20. data/app/helpers/editor_helper.rb +5 -0
  21. data/app/helpers/exam_registration_helper.rb +1 -1
  22. data/app/helpers/links_helper.rb +5 -1
  23. data/app/helpers/menu_bar_helper.rb +2 -3
  24. data/app/helpers/overlapped_buttons_helper.rb +2 -1
  25. data/app/views/book/show.html.erb +16 -7
  26. data/app/views/chapters/show.html.erb +1 -0
  27. data/app/views/discussions/_new_message.html.erb +2 -2
  28. data/app/views/discussions/show.html.erb +5 -5
  29. data/app/views/exam_authorization_requests/_pending.html.erb +12 -5
  30. data/app/views/exam_registrations/show.html.erb +11 -9
  31. data/app/views/exercise_solutions/_results.html.erb +1 -1
  32. data/app/views/guides/_guide.html.erb +2 -2
  33. data/app/views/layouts/_progress_bar.html.erb +1 -0
  34. data/app/views/layouts/_progress_listing.html.erb +1 -0
  35. data/app/views/layouts/application.html.erb +11 -0
  36. data/app/views/layouts/exercise_inputs/forms/_kids_form.html.erb +1 -1
  37. data/app/views/layouts/exercise_inputs/forms/_problem_form.html.erb +6 -2
  38. data/app/views/layouts/exercise_inputs/read_only_editors/_hidden.html.erb +0 -0
  39. data/app/views/layouts/exercise_inputs/read_only_editors/_upload.html.erb +0 -0
  40. data/lib/mumuki/laboratory/controllers/authorization.rb +5 -1
  41. data/lib/mumuki/laboratory/controllers/validate_access_mode.rb +15 -0
  42. data/lib/mumuki/laboratory/controllers.rb +1 -0
  43. data/lib/mumuki/laboratory/locales/en.yml +1 -0
  44. data/lib/mumuki/laboratory/locales/es-CL.yml +7 -4
  45. data/lib/mumuki/laboratory/locales/es.yml +7 -4
  46. data/lib/mumuki/laboratory/locales/pt.yml +1 -0
  47. data/lib/mumuki/laboratory/version.rb +1 -1
  48. data/spec/features/menu_bar_spec.rb +3 -2
  49. data/spec/features/not_found_private_flow_spec.rb +1 -1
  50. data/spec/features/read_only_flow_spec.rb +933 -0
  51. metadata +127 -128
@@ -28,6 +28,7 @@
28
28
  <h3><%= t(:lessons) %></h3>
29
29
 
30
30
  <% @chapter.lessons.includes(guide: :exercises).each do |lesson| %>
31
+ <% next unless show_content?(lesson.guide) %>
31
32
  <h4><%= lesson.number %>. <%= link_to_path_element lesson, mode: :plain %></h4>
32
33
  <%= render partial: 'layouts/progress_listing', locals: { guide: lesson.guide } %>
33
34
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= form_for [@discussion, Message.new] do |f| %>
2
- <%= render layout: 'discussions/message_container', locals: {user: user} do %>
2
+ <%= render layout: 'discussions/message_container', locals: { user: user } do %>
3
3
  <div class="discussion-message-bubble">
4
4
  <div class="discussion-message-bubble-header">
5
5
  <div class="discussion-message-bubble-title">
@@ -10,7 +10,7 @@
10
10
  <div class="container-fluid">
11
11
  <div class="row">
12
12
  <div class="discussion-new-message-content">
13
- <%= f.editor :content, '', { id: 'discussion-new-message', class: 'form-control', placeholder: t(:message) } %>
13
+ <%= spell_checked_editor 'message[content]', { id: 'discussion-new-message', placeholder: t(:message) } %>
14
14
  </div>
15
15
  <div class="discussion-message-content d-none" id="discussion-new-message-preview"></div>
16
16
  </div>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <div>
6
6
  <div class="discussion-context">
7
- <%= render partial: 'exercises/read_only', locals: {exercise: @debatable} %>
7
+ <%= render partial: 'exercises/read_only', locals: { exercise: @debatable } %>
8
8
  </div>
9
9
  </div>
10
10
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  <div class="d-flex flex-wrap">
15
15
  <h3 class="flex-grow-1 me-3"><%= t :messages %></h3>
16
- <% if current_user && @discussion.persisted? %>
16
+ <% if current_user && @discussion.persisted? && current_access_mode.show_discussion_element? %>
17
17
  <span class="d-flex">
18
18
  <% if @discussion.can_toggle_responsible?(current_user) %>
19
19
  <div class="discussion-responsible me-1">
@@ -40,10 +40,10 @@
40
40
  <% if @discussion.has_messages? %>
41
41
  <div class="discussion-messages">
42
42
  <% if @discussion.description.present? %>
43
- <%= render partial: 'discussions/description_message', locals: {discussion: @discussion} %>
43
+ <%= render partial: 'discussions/description_message', locals: { discussion: @discussion } %>
44
44
  <% end %>
45
45
  <% @discussion.visible_messages.each do |message| %>
46
- <%= render partial: 'discussions/message', locals: {user: message.sender_user, message: message} %>
46
+ <%= render partial: 'discussions/message', locals: { user: message.sender_user, message: message } %>
47
47
  <% end %>
48
48
  <% if @discussion.commentable_by?(current_user) %>
49
49
  <hr class="message-divider">
@@ -51,7 +51,7 @@
51
51
  </div>
52
52
  <% end %>
53
53
 
54
- <%= render partial: 'discussions/new_message', locals: {user: current_user} if @discussion.commentable_by?(current_user) %>
54
+ <%= render partial: 'discussions/new_message', locals: { user: current_user } if @discussion.commentable_by?(current_user) && current_access_mode.show_discussion_element? %>
55
55
 
56
56
  <% end %>
57
57
 
@@ -1,5 +1,12 @@
1
- <%= t :exam_authorization_pending_explanation_html,
2
- date: l(authorization_request.exam.start_time, format: :long),
3
- end_time: l(authorization_request.exam_registration.end_time, format: :long),
4
- location: Organization.current.time_zone,
5
- edit_path: url_for(authorization_request.exam_registration) %>
1
+ <% if authorization_request.exam_registration.ended? %>
2
+ <%= t :exam_authorization_pending_confirmation_soon_html %>
3
+ <% elsif authorization_request.exam_registration.multiple_options? %>
4
+ <%= t :exam_authorization_pending_change_date_html,
5
+ end_time: l(authorization_request.exam_registration.end_time, format: :long),
6
+ location: Organization.current.time_zone,
7
+ edit_path: url_for(authorization_request.exam_registration) %>
8
+ <% else %>
9
+ <%= t :exam_authorization_pending_done_html,
10
+ end_time: l(authorization_request.exam_registration.end_time, format: :long),
11
+ location: Organization.current.time_zone %>
12
+ <% end %>
@@ -20,17 +20,19 @@
20
20
  <%= t exam_registration_view[:t], date: l(@registration.end_time, format: :long), location: Organization.current.time_zone %>
21
21
  </p>
22
22
  </div>
23
- <% unless @registration.end_time.past? %>
23
+ <% unless @registration.ended? %>
24
24
  <%= form_for @authorization_request, html: {class: 'mu-form'} do |f| %>
25
25
  <%= f.hidden_field :exam_registration_id, value: @registration.id %>
26
- <%= f.label :exam_id, t(:exam_registration_choose_exam) %>
27
- <% @registration.exams.each do |exam| %>
28
- <div class="form-check">
29
- <%= f.radio_button(:exam_id, exam.id, id: exam.id, required: true, class: 'form-check-input mu-read-only-input',
30
- checked: @authorization_request.exam_id == exam.id) %>
31
- <%= label_tag exam.id, "#{l(exam.start_time, format: :long)} #{current_time_zone_html}".html_safe, class: 'form-check-label' %>
32
- </div>
33
- <% end %>
26
+ <div class="mb-4">
27
+ <%= f.label :exam_id, t(:exam_registration_choose_exam) %>
28
+ <% @registration.exams.each do |exam| %>
29
+ <div class="form-check">
30
+ <%= f.radio_button(:exam_id, exam.id, id: exam.id, required: true, class: 'form-check-input mu-read-only-input',
31
+ checked: @authorization_request.exam_id == exam.id) %>
32
+ <%= label_tag exam.id, "#{l(exam.start_time, format: :long)} #{current_time_zone_html}".html_safe, class: 'form-check-label' %>
33
+ </div>
34
+ <% end %>
35
+ </div>
34
36
  <button class="btn btn-complementary"> <%= t :save %> </button>
35
37
  <% end %>
36
38
  <% end %>
@@ -13,7 +13,7 @@
13
13
  <% unless assignment.manual_evaluation_comment? %>
14
14
  <%= render layout: 'exercise_solutions/assistant_rules_box', locals: {assignment: assignment } do %>
15
15
  <%= render partial: 'exercise_solutions/contextualization_results_body', locals: {contextualization: assignment} %>
16
- <% if should_render_need_help_dropdown?(assignment) %>
16
+ <% if should_render_need_help_dropdown?(assignment) && current_access_mode.show_discussion_element? %>
17
17
  <div class="notify-problem-box">
18
18
  <div class="dropdown">
19
19
  <%= link_to fa_icon(:'question-circle', text: t(:need_help)), "", {'data-bs-toggle': 'dropdown'} %>
@@ -28,7 +28,7 @@
28
28
  </div>
29
29
  <% end %>
30
30
 
31
- <% if !@stats.try(:done?) && @next_exercise %>
31
+ <% if !@stats.try(:done?) && @next_exercise && show_content_element? %>
32
32
  <div class="text-box">
33
33
  <div class="actions">
34
34
  <%= link_to t(lesson_practice_key_for(@stats)), exercise_path(@next_exercise), class: 'btn btn-complementary' %>
@@ -36,7 +36,7 @@
36
36
  </div>
37
37
  <% end %>
38
38
 
39
- <% if @stats&.done? %>
39
+ <% if @stats&.done? && show_content_element? %>
40
40
  <div class="text-box">
41
41
  <div class="actions">
42
42
  <%= next_lesson_button @guide %>
@@ -1,6 +1,7 @@
1
1
  <div class="progress-list-flex">
2
2
  <% assignments = guide.assignments_for(current_user) %>
3
3
  <% assignments.each do |assignment| %>
4
+ <% next unless show_content?(assignment.exercise) %>
4
5
  <% exercise = assignment.exercise %>
5
6
  <a
6
7
  <%= turbolinks_enable_for exercise %>
@@ -1,5 +1,6 @@
1
1
  <ul class="progress-listing">
2
2
  <% guide.assignments_for(current_user).each do |assignment| %>
3
+ <% next unless show_content?(assignment.exercise) %>
3
4
  <% cache [assignment.exercise, assignment.status, Organization.current.name, current_user?] do %>
4
5
  <li <%= turbolinks_enable_for(assignment.exercise) %>>
5
6
  <%= assignment_status_icon assignment %>
@@ -1,4 +1,11 @@
1
1
  <%= content_for :navbar do %>
2
+
3
+ <% if current_access_mode.read_only? %>
4
+ <div class="mu-read-only">
5
+ <small><%= t :organization_read_only_legend %></small>
6
+ </div>
7
+ <% end %>
8
+
2
9
  <%= hidden_field_tag("mu-current-exp", UserStats.exp_for(@current_user)) if in_gamified_context? %>
3
10
  <div class="<%= exercise_container_type %> px-0">
4
11
  <nav class="navbar navbar-light navbar-expand-lg mu-navbar">
@@ -20,6 +27,10 @@
20
27
  <%= profile_picture_for current_user %>
21
28
  </div>
22
29
  <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="profileDropdown">
30
+ <% if profile_enabled_here? %>
31
+ <%= menu_link_to_profile %>
32
+ <li class="dropdown-divider"></li>
33
+ <% end %>
23
34
  <%= menu_bar_list_items %>
24
35
  <% if any_menu_bar_links? %>
25
36
  <li class="dropdown-divider"></li>
@@ -4,7 +4,7 @@
4
4
  <%= render_exercise_input_editor f, exercise %>
5
5
 
6
6
  <div class="actions mu-submit-button mu-kids-submit-button">
7
- <%= render_submit_button(@assignment) %>
7
+ <%= render_submit_button(@assignment) if current_access_mode.submit_solutions_here? %>
8
8
  </div>
9
9
  <div class="actions mu-kids-reset-button"></div>
10
10
  <img class="mu-kids-compass-rose" src="/compass_rose.svg">
@@ -34,11 +34,15 @@
34
34
  remote: true,
35
35
  html: {role: 'form', class: "new_solution mu-editor mu-editor-overlap mu-form #{pending_messages_filter(@assignment)}"}) do |f| %>
36
36
  <div class="mb-3">
37
- <%= render_exercise_input_editor f, exercise %>
37
+ <% if current_access_mode.submit_solutions_here? %>
38
+ <%= render_exercise_input_editor f, exercise %>
39
+ <% else %>
40
+ <%= render_exercise_read_only_editor exercise, @assignment.solution %>
41
+ <% end %>
38
42
  </div>
39
43
 
40
44
  <div class="actions mu-submit-button">
41
- <%= render_submit_button(@assignment) %>
45
+ <%= render_submit_button(@assignment) if current_access_mode.submit_solutions_here? %>
42
46
  </div>
43
47
  <% end %>
44
48
  </div>
@@ -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
@@ -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'
@@ -275,6 +275,7 @@ en:
275
275
  only_landscape_support: Please, rotate your tablet or cellphone to continue practicing
276
276
  opened: Open
277
277
  opened_count: '%{count} opened'
278
+ organization_read_only_legend: 'You are in reading mode. You will only be able to access the exercises that you did previously and you will not be able to send new solutions'
278
279
  other: Other
279
280
  out_of_attempts: You've run out of attempts. You should proceed to the next exercise!
280
281
  output: Output
@@ -116,13 +116,15 @@ es-CL:
116
116
  internal_server_error: ¡Ups! Algo no anduvo bien
117
117
  not_found: ¡Ups! La página no existe
118
118
  errored: ¡Ups! Tu solución no se puede ejecutar
119
- exam_authorization_pending_explanation_html: Tienes tiempo hasta el <strong>%{end_time}</strong> (hora de %{location}) para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
119
+ exam_authorization_pending_confirmation_soon_html: El período de inscripción a este examen ha finalizado. Tu solicitud será evaluada pronto y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
120
+ exam_authorization_pending_change_date_html: Tienes tiempo hasta el <strong>%{end_time}</strong> (hora de %{location}) para cambiar el turno haciendo click <strong><a href="%{edit_path}">aquí</a></strong>. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
121
+ exam_authorization_pending_done_html: Ya te inscribiste a este examen. Luego del <strong>%{end_time}</strong> (hora de %{location}) se evaluará tu solicitud y recibirás una confirmación. <br> ¡No olvides de revisar las notificaciones!
120
122
  exam_authorization_request_approved_html: Tu solicitud fue aprobada, no olvides conectarte el <strong>%{date}</strong> (hora de %{location}). ¡Buena suerte!
121
- exam_authorization_request_created: ¡Tu inscripción al exámen se registró exitosamente!
123
+ exam_authorization_request_created: ¡Tu inscripción al examen se registró exitosamente!
122
124
  exam_authorization_request_rejected: Tu solicitud fue rechazada porque no cumpliste con los requisitos para rendir el examen.
123
- exam_authorization_request_saved: ¡Tu inscripción al exámen se modificó exitosamente!
125
+ exam_authorization_request_saved: ¡Tu inscripción al examen se modificó exitosamente!
124
126
  exam_authorization_request_updated: Hay novedades sobre tu inscripción a %{description}
125
- exam_registration_choose_exam: Seleccioná día y horario en el que te gustaría rendir el exámen
127
+ exam_registration_choose_exam: Seleccioná día y horario en el que te gustaría rendir el examen
126
128
  exam_registration_explanation_html: Tienes tiempo hasta el <strong>%{date}</strong> (hora de %{location}) para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
127
129
  exam_registration_finished_html: La inscripción a este examen finalizó el <strong>%{date}</strong> (hora de %{location})
128
130
  exam_registration_open: ¡Ya puedes inscribirte a %{description}!
@@ -284,6 +286,7 @@ es-CL:
284
286
  one: '1 abierta'
285
287
  other: '%{count} abiertas'
286
288
  organizations: Organizaciones
289
+ organization_read_only_legend: 'Estás en modo lectura. Solo podrás acceder a los ejercicios que realizaste previamente y no podrás enviar nuevas soluciones'
287
290
  other: Otro
288
291
  out_of_attempts: Te quedaste sin intentos. ¡Sigue al próximo ejercicio!
289
292
  output: Salida
@@ -123,13 +123,15 @@ es:
123
123
  internal_server_error: ¡Ups! Algo no anduvo bien
124
124
  not_found: ¡Ups! La página no existe
125
125
  errored: ¡Ups! Tu solución no se puede ejecutar
126
- exam_authorization_pending_explanation_html: Tenés tiempo hasta el <strong>%{end_time}</strong> (hora de %{location}) para cambiar el turno haciendo click <strong><a href="%{edit_path}">acá</a></strong>. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
126
+ exam_authorization_pending_confirmation_soon_html: El período de inscripción a este examen ha finalizado. Tu solicitud será evaluada pronto y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
127
+ exam_authorization_pending_change_date_html: Tenés tiempo hasta el <strong>%{end_time}</strong> (hora de %{location}) para cambiar el turno haciendo click <strong><a href="%{edit_path}">acá</a></strong>. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
128
+ exam_authorization_pending_done_html: Ya te inscribiste a este examen. Luego del <strong>%{end_time}</strong> (hora de %{location}) se evaluará tu solicitud y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
127
129
  exam_authorization_request_approved_html: Tu solicitud fue aprobada, no olvides conectarte el <strong>%{date}</strong> (hora de %{location}). ¡Buena suerte!
128
- exam_authorization_request_created: ¡Tu inscripción al exámen se registró exitosamente!
130
+ exam_authorization_request_created: ¡Tu inscripción al examen se registró exitosamente!
129
131
  exam_authorization_request_rejected: Tu solicitud fue rechazada porque no cumpliste con los requisitos para rendir el examen.
130
- exam_authorization_request_saved: ¡Tu inscripción al exámen se modificó exitosamente!
132
+ exam_authorization_request_saved: ¡Tu inscripción al examen se modificó exitosamente!
131
133
  exam_authorization_request_updated: Hay novedades sobre tu inscripción a %{description}
132
- exam_registration_choose_exam: Seleccioná día y horario en el que te gustaría rendir el exámen
134
+ exam_registration_choose_exam: Seleccioná día y horario en el que te gustaría rendir el examen
133
135
  exam_registration_explanation_html: Tenés tiempo hasta el <strong>%{date}</strong> (hora de %{location}) para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
134
136
  exam_registration_finished_html: La inscripción a este examen finalizó el <strong>%{date}</strong> (hora de %{location})
135
137
  exam_registration_open: ¡Ya podés inscribirte a %{description}!
@@ -293,6 +295,7 @@ es:
293
295
  one: '1 abierta'
294
296
  other: '%{count} abiertas'
295
297
  organizations: Organizaciones
298
+ organization_read_only_legend: 'Estás en modo lectura. Solo podrás acceder a los ejercicios que realizaste previamente y no podrás enviar nuevas soluciones'
296
299
  other: Otro
297
300
  out_of_attempts: Te quedaste sin intentos. ¡Seguí al proximo ejercicio!
298
301
  output: Salida
@@ -284,6 +284,7 @@ pt:
284
284
  opened: Aberto
285
285
  opened_count: '%{count} aberto'
286
286
  organizations: Organizações
287
+ organization_read_only_legend: 'Você está no modo de leitura. Você só poderá acessar os exercícios que fez anteriormente e não poderá enviar novas soluções'
287
288
  other: Outro
288
289
  out_of_attempts: Você ficou sem tentativas. Você deve prosseguir para o próximo exercício!
289
290
  output: Sair
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Laboratory
3
- VERSION = '9.12.1'
3
+ VERSION = '9.14.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,933 @@
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
+ scenario 'reattach book' do
261
+ expect(book.has_progress_for?(user, organization)).to eq true
262
+ visit "/"
263
+ expect(page).to have_text('Chapters')
264
+ organization.update! book: create(:book_with_full_tree)
265
+ organization.reload
266
+ visit "/"
267
+ expect(page).not_to have_text('Chapters')
268
+ organization.update! book: book
269
+ organization.reload
270
+ visit "/"
271
+ expect(page).to have_text('Chapters')
272
+ end
273
+ end
274
+
275
+ context 'and user is outsider of organization' do
276
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
277
+ scenario 'avatar dorpdown' do
278
+ visit "/"
279
+ find('#profileDropdown').click
280
+ expect(page).not_to have_text('My account')
281
+ expect(page).not_to have_text('FAQs')
282
+ expect(page).not_to have_text('My doubts')
283
+ expect(page).not_to have_text('Classroom')
284
+ expect(page).not_to have_text('Bibliotheca')
285
+ expect(page).not_to have_text('Solve other\'s doubts')
286
+ expect(page).to have_text('Sign Out')
287
+ end
288
+ scenario 'show book' do
289
+ visit "/"
290
+ expect(page).to have_text('You are not allowed to see this content')
291
+ end
292
+ scenario 'show chapter' do
293
+ visit "/chapters/#{chapter1.id}"
294
+ expect(page).to have_text('You are not allowed to see this content')
295
+ end
296
+ scenario 'show lesson' do
297
+ visit "/lessons/#{lesson11.id}"
298
+ expect(page).to have_text('You are not allowed to see this content')
299
+ end
300
+ scenario 'show exercise 111' do
301
+ visit "/exercises/#{exercise111.id}"
302
+ expect(page).to have_text('You are not allowed to see this content')
303
+ end
304
+ scenario 'show exercise 112' do
305
+ visit "/exercises/#{exercise112.id}"
306
+ expect(page).to have_text('You are not allowed to see this content')
307
+ end
308
+ scenario 'show profile' do
309
+ visit "/user"
310
+ expect(page).to have_text('You are not allowed to see this content')
311
+ end
312
+ scenario 'show faqs' do
313
+ visit "/faqs"
314
+ expect(page).to have_text('You are not allowed to see this content')
315
+ end
316
+ scenario 'show discussion' do
317
+ visit "/discussions"
318
+ expect(page).to have_text('You are not allowed to see this content')
319
+ end
320
+ scenario 'show discussion in existent exercise' do
321
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
322
+ expect(page).to have_text('You are not allowed to see this content')
323
+ end
324
+ scenario 'show discussion in existent exercise' do
325
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
326
+ expect(page).to have_text('You are not allowed to see this content')
327
+ end
328
+ scenario 'new discussion' do
329
+ visit "/exercises/#{exercise112.id}/discussions/new"
330
+ expect(page).to have_text('You are not allowed to see this content')
331
+ end
332
+ end
333
+ end
334
+
335
+ context 'when organization is in preparation' do
336
+ before { organization.update! in_preparation_until: 1.day.since }
337
+
338
+ context 'and user is teacher of organization' do
339
+ before { user.update! permissions: { teacher: slug } }
340
+ scenario 'avatar dorpdown' do
341
+ visit "/"
342
+ find('#profileDropdown').click
343
+ expect(page).to have_text('My account')
344
+ expect(page).to have_text('FAQs')
345
+ expect(page).to have_text('Classroom')
346
+ expect(page).to have_text('Solve other\'s doubts')
347
+ expect(page).to have_text('My doubts')
348
+ expect(page).not_to have_text('Bibliotheca')
349
+ expect(page).to have_text('Sign Out')
350
+ end
351
+ scenario 'show book' do
352
+ visit "/"
353
+ expect(page).to have_text('Chapter 1')
354
+ expect(page).to have_text('Chapter 2')
355
+ expect(page).to have_text('Practicing!')
356
+ end
357
+ scenario 'show chapter' do
358
+ visit "/chapters/#{chapter1.id}"
359
+ expect(page).to have_text('Lesson 11')
360
+ expect(page).to have_text('Lesson 12')
361
+ expect(page).to have_text('Exercise 111')
362
+ expect(page).to have_text('Exercise 112')
363
+ expect(page).to have_text('Exercise 121')
364
+ expect(page).to have_text('Exercise 122')
365
+ end
366
+ scenario 'show lesson' do
367
+ visit "/lessons/#{lesson11.id}"
368
+ expect(page).to have_text('Lesson 11')
369
+ expect(page).to have_text('Exercise 111')
370
+ expect(page).to have_text('Exercise 112')
371
+ expect(page).to have_text('Continue this lesson!')
372
+ end
373
+ scenario 'show exercise 111' do
374
+ visit "/exercises/#{exercise111.id}"
375
+ expect(page).to have_text('Exercise 111')
376
+ expect(page).to have_selector(:link_or_button, 'Submit')
377
+ expect(page).to have_text('Solve your doubts')
378
+ end
379
+ scenario 'show exercise 112' do
380
+ visit "/exercises/#{exercise112.id}"
381
+ expect(page).to have_text('Exercise 112')
382
+ expect(page).to have_selector(:link_or_button, 'Submit')
383
+ expect(page).not_to have_text('Solve your doubts')
384
+ end
385
+ scenario 'show profile' do
386
+ visit "/user"
387
+ expect(page).to have_text('My profile')
388
+ end
389
+ scenario 'show faqs' do
390
+ visit "/faqs"
391
+ expect(page).to have_text('FAQs')
392
+ end
393
+ scenario 'show discussion' do
394
+ visit "/discussions"
395
+ expect(page).not_to have_text('You are not allowed to see this content')
396
+ end
397
+ scenario 'show discussion in existent exercise' do
398
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
399
+ expect(page).to have_text('Exercise 111')
400
+ expect(page).to have_selector(:link_or_button, 'Comment')
401
+ end
402
+ scenario 'show discussion in existent exercise' do
403
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
404
+ expect(page).not_to have_text('You are not allowed to see this content')
405
+ end
406
+ scenario 'new discussion' do
407
+ visit "/exercises/#{exercise112.id}/discussions/new"
408
+ expect(page).not_to have_text('You are not allowed to see this content')
409
+ end
410
+ end
411
+
412
+ context 'and user is student of organization' do
413
+ before { user.update! permissions: { student: slug } }
414
+ scenario 'avatar dorpdown' do
415
+ visit "/"
416
+ find('#profileDropdown').click
417
+ expect(page).not_to have_text('My account')
418
+ expect(page).not_to have_text('FAQs')
419
+ expect(page).not_to have_text('Classroom')
420
+ expect(page).not_to have_text('Solve other\'s doubts')
421
+ expect(page).not_to have_text('My doubts')
422
+ expect(page).not_to have_text('Bibliotheca')
423
+ expect(page).to have_text('Sign Out')
424
+ end
425
+ scenario 'show book' do
426
+ visit "/"
427
+ expect(page).to have_text('This path hasn\'t started yet')
428
+ end
429
+ scenario 'show chapter' do
430
+ visit "/chapters/#{chapter1.id}"
431
+ expect(page).to have_text('This path hasn\'t started yet')
432
+ end
433
+ scenario 'show lesson' do
434
+ visit "/lessons/#{lesson11.id}"
435
+ expect(page).to have_text('This path hasn\'t started yet')
436
+ end
437
+ scenario 'show exercise 111' do
438
+ visit "/exercises/#{exercise111.id}"
439
+ expect(page).to have_text('This path hasn\'t started yet')
440
+ end
441
+ scenario 'show exercise 112' do
442
+ visit "/exercises/#{exercise112.id}"
443
+ expect(page).to have_text('This path hasn\'t started yet')
444
+ end
445
+ scenario 'show profile' do
446
+ visit "/user"
447
+ expect(page).to have_text('This path hasn\'t started yet')
448
+ end
449
+ scenario 'show faqs' do
450
+ visit "/faqs"
451
+ expect(page).to have_text('This path hasn\'t started yet')
452
+ end
453
+ scenario 'show discussion' do
454
+ visit "/discussions"
455
+ expect(page).to have_text('This path hasn\'t started yet')
456
+ end
457
+ scenario 'show discussion in existent exercise' do
458
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
459
+ expect(page).to have_text('This path hasn\'t started yet')
460
+ end
461
+ scenario 'show discussion in existent exercise' do
462
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
463
+ expect(page).to have_text('This path hasn\'t started yet')
464
+ end
465
+ scenario 'new discussion' do
466
+ visit "/exercises/#{exercise112.id}/discussions/new"
467
+ expect(page).to have_text('This path hasn\'t started yet')
468
+ end
469
+ end
470
+
471
+ context 'and user is ex student of organization' do
472
+ before { user.update! permissions: { ex_student: slug } }
473
+ scenario 'avatar dorpdown' do
474
+ visit "/"
475
+ find('#profileDropdown').click
476
+ expect(page).not_to have_text('My account')
477
+ expect(page).not_to have_text('FAQs')
478
+ expect(page).not_to have_text('Classroom')
479
+ expect(page).not_to have_text('Solve other\'s doubts')
480
+ expect(page).not_to have_text('My doubts')
481
+ expect(page).not_to have_text('Bibliotheca')
482
+ expect(page).to have_text('Sign Out')
483
+ end
484
+ scenario 'show book' do
485
+ visit "/"
486
+ expect(page).to have_text('You are not allowed to see this content')
487
+ end
488
+ scenario 'show chapter' do
489
+ visit "/chapters/#{chapter1.id}"
490
+ expect(page).to have_text('You are not allowed to see this content')
491
+ end
492
+ scenario 'show lesson' do
493
+ visit "/lessons/#{lesson11.id}"
494
+ expect(page).to have_text('You are not allowed to see this content')
495
+ end
496
+ scenario 'show exercise 111' do
497
+ visit "/exercises/#{exercise111.id}"
498
+ expect(page).to have_text('You are not allowed to see this content')
499
+ end
500
+ scenario 'show exercise 112' do
501
+ visit "/exercises/#{exercise112.id}"
502
+ expect(page).to have_text('You are not allowed to see this content')
503
+ end
504
+ scenario 'show profile' do
505
+ visit "/user"
506
+ expect(page).to have_text('You are not allowed to see this content')
507
+ end
508
+ scenario 'show faqs' do
509
+ visit "/faqs"
510
+ expect(page).to have_text('You are not allowed to see this content')
511
+ end
512
+ scenario 'show discussion' do
513
+ visit "/discussions"
514
+ expect(page).to have_text('You are not allowed to see this content')
515
+ end
516
+ scenario 'show discussion in existent exercise' do
517
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
518
+ expect(page).to have_text('You are not allowed to see this content')
519
+ end
520
+ scenario 'show discussion in existent exercise' do
521
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
522
+ expect(page).to have_text('You are not allowed to see this content')
523
+ end
524
+ scenario 'new discussion' do
525
+ visit "/exercises/#{exercise112.id}/discussions/new"
526
+ expect(page).to have_text('You are not allowed to see this content')
527
+ end
528
+ end
529
+
530
+ context 'and user is outsider of organization' do
531
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
532
+ scenario 'avatar dorpdown' do
533
+ visit "/"
534
+ find('#profileDropdown').click
535
+ expect(page).not_to have_text('My account')
536
+ expect(page).not_to have_text('FAQs')
537
+ expect(page).not_to have_text('My doubts')
538
+ expect(page).not_to have_text('Classroom')
539
+ expect(page).not_to have_text('Bibliotheca')
540
+ expect(page).not_to have_text('Solve other\'s doubts')
541
+ expect(page).to have_text('Sign Out')
542
+ end
543
+ scenario 'show book' do
544
+ visit "/"
545
+ expect(page).to have_text('You are not allowed to see this content')
546
+ end
547
+ scenario 'show chapter' do
548
+ visit "/chapters/#{chapter1.id}"
549
+ expect(page).to have_text('You are not allowed to see this content')
550
+ end
551
+ scenario 'show lesson' do
552
+ visit "/lessons/#{lesson11.id}"
553
+ expect(page).to have_text('You are not allowed to see this content')
554
+ end
555
+ scenario 'show exercise 111' do
556
+ visit "/exercises/#{exercise111.id}"
557
+ expect(page).to have_text('You are not allowed to see this content')
558
+ end
559
+ scenario 'show exercise 112' do
560
+ visit "/exercises/#{exercise112.id}"
561
+ expect(page).to have_text('You are not allowed to see this content')
562
+ end
563
+ scenario 'show profile' do
564
+ visit "/user"
565
+ expect(page).to have_text('You are not allowed to see this content')
566
+ end
567
+ scenario 'show faqs' do
568
+ visit "/faqs"
569
+ expect(page).to have_text('You are not allowed to see this content')
570
+ end
571
+ scenario 'show discussion' do
572
+ visit "/discussions"
573
+ expect(page).to have_text('You are not allowed to see this content')
574
+ end
575
+ scenario 'show discussion in existent exercise' do
576
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
577
+ expect(page).to have_text('You are not allowed to see this content')
578
+ end
579
+ scenario 'show discussion in existent exercise' do
580
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
581
+ expect(page).to have_text('You are not allowed to see this content')
582
+ end
583
+ scenario 'new discussion' do
584
+ visit "/exercises/#{exercise112.id}/discussions/new"
585
+ expect(page).to have_text('You are not allowed to see this content')
586
+ end
587
+ end
588
+ end
589
+
590
+ context 'when organization is disabled' do
591
+ before { organization.update! disabled_from: 1.day.ago }
592
+
593
+ context 'and user is teacher of organization' do
594
+ before { user.update! permissions: { teacher: slug } }
595
+ scenario 'avatar dorpdown' do
596
+ visit "/"
597
+ find('#profileDropdown').click
598
+ expect(page).to have_text('My account')
599
+ expect(page).to have_text('FAQs')
600
+ expect(page).to have_text('Classroom')
601
+ expect(page).to have_text('Solve other\'s doubts')
602
+ expect(page).to have_text('My doubts')
603
+ expect(page).not_to have_text('Bibliotheca')
604
+ expect(page).to have_text('Sign Out')
605
+ end
606
+ scenario 'show book' do
607
+ visit "/"
608
+ expect(page).to have_text('Chapter 1')
609
+ expect(page).to have_text('Chapter 2')
610
+ expect(page).to have_text('Practicing!')
611
+ end
612
+ scenario 'show chapter' do
613
+ visit "/chapters/#{chapter1.id}"
614
+ expect(page).to have_text('Lesson 11')
615
+ expect(page).to have_text('Lesson 12')
616
+ expect(page).to have_text('Exercise 111')
617
+ expect(page).to have_text('Exercise 112')
618
+ expect(page).to have_text('Exercise 121')
619
+ expect(page).to have_text('Exercise 122')
620
+ end
621
+ scenario 'show lesson' do
622
+ visit "/lessons/#{lesson11.id}"
623
+ expect(page).to have_text('Lesson 11')
624
+ expect(page).to have_text('Exercise 111')
625
+ expect(page).to have_text('Exercise 112')
626
+ expect(page).to have_text('Continue this lesson!')
627
+ end
628
+ scenario 'show exercise 111' do
629
+ visit "/exercises/#{exercise111.id}"
630
+ expect(page).to have_text('Exercise 111')
631
+ expect(page).to have_selector(:link_or_button, 'Submit')
632
+ expect(page).to have_text('Solve your doubts')
633
+ end
634
+ scenario 'show exercise 112' do
635
+ visit "/exercises/#{exercise112.id}"
636
+ expect(page).to have_text('Exercise 112')
637
+ expect(page).to have_selector(:link_or_button, 'Submit')
638
+ expect(page).not_to have_text('Solve your doubts')
639
+ end
640
+ scenario 'show profile' do
641
+ visit "/user"
642
+ expect(page).to have_text('My profile')
643
+ end
644
+ scenario 'show faqs' do
645
+ visit "/faqs"
646
+ expect(page).to have_text('FAQs')
647
+ end
648
+ scenario 'show discussion' do
649
+ visit "/discussions"
650
+ expect(page).not_to have_text('You are not allowed to see this content')
651
+ end
652
+ scenario 'show discussion in existent exercise' do
653
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
654
+ expect(page).to have_text('Exercise 111')
655
+ expect(page).to have_selector(:link_or_button, 'Comment')
656
+ end
657
+ scenario 'show discussion in existent exercise' do
658
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
659
+ expect(page).not_to have_text('You are not allowed to see this content')
660
+ end
661
+ scenario 'new discussion' do
662
+ visit "/exercises/#{exercise112.id}/discussions/new"
663
+ expect(page).not_to have_text('You are not allowed to see this content')
664
+ end
665
+ end
666
+
667
+ context 'and user is student of organization' do
668
+ before { user.update! permissions: { student: slug } }
669
+ scenario 'avatar dorpdown' do
670
+ visit "/"
671
+ find('#profileDropdown').click
672
+ expect(page).to have_text('My account')
673
+ expect(page).to have_text('FAQs')
674
+ expect(page).to have_text('My doubts')
675
+ expect(page).not_to have_text('Classroom')
676
+ expect(page).not_to have_text('Bibliotheca')
677
+ expect(page).not_to have_text('Solve other\'s doubts')
678
+ expect(page).to have_text('Sign Out')
679
+ end
680
+ scenario 'show book' do
681
+ visit "/"
682
+ expect(page).to have_text('Chapter 1')
683
+ expect(page).to have_text('Chapter 2')
684
+ expect(page).not_to have_text('Practicing!')
685
+ end
686
+ scenario 'show chapter' do
687
+ visit "/chapters/#{chapter1.id}"
688
+ expect(page).to have_text('Lesson 11')
689
+ expect(page).to have_text('Lesson 12')
690
+ expect(page).to have_text('Exercise 111')
691
+ expect(page).to have_text('Exercise 112')
692
+ expect(page).to have_text('Exercise 121')
693
+ expect(page).to have_text('Exercise 122')
694
+ end
695
+ scenario 'show lesson' do
696
+ visit "/lessons/#{lesson11.id}"
697
+ expect(page).to have_text('Lesson 11')
698
+ expect(page).to have_text('Exercise 111')
699
+ expect(page).to have_text('Exercise 112')
700
+ expect(page).not_to have_text('Continue this lesson!')
701
+ end
702
+ scenario 'show exercise 111' do
703
+ visit "/exercises/#{exercise111.id}"
704
+ expect(page).to have_text('Exercise 111')
705
+ expect(page).not_to have_selector(:link_or_button, 'Comment')
706
+ expect(page).not_to have_text('Solve your doubts')
707
+ end
708
+ scenario 'show exercise 112' do
709
+ visit "/exercises/#{exercise112.id}"
710
+ expect(page).to have_text('Exercise 112')
711
+ expect(page).not_to have_selector(:link_or_button, 'Comment')
712
+ expect(page).not_to have_text('Solve your doubts')
713
+ end
714
+ scenario 'show profile' do
715
+ visit "/user"
716
+ expect(page).to have_text('My profile')
717
+ end
718
+ scenario 'show faqs' do
719
+ visit "/faqs"
720
+ expect(page).to have_text('FAQs')
721
+ end
722
+ scenario 'show discussion' do
723
+ visit "/discussions"
724
+ expect(page).to have_text('You are not allowed to see this content')
725
+ end
726
+ scenario 'show discussion in existent exercise' do
727
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
728
+ expect(page).to have_text('Exercise 111')
729
+ expect(page).not_to have_selector(:link_or_button, 'Comment')
730
+ end
731
+ scenario 'show discussion in existent exercise' do
732
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
733
+ expect(page).to have_text('You are not allowed to see this content')
734
+ end
735
+ scenario 'new discussion' do
736
+ visit "/exercises/#{exercise112.id}/discussions/new"
737
+ expect(page).to have_text('You are not allowed to see this content')
738
+ end
739
+ end
740
+
741
+ context 'and user is ex student of organization' do
742
+ before { user.update! permissions: { ex_student: slug } }
743
+ scenario 'avatar dorpdown' do
744
+ visit "/"
745
+ find('#profileDropdown').click
746
+ expect(page).to have_text('My account')
747
+ expect(page).to have_text('FAQs')
748
+ expect(page).not_to have_text('My doubts')
749
+ expect(page).not_to have_text('Classroom')
750
+ expect(page).not_to have_text('Bibliotheca')
751
+ expect(page).not_to have_text('Solve other\'s doubts')
752
+ expect(page).to have_text('Sign Out')
753
+ end
754
+ scenario 'show book' do
755
+ visit "/"
756
+ expect(page).not_to have_text('Chapter 1')
757
+ expect(page).not_to have_text('Chapter 2')
758
+ expect(page).not_to have_text('Practicing!')
759
+ end
760
+ scenario 'show chapter' do
761
+ visit "/chapters/#{chapter1.id}"
762
+ expect(page).to have_text('You are not allowed to see this content')
763
+ end
764
+ scenario 'show lesson' do
765
+ visit "/lessons/#{lesson11.id}"
766
+ expect(page).to have_text('You are not allowed to see this content')
767
+ end
768
+ scenario 'show exercise 111' do
769
+ visit "/exercises/#{exercise111.id}"
770
+ expect(page).to have_text('You are not allowed to see this content')
771
+ end
772
+ scenario 'show exercise 112' do
773
+ visit "/exercises/#{exercise112.id}"
774
+ expect(page).to have_text('You are not allowed to see this content')
775
+ end
776
+ scenario 'show profile' do
777
+ visit "/user"
778
+ expect(page).to have_text('My profile')
779
+ end
780
+ scenario 'show faqs' do
781
+ visit "/faqs"
782
+ expect(page).to have_text('FAQs')
783
+ end
784
+ scenario 'show discussion in existent exercise' do
785
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
786
+ expect(page).to have_text('Page was not found')
787
+ end
788
+ scenario 'show discussion in existent exercise' do
789
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
790
+ expect(page).to have_text('Page was not found')
791
+ end
792
+ scenario 'new discussion' do
793
+ visit "/exercises/#{exercise112.id}/discussions/new"
794
+ expect(page).to have_text('Page was not found')
795
+ end
796
+ end
797
+
798
+ context 'and user is outsider of organization' do
799
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
800
+ scenario 'avatar dorpdown' do
801
+ visit "/"
802
+ find('#profileDropdown').click
803
+ expect(page).not_to have_text('My account')
804
+ expect(page).not_to have_text('Classroom')
805
+ expect(page).not_to have_text('Bibliotheca')
806
+ expect(page).not_to have_text('FAQs')
807
+ expect(page).not_to have_text('My doubts')
808
+ expect(page).not_to have_text('Solve other\'s doubts')
809
+ expect(page).to have_text('Sign Out')
810
+ expect(page).to have_text('You are not allowed to see this content')
811
+ end
812
+ scenario 'show book' do
813
+ visit "/"
814
+ expect(page).to have_text('You are not allowed to see this content')
815
+ end
816
+ scenario 'show chapter' do
817
+ visit "/chapters/#{chapter1.id}"
818
+ expect(page).to have_text('You are not allowed to see this content')
819
+ end
820
+ scenario 'show lesson' do
821
+ visit "/lessons/#{lesson11.id}"
822
+ expect(page).to have_text('You are not allowed to see this content')
823
+ end
824
+ scenario 'show exercise 111' do
825
+ visit "/exercises/#{exercise111.id}"
826
+ expect(page).to have_text('You are not allowed to see this content')
827
+ end
828
+ scenario 'show exercise 112' do
829
+ visit "/exercises/#{exercise112.id}"
830
+ expect(page).to have_text('You are not allowed to see this content')
831
+ end
832
+ scenario 'show profile' do
833
+ visit "/user"
834
+ expect(page).to have_text('You are not allowed to see this content')
835
+ end
836
+ scenario 'show faqs' do
837
+ visit "/faqs"
838
+ expect(page).to have_text('You are not allowed to see this content')
839
+ end
840
+ scenario 'show discussion in existent exercise' do
841
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
842
+ expect(page).to have_text('You are not allowed to see this content')
843
+ end
844
+ scenario 'show discussion in existent exercise' do
845
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
846
+ expect(page).to have_text('You are not allowed to see this content')
847
+ end
848
+ scenario 'new discussion' do
849
+ visit "/exercises/#{exercise112.id}/discussions/new"
850
+ expect(page).to have_text('You are not allowed to see this content')
851
+ end
852
+ end
853
+ end
854
+ end
855
+
856
+ context 'in public organization' do
857
+ let(:organization) { create :public_organization, book: book }
858
+ context 'when organization is enabled' do
859
+ context 'and user is outsider of organization' do
860
+ before { user.update! permissions: { ex_student: '', student: '', teacher: '' } }
861
+ scenario 'avatar dorpdown' do
862
+ visit "/"
863
+ find('#profileDropdown').click
864
+ expect(page).to have_text('My account')
865
+ expect(page).not_to have_text('Classroom')
866
+ expect(page).not_to have_text('Bibliotheca')
867
+ expect(page).not_to have_text('FAQs')
868
+ expect(page).not_to have_text('My doubts')
869
+ expect(page).not_to have_text('Solve other\'s doubts')
870
+ expect(page).to have_text('Sign Out')
871
+ end
872
+ scenario 'show book' do
873
+ visit "/"
874
+ expect(page).to have_text('Chapter 1')
875
+ expect(page).to have_text('Chapter 2')
876
+ expect(page).to have_text('Practicing!')
877
+ end
878
+ scenario 'show chapter' do
879
+ visit "/chapters/#{chapter1.id}"
880
+ expect(page).to have_text('Lesson 11')
881
+ expect(page).to have_text('Lesson 12')
882
+ expect(page).to have_text('Exercise 111')
883
+ expect(page).to have_text('Exercise 112')
884
+ expect(page).to have_text('Exercise 121')
885
+ expect(page).to have_text('Exercise 122')
886
+ end
887
+ scenario 'show lesson' do
888
+ visit "/lessons/#{lesson11.id}"
889
+ expect(page).to have_text('Lesson 11')
890
+ expect(page).to have_text('Exercise 111')
891
+ expect(page).to have_text('Exercise 112')
892
+ expect(page).to have_text('Continue this lesson!')
893
+ end
894
+ scenario 'show exercise 111' do
895
+ visit "/exercises/#{exercise111.id}"
896
+ expect(page).to have_text('Exercise 111')
897
+ expect(page).to have_selector(:link_or_button, 'Submit')
898
+ expect(page).not_to have_text('Solve your doubts')
899
+ end
900
+ scenario 'show exercise 112' do
901
+ visit "/exercises/#{exercise112.id}"
902
+ expect(page).to have_text('Exercise 112')
903
+ expect(page).to have_selector(:link_or_button, 'Submit')
904
+ expect(page).not_to have_text('Solve your doubts')
905
+ end
906
+ scenario 'show profile' do
907
+ visit "/user"
908
+ expect(page).to have_text('My profile')
909
+ end
910
+ scenario 'show faqs' do
911
+ visit "/faqs"
912
+ expect(page).to have_text('Page was not found')
913
+ end
914
+ scenario 'show discussion' do
915
+ visit "/discussions"
916
+ expect(page).to have_text('Page was not found')
917
+ end
918
+ scenario 'show discussion in existent exercise' do
919
+ visit "/exercises/#{exercise111.id}/discussions/#{discussion111.id}"
920
+ expect(page).to have_text('Page was not found')
921
+ end
922
+ scenario 'show discussion in existent exercise' do
923
+ visit "/exercises/#{exercise112.id}/discussions/#{discussion112.id}"
924
+ expect(page).to have_text('Page was not found')
925
+ end
926
+ scenario 'new discussion' do
927
+ visit "/exercises/#{exercise112.id}/discussions/new"
928
+ expect(page).to have_text('Page was not found')
929
+ end
930
+ end
931
+ end
932
+ end
933
+ end