mumuki-laboratory 9.11.0 → 9.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/app/assets/javascripts/mumuki_laboratory/application/bridge.js +15 -9
- data/app/assets/javascripts/mumuki_laboratory/application/confirmation.js +10 -8
- data/app/assets/javascripts/mumuki_laboratory/application/editors.js +5 -3
- data/app/assets/javascripts/mumuki_laboratory/application/progress.js +4 -4
- data/app/assets/javascripts/mumuki_laboratory/application/results-renderer.js +12 -1
- data/app/assets/javascripts/mumuki_laboratory/application/submissions-store.js +8 -2
- data/app/controllers/application_controller.rb +8 -4
- data/app/controllers/book_controller.rb +6 -0
- data/app/controllers/chapters_controller.rb +9 -0
- data/app/controllers/discussions_controller.rb +9 -0
- data/app/controllers/exercises_controller.rb +5 -0
- data/app/controllers/faqs_controller.rb +4 -0
- data/app/controllers/lessons_controller.rb +9 -0
- data/app/controllers/users_controller.rb +5 -1
- data/app/helpers/concerns/with_student_path_navigation.rb +1 -1
- data/app/helpers/content_view_helper.rb +8 -0
- data/app/helpers/discussions_helper.rb +1 -1
- data/app/helpers/links_helper.rb +5 -1
- data/app/helpers/menu_bar_helper.rb +2 -3
- data/app/helpers/overlapped_buttons_helper.rb +2 -1
- data/app/helpers/time_zone_helper.rb +5 -0
- data/app/mailers/user_mailer.rb +2 -0
- data/app/views/book/show.html.erb +16 -7
- data/app/views/chapters/show.html.erb +1 -0
- data/app/views/discussions/_new_message.html.erb +1 -1
- data/app/views/discussions/show.html.erb +5 -5
- data/app/views/exercise_solutions/_results.html.erb +1 -1
- data/app/views/guides/_guide.html.erb +2 -2
- data/app/views/layouts/_progress_bar.html.erb +1 -0
- data/app/views/layouts/_progress_listing.html.erb +1 -0
- data/app/views/layouts/application.html.erb +4 -0
- data/app/views/layouts/exercise_inputs/forms/_kids_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/forms/_problem_form.html.erb +6 -2
- data/app/views/layouts/exercise_inputs/read_only_editors/_hidden.html.erb +0 -0
- data/app/views/layouts/exercise_inputs/read_only_editors/_upload.html.erb +0 -0
- data/app/views/notifications/previews/_exam_authorization_request_updated.html.erb +1 -1
- data/app/views/user_mailer/_mail_template.erb +1 -1
- data/app/views/user_mailer/notifications/_exam_registration.html.erb +1 -1
- data/app/views/user_mailer/notifications/exam_authorization_request_updated/_approved.html.erb +1 -1
- data/app/views/users/manage_notifications.html.erb +1 -1
- data/app/views/users/notifications.html.erb +1 -1
- data/lib/mumuki/laboratory.rb +1 -0
- data/lib/mumuki/laboratory/controllers.rb +1 -0
- data/lib/mumuki/laboratory/controllers/authorization.rb +5 -1
- data/lib/mumuki/laboratory/controllers/validate_access_mode.rb +15 -0
- data/lib/mumuki/laboratory/locales/en.yml +1 -0
- data/lib/mumuki/laboratory/locales/es-CL.yml +1 -0
- data/lib/mumuki/laboratory/locales/es.yml +1 -0
- data/lib/mumuki/laboratory/locales/pt.yml +1 -0
- data/lib/mumuki/laboratory/mailers/message_delivery.rb +15 -0
- data/lib/mumuki/laboratory/version.rb +1 -1
- data/spec/features/menu_bar_spec.rb +3 -2
- data/spec/features/not_found_private_flow_spec.rb +1 -1
- data/spec/features/read_only_flow_spec.rb +920 -0
- data/spec/javascripts/editors-spec.js +21 -3
- data/spec/javascripts/submissions-store-spec.js +11 -0
- data/spec/mailers/previews/user_mailer_preview.rb +48 -6
- metadata +15 -14
data/app/mailers/user_mailer.rb
CHANGED
@@ -6,16 +6,25 @@
|
|
6
6
|
<%= render partial: 'book/header' %>
|
7
7
|
|
8
8
|
<% @book.next_lesson_for(current_user).try do |lesson| %>
|
9
|
-
|
10
|
-
<
|
11
|
-
<%=
|
12
|
-
|
13
|
-
|
9
|
+
<% if show_content_element? %>
|
10
|
+
<div class="actions">
|
11
|
+
<a href="<%= lesson_path(lesson) %>" class="btn btn-complementary">
|
12
|
+
<%= t book_practice_key_for(current_user) %>
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
<% else %>
|
16
|
+
<br>
|
17
|
+
<% end %>
|
14
18
|
<% end %>
|
15
19
|
|
16
|
-
|
20
|
+
<% if show_content?(@book) %>
|
21
|
+
<h2><%= t(:chapters) %></h2>
|
22
|
+
<% end %>
|
17
23
|
|
18
24
|
<% @book.chapter_visibilities_in(current_workspace).each do |it, enabled| %>
|
25
|
+
|
26
|
+
<% next unless show_content?(it.topic) %>
|
27
|
+
|
19
28
|
<div class="chapter-container">
|
20
29
|
<div class="chapter <%= enabled ? '' : 'mu-locked' %>">
|
21
30
|
<h3><%= it.number %>. <%= link_to_path_element it, mode: :plain %></h3>
|
@@ -24,7 +33,7 @@
|
|
24
33
|
</div>
|
25
34
|
</div>
|
26
35
|
|
27
|
-
<% unless enabled
|
36
|
+
<% unless enabled %>
|
28
37
|
<div class="text-center mu-lock">
|
29
38
|
<i class="fas fa-lock fa-5x"></i>
|
30
39
|
<p><%= t :locked_content %></p>
|
@@ -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">
|
@@ -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
|
-
|
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
|
|
@@ -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 %>
|
@@ -20,6 +20,10 @@
|
|
20
20
|
<%= profile_picture_for current_user %>
|
21
21
|
</div>
|
22
22
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="profileDropdown">
|
23
|
+
<% if profile_enabled_here? %>
|
24
|
+
<%= menu_link_to_profile %>
|
25
|
+
<li class="dropdown-divider"></li>
|
26
|
+
<% end %>
|
23
27
|
<%= menu_bar_list_items %>
|
24
28
|
<% if any_menu_bar_links? %>
|
25
29
|
<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
|
-
|
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>
|
File without changes
|
File without changes
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<% target = notification.target %>
|
2
|
-
<%= notification_preview_item :book_open, :exam_authorization_request_updated, exam_authorizations_user_path, { description: target.exam_registration.description } %>
|
2
|
+
<%= notification_preview_item :book_open, :exam_authorization_request_updated, exam_authorizations_user_path(notification.organization), { description: target.exam_registration.description } %>
|
@@ -107,7 +107,7 @@
|
|
107
107
|
<tbody>
|
108
108
|
<tr>
|
109
109
|
<td align="center" valign="middle" class="muMailButtonContent" style="font-family: Helvetica; font-size: 18px; padding: 18px;">
|
110
|
-
<a class="muMailButton
|
110
|
+
<a class="muMailButton" title="<%= button %>" href="<%= url %>" target="_blank" style="font-weight: bold;letter-spacing: -0.5px;line-height: 100%;text-align: center;text-decoration: none;color: #FFFFFF;"><%= button %></a>
|
111
111
|
</td>
|
112
112
|
</tr>
|
113
113
|
</tbody>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= render partial: 'user_mailer/mail_template', locals: {
|
2
2
|
title: t("mailer.title.exam_registration"),
|
3
3
|
subtitle: t("mailer.subtitle.exam_registration"),
|
4
|
-
text: t("mailer.text.exam_registration", exam_registration_deadline:
|
4
|
+
text: t("mailer.text.exam_registration", exam_registration_deadline: local_time(@notification.target.end_time, @organization.time_zone)),
|
5
5
|
button: t("mailer.button.exam_registration"),
|
6
6
|
url: exam_registration_url(@organization, @notification.target)
|
7
7
|
} %>
|
data/app/views/user_mailer/notifications/exam_authorization_request_updated/_approved.html.erb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= render partial: 'user_mailer/mail_template', locals: {
|
2
2
|
title: t(:congratulations),
|
3
3
|
subtitle: t('mailer.subtitle.exam_authorization_request_approved'),
|
4
|
-
text: t('mailer.text.exam_authorization_request_approved', exam_start_date:
|
4
|
+
text: t('mailer.text.exam_authorization_request_approved', exam_start_date: local_time(@notification.target.exam.start_time, @organization.time_zone)),
|
5
5
|
button: t('mailer.button.exam_authorization_request_approved'),
|
6
6
|
url: @organization.url
|
7
7
|
} %>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<h1><%= t(:manage_notifications) %></h1>
|
10
10
|
<div class="mu-profile-actions d-none d-md-block">
|
11
11
|
<a class="btn btn-secondary" href="<%= notifications_user_path %>">Cancelar</a>
|
12
|
-
<button type="submit" class="btn btn-complementary"><%= t :
|
12
|
+
<button type="submit" class="btn btn-complementary"><%= t :save %></button>
|
13
13
|
</div>
|
14
14
|
</div>
|
15
15
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
<% @notifications.each do |notification| %>
|
33
33
|
<tr class="<%= background_for_notification notification %>" >
|
34
34
|
<td class="col-md-1">
|
35
|
-
<%= link_to icon_for_read(notification.read?), "notifications/#{notification.id}/toggle_read", tooltip_options(:
|
35
|
+
<%= link_to icon_for_read(notification.read?), "notifications/#{notification.id}/toggle_read", tooltip_options(:toggle_read).merge(method: :post, role: :button) %>
|
36
36
|
</td>
|
37
37
|
<td class="col-md-8 text-break">
|
38
38
|
<%= render partial: "notifications/#{notification.subject}", locals: { notification: notification } %>
|
data/lib/mumuki/laboratory.rb
CHANGED
@@ -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!
|
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
|
@@ -366,6 +366,7 @@ en:
|
|
366
366
|
to_opened: Reopen
|
367
367
|
to_pending_review: Mark as solved
|
368
368
|
to_solved: Mark as solved
|
369
|
+
toggle_read: "Toggle read/unread"
|
369
370
|
unauthorized_explanation: You have no permissions for this content. Maybe you logged in with another account.
|
370
371
|
total: Total
|
371
372
|
undo_upvote: Undo upvote
|
@@ -378,6 +378,7 @@ es-CL:
|
|
378
378
|
to_opened: Reabrir
|
379
379
|
to_pending_review: Resolver
|
380
380
|
to_solved: Resolver
|
381
|
+
toggle_read: "Marcar como leído/no leído"
|
381
382
|
unauthorized_explanation: ¡Ups! Esto es lo que se conoce como %{error}, es decir que no iniciaste sesión.
|
382
383
|
total: Total
|
383
384
|
uncategorized: No categorizado
|
@@ -392,6 +392,7 @@ es:
|
|
392
392
|
to_opened: Reabrir
|
393
393
|
to_pending_review: Resolver
|
394
394
|
to_solved: Resolver
|
395
|
+
toggle_read: "Marcar como leído/no leído"
|
395
396
|
unauthorized_explanation: ¡Ups! Esto es lo que se conoce como %{error}, es decir que no iniciaste sesión.
|
396
397
|
total: Total
|
397
398
|
uncategorized: No categorizado
|
@@ -379,6 +379,7 @@ pt:
|
|
379
379
|
to_opened: Reabrir
|
380
380
|
to_pending_review: Marcar como resolvida
|
381
381
|
to_solved: Marcar como resolvida
|
382
|
+
toggle_read: "Marcar como lido / não lido"
|
382
383
|
unauthorized_explanation: Opa! Isso é o que é conhecido como %{error}, ou seja, você não fez logon.
|
383
384
|
total: Total
|
384
385
|
uncategorized: Não classificado
|
@@ -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
|
53
|
+
scenario 'visitor should only see sing out' do
|
54
54
|
set_current_user! visitor
|
55
55
|
|
56
56
|
visit '/'
|
57
|
-
expect(page).
|
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
|