mumuki-laboratory 8.0.0 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mumuki_laboratory/application/gamification.js +89 -11
  3. data/app/assets/javascripts/mumuki_laboratory/application/kids.js +16 -4
  4. data/app/assets/javascripts/mumuki_laboratory/application/kindergarten.js +9 -50
  5. data/app/assets/javascripts/mumuki_laboratory/application/mu-modal-carrousel.js +63 -0
  6. data/app/assets/javascripts/mumuki_laboratory/application/number-counter.js +18 -0
  7. data/app/assets/javascripts/mumuki_laboratory/application/primary.js +2 -1
  8. data/app/assets/javascripts/mumuki_laboratory/application/submission.js +1 -1
  9. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids_results.scss +117 -0
  10. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kindergarten.scss +45 -131
  11. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_terms.scss +9 -12
  12. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_user_profile.scss +31 -3
  13. data/app/controllers/application_controller.rb +40 -8
  14. data/app/controllers/assets_controller.rb +1 -0
  15. data/app/controllers/book_discussions_controller.rb +1 -1
  16. data/app/controllers/chapters_controller.rb +1 -0
  17. data/app/controllers/discussions_controller.rb +4 -0
  18. data/app/controllers/exercises_controller.rb +1 -0
  19. data/app/controllers/guides_controller.rb +2 -0
  20. data/app/controllers/invitations_controller.rb +1 -0
  21. data/app/controllers/lessons_controller.rb +1 -0
  22. data/app/controllers/login_controller.rb +1 -0
  23. data/app/controllers/users_controller.rb +8 -1
  24. data/app/helpers/assistance_box_helper.rb +7 -5
  25. data/app/helpers/gamification_helper.rb +5 -0
  26. data/app/helpers/links_helper.rb +1 -1
  27. data/app/views/exercise_solutions/_assistant_rules_box.html.erb +13 -0
  28. data/app/views/exercise_solutions/_contextualization_results_container.html.erb +9 -0
  29. data/app/views/exercise_solutions/_kids_level_up.html.erb +11 -0
  30. data/app/views/exercise_solutions/_results.html.erb +19 -19
  31. data/app/views/exercise_solutions/_results_title.html.erb +5 -0
  32. data/app/views/exercises/show.html.erb +4 -1
  33. data/app/views/layouts/_kindergarten.html.erb +1 -1
  34. data/app/views/layouts/_organizations_listing.html.erb +8 -12
  35. data/app/views/layouts/application.html.erb +8 -2
  36. data/app/views/layouts/modals/_guide_corollary.html.erb +1 -1
  37. data/app/views/layouts/modals/_kids_context.html.erb +1 -1
  38. data/app/views/layouts/modals/_kids_results.html.erb +16 -6
  39. data/app/views/layouts/modals/_kindergarten_context.html.erb +15 -15
  40. data/app/views/layouts/modals/_kindergarten_results.html.erb +20 -7
  41. data/app/views/layouts/modals/_kindergarten_results_aborted.html.erb +4 -4
  42. data/app/views/layouts/modals/_level_up.html.erb +27 -0
  43. data/app/views/users/_edit_user_form.html.erb +1 -1
  44. data/app/views/users/_user_form.html.erb +12 -2
  45. data/app/views/users/terms.html.erb +12 -0
  46. data/config/routes.rb +8 -8
  47. data/lib/mumuki/laboratory.rb +18 -5
  48. data/lib/mumuki/laboratory/controllers.rb +2 -0
  49. data/lib/mumuki/laboratory/controllers/action_redirector.rb +21 -0
  50. data/lib/mumuki/laboratory/controllers/immersive_navigation.rb +7 -0
  51. data/lib/mumuki/laboratory/controllers/results_rendering.rb +1 -0
  52. data/lib/mumuki/laboratory/events/events.rb +0 -9
  53. data/lib/mumuki/laboratory/locales/en.yml +5 -0
  54. data/lib/mumuki/laboratory/locales/es-CL.yml +5 -0
  55. data/lib/mumuki/laboratory/locales/es.yml +5 -0
  56. data/lib/mumuki/laboratory/locales/pt.yml +5 -0
  57. data/lib/mumuki/laboratory/version.rb +1 -1
  58. data/spec/capybara_helper.rb +5 -1
  59. data/spec/controllers/exercise_solutions_controller_spec.rb +1 -1
  60. data/spec/features/immersive_redirection_spec.rb +181 -0
  61. data/spec/features/profile_flow_spec.rb +35 -3
  62. data/spec/features/terms_flow_spec.rb +151 -0
  63. metadata +110 -101
  64. data/app/helpers/organization_list_helper.rb +0 -5
  65. data/spec/features/choose_organization_spec.rb +0 -74
@@ -16,3 +16,15 @@
16
16
  <% end %>
17
17
  </div>
18
18
 
19
+ <% if @user&.has_role_terms_to_accept? %>
20
+ <div class="terms-acceptance">
21
+ <%= form_for :user, url: terms_user_path, method: :post do |f| %>
22
+ <span class="terms-acceptance-checkbox">
23
+ <%= f.check_box :terms_of_service, required: true, onInvalid: "this.setCustomValidity('#{t(:terms_and_conditions_must_be_accepted)}')", onChange: "this.setCustomValidity(validity.valueMissing ? '#{t(:terms_and_conditions_must_be_accepted)}' : '')" %>
24
+ <%= t(:accept_terms) %>
25
+ </span>
26
+ <%= f.submit t(:accept), class: 'btn btn-success terms-acceptance-btn' %>
27
+ <% end %>
28
+ </div>
29
+ <% end %>
30
+
@@ -52,11 +52,15 @@ Rails.application.routes.draw do
52
52
  resources :complements, only: :show
53
53
  resources :exams, only: :show
54
54
 
55
- # All users
56
- resource :user, only: [:show, :edit]
57
- get '/user/terms' => 'users#terms'
58
-
59
55
  # Current user
56
+ resource :user, only: [:show, :edit, :update] do
57
+ get :terms
58
+ post :terms, to: 'users#accept_profile_terms'
59
+
60
+ # Notification subscriptions
61
+ get :unsubscribe
62
+ end
63
+
60
64
  resources :messages, only: [:index, :create]
61
65
  get '/messages/errors' => 'messages#errors'
62
66
 
@@ -69,10 +73,6 @@ Rails.application.routes.draw do
69
73
  get '/join/:code' => 'invitations#show', as: :invitation
70
74
  post '/join/:code' => 'invitations#join'
71
75
 
72
- # Notification subscriptions
73
- get '/user/unsubscribe' => 'users#unsubscribe'
74
- put '/user' => 'users#update', as: :update_user
75
-
76
76
  # Route for reading messages
77
77
  post '/messages/read_messages/:exercise_id' => 'messages#read_messages', as: :read_messages
78
78
 
@@ -31,12 +31,25 @@ end
31
31
 
32
32
  module Mumukit::Platform::OrganizationMapping::Path
33
33
  class << self
34
- patch :organization_name do |request, domain, hyper|
35
- name = hyper.(request, domain)
36
- if %w(auth login logout).include? name
37
- 'base'
34
+ alias_method :__organization_name__, :organization_name
35
+ def in_actual_organization?(request, domain = nil)
36
+ actual_organization_name(request, domain).present?
37
+ end
38
+
39
+ def actual_organization_name(request, domain)
40
+ name = __organization_name__(request, domain)
41
+ name unless %w(auth login logout).include? name
42
+ end
43
+
44
+ def organization_name(request, domain)
45
+ actual_organization_name(request, domain) || 'base'
46
+ end
47
+
48
+ patch :inorganic_path_for do |request, hyper|
49
+ if in_actual_organization?(request)
50
+ hyper.call
38
51
  else
39
- name
52
+ path_for(request)
40
53
  end
41
54
  end
42
55
  end
@@ -2,12 +2,14 @@ module Mumuki::Laboratory::Controllers
2
2
  end
3
3
 
4
4
  require_relative './controllers/authorization'
5
+ require_relative './controllers/action_redirector'
5
6
  require_relative './controllers/disabling'
6
7
  require_relative './controllers/current_organization'
7
8
  require_relative './controllers/dynamic_errors'
8
9
  require_relative './controllers/notifications'
9
10
  require_relative './controllers/embedded_mode'
10
11
  require_relative './controllers/incognito_mode'
12
+ require_relative './controllers/immersive_navigation'
11
13
  require_relative './controllers/nested_in_exercise'
12
14
  require_relative './controllers/results_rendering'
13
15
  require_relative './controllers/exercise_seed'
@@ -0,0 +1,21 @@
1
+ module Mumuki::Laboratory::Controllers::ActionRedirector
2
+ def save_location_before!(action)
3
+ session[redirection_variable_for(action)] = origin
4
+ end
5
+
6
+ def redirect_after!(action, fallback_location: root_path)
7
+ redirection_variable = redirection_variable_for(action)
8
+ destination = session.delete(redirection_variable).presence
9
+ redirect_to(destination || fallback_location)
10
+ end
11
+
12
+ private
13
+
14
+ def redirection_variable_for(action)
15
+ "redirect_after_#{action}"
16
+ end
17
+
18
+ def origin
19
+ Addressable::URI.heuristic_parse(request.path).to_s
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module Mumuki::Laboratory::Controllers::ImmersiveNavigation
2
+ extend ActiveSupport::Concern
3
+
4
+ def immersive_subject
5
+ subject.navigable_content_in(current_immersive_context)
6
+ end
7
+ end
@@ -29,6 +29,7 @@ module Mumuki::Laboratory::Controllers::ResultsRendering
29
29
  title_html: render_results_title(assignment),
30
30
  expectations: assignment.affable_expectation_results,
31
31
  tips: assignment.affable_tips,
32
+ level_up_html: render_results('exercise_solutions/kids_level_up', assignment),
32
33
  test_results: assignment.sanitized_affable_test_results) # these results could include escaped characters so they should be rendered as HTML to display properly
33
34
  end
34
35
 
@@ -1,15 +1,6 @@
1
1
  Mumukit::Nuntius::EventConsumer.handle do
2
-
3
2
  # Emitted by assigment manual evaluation in classroom
4
3
  event 'AssignmentManuallyEvaluated' do |payload|
5
4
  Assignment.evaluate_manually! payload.deep_symbolize_keys[:assignment]
6
5
  end
7
-
8
- [Book, Topic, Guide].each do |it|
9
- event "#{it.name}Changed" do |data|
10
- Mumukit::Sync::Syncer.new(
11
- Mumukit::Sync::Store::Bibliotheca.new(
12
- Mumukit::Platform.bibliotheca_bridge)).locate_and_import! it, data[:slug]
13
- end
14
- end
15
6
  end
@@ -95,6 +95,7 @@ en:
95
95
  exercise_number: Exercise %{number}
96
96
  exercise_success_rate: Exercises success rate
97
97
  exit: Exit
98
+ exp_points: experience points.
98
99
  expectations: Expectations
99
100
  expected_state: Expected board
100
101
  explain_redirect: You have registered in another organization
@@ -145,6 +146,8 @@ en:
145
146
  lessons: Lessons
146
147
  lesson_number: Lesson %{number}
147
148
  let_us_know: please let us know!
149
+ level: Level
150
+ level_up: Level up!
148
151
  loading: Loading
149
152
  load_solution_into_console: Load your solution into the console
150
153
  locked_content: 'This content will be unlocked when you finish previous chapters'
@@ -233,6 +236,7 @@ en:
233
236
  solved: Solved
234
237
  solved_count: '%{count} solved'
235
238
  solve_doubts: Solve other's doubts
239
+ solve_more_exercises_to_level_up: Solve <span>number</span> more exercises to advance to the next level.
236
240
  solve_your_doubts: Solve your doubts
237
241
  solve_your_doubts_teaser: Do you have any doubts?
238
242
  something_went_wrong: Something went wrong!
@@ -289,6 +293,7 @@ en:
289
293
  working: "Working"
290
294
  wrong_answer: The answer is wrong
291
295
  years: years old
296
+ you_earned: You earned
292
297
  you_must_sign_in_before_submitting: You must sign in before submitting your solutions
293
298
  you_never_submitted_solutions: It seems that you've never submitted solutions since you created your account.
294
299
  your_new_organization: your new organization
@@ -93,6 +93,7 @@ es-CL:
93
93
  exercise_success_rate: Tasa de éxito en ejercicios
94
94
  exercises: Ejercicios
95
95
  exit: Salir
96
+ exp_points: puntos de experiencia.
96
97
  expectations: Objetivos
97
98
  expected_state: Tablero esperado
98
99
  explain_redirect: Notamos que te registraste en otra organización.
@@ -139,6 +140,8 @@ es-CL:
139
140
  lessons: Lecciones
140
141
  lesson_number: Lección %{number}
141
142
  let_us_know: ¡Por favor avísanos!
143
+ level: Nivel
144
+ level_up: ¡Subiste de nivel!
142
145
  loading: Cargando
143
146
  load_solution_into_console: Cargar la solución en la consola
144
147
  locked_content: 'Éste contenido se desbloqueará cuando termines los capítulos anteriores'
@@ -235,6 +238,7 @@ es-CL:
235
238
  other: '%{count} resueltas'
236
239
  solved_exercises: Ejercicios Resueltos
237
240
  solve_doubts: Resuelve consultas
241
+ solve_more_exercises_to_level_up: Resuelve <span>number</span> ejercicios más para pasar al siguiente nivel.
238
242
  solve_your_doubts: Consulta tus dudas
239
243
  solve_your_doubts_teaser: ¿Tienes alguna consulta?
240
244
  something_went_wrong: ¡Ups!, algo no anduvo bien...
@@ -294,5 +298,6 @@ es-CL:
294
298
  page_gap: "&hellip;"
295
299
  working: "Procesando"
296
300
  wrong_answer: La respuesta no es correcta
301
+ you_earned: Ganaste
297
302
  you_must_sign_in_before_submitting: Tienes que iniciar sesión antes de empezar a enviar tus soluciones
298
303
  you_never_submitted_solutions: Parece que nunca enviaste soluciones desde que creaste tu cuenta.
@@ -101,6 +101,7 @@ es:
101
101
  exercise_success_rate: Tasa de éxito en ejercicios
102
102
  exercises: Ejercicios
103
103
  exit: Salir
104
+ exp_points: puntos de experiencia.
104
105
  expectations: Objetivos
105
106
  expected_state: Tablero esperado
106
107
  explain_redirect: Notamos que te registraste en otra organización.
@@ -155,6 +156,8 @@ es:
155
156
  lessons: Lecciones
156
157
  lesson_number: Lección %{number}
157
158
  let_us_know: ¡Por favor avisanos!
159
+ level: Nivel
160
+ level_up: ¡Subiste de nivel!
158
161
  loading: Cargando
159
162
  load_solution_into_console: Cargar la solución en la consola
160
163
  locked_content: 'Este contenido se desbloqueará cuando termines los capítulos anteriores'
@@ -255,6 +258,7 @@ es:
255
258
  other: '%{count} resueltas'
256
259
  solved_exercises: Ejercicios Resueltos
257
260
  solve_doubts: Resolvé consultas
261
+ solve_more_exercises_to_level_up: Resolvé <span>number</span> ejercicios más para pasar al siguiente nivel.
258
262
  solve_your_doubts: Consultá tus dudas
259
263
  solve_your_doubts_teaser: ¿Tenés alguna consulta?
260
264
  something_went_wrong: ¡Ups!, algo no anduvo bien...
@@ -317,6 +321,7 @@ es:
317
321
  working: "Procesando"
318
322
  wrong_answer: La respuesta no es correcta
319
323
  years: años
324
+ you_earned: Ganaste
320
325
  you_must_sign_in_before_submitting: Tenés que iniciar sesión antes de empezar a enviar tus soluciones
321
326
  you_never_submitted_solutions: Parece que nunca enviaste soluciones desde que creaste tu cuenta.
322
327
  your_new_organization: tu nueva organización
@@ -97,6 +97,7 @@ pt:
97
97
  exercise_success_rate: Taxa de sucesso em exercícios
98
98
  exercises: Exercícios
99
99
  exit: Sair
100
+ exp_points: pontos de experiência.
100
101
  expectations: Objetivos
101
102
  expected_state: Tabuleiro esperado
102
103
  explain_redirect: Percebemos que você se registrou em outra organização.
@@ -149,6 +150,8 @@ pt:
149
150
  lessons: Lições
150
151
  lesson_number: Lição %{number}
151
152
  let_us_know: Por favor, avise-nos!
153
+ level: Nível
154
+ level_up: Você sobe de nível!
152
155
  loading: Carregando
153
156
  load_solution_into_console: Carregue a solução no console
154
157
  locked_content: 'Este conteúdo será desbloqueado quando você terminar os capítulos anteriores'
@@ -242,6 +245,7 @@ pt:
242
245
  solved_count: '%{count} resolvido'
243
246
  solved_exercises: Exercícios resolvidos
244
247
  solve_doubts: Resolvi dúvidas
248
+ solve_more_exercises_to_level_up: Resolva mais <span>number</span> exercícios para avançar para o próximo nível.
245
249
  solve_your_doubts: Consulte suas dúvidas
246
250
  solve_your_doubts_teaser: Você tem alguma dúvida?
247
251
  something_went_wrong: Oops!, Algo não estava certo ...
@@ -292,5 +296,6 @@ pt:
292
296
  working: Processamento
293
297
  wrong_answer: A resposta não é correta
294
298
  years: anos
299
+ you_earned: Você ganhou
295
300
  you_must_sign_in_before_submitting: Você deve fazer o login antes de começar a enviar suas soluções
296
301
  your_new_organization: sua nova organização
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Laboratory
3
- VERSION = '8.0.0'
3
+ VERSION = '8.1.0'
4
4
  end
5
5
  end
@@ -87,7 +87,11 @@ def exclude_selenium_failing_tests!
87
87
  :json_eq_error,
88
88
  :navigation_error,
89
89
  :organization_not_nil,
90
- :xpath_no_matches
90
+ :xpath_no_matches,
91
+
92
+ # Fails because Rails redirection doesn't include Capybara port.
93
+ # It can be fixed by using path mapping instead of subdomain.
94
+ :subdomain_redirection_without_port
91
95
  )
92
96
  end
93
97
  end
@@ -89,7 +89,7 @@ describe ExerciseSolutionsController, organization_workspace: :test do
89
89
 
90
90
  it { expect(response.body).to json_eq({ status: :failed, guide_finished_by_solution: false },
91
91
  except: [:html, :remaining_attempts_html, :title_html, :button_html,
92
- :expectations, :test_results, :tips, :current_exp]) }
92
+ :expectations, :test_results, :tips, :current_exp, :level_up_html]) }
93
93
 
94
94
  it 'includes kids specific renders' do
95
95
  body = JSON.parse(response.body)
@@ -0,0 +1,181 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Immersive redirection Flow', organization_workspace: :test, subdomain_redirection_without_port: true do
4
+ def create_guide(name)
5
+ create(:guide, name: name)
6
+ end
7
+
8
+ def create_immersive_organization(name, guides)
9
+ create(:organization,
10
+ name: name,
11
+ immersive: true,
12
+ book:
13
+ create(:book,
14
+ chapters: [
15
+ create(:chapter, lessons: guides.map { |it| create(:lesson, guide: it) })
16
+ ]))
17
+ end
18
+
19
+ let(:organization) { Organization.current }
20
+ let(:book) { organization.book }
21
+
22
+ let(:guide_one) { create_guide 'guide one' }
23
+ let(:guide_two) { create_guide 'guide two' }
24
+ let(:guide_three) { create_guide 'guide three' }
25
+
26
+ let(:lesson_one) { create(:lesson, guide: guide_one) }
27
+ let(:lesson_two) { create(:lesson, guide: guide_two) }
28
+ let(:lesson_three) { create(:lesson, guide: guide_three) }
29
+
30
+ before { book.update! chapters: [create(:chapter, lessons: [lesson_one, lesson_two, lesson_three])] }
31
+ before { set_current_user! user }
32
+
33
+ shared_examples 'immersive redirection' do |organization_name|
34
+ scenario 'should redirect to immersive organization' do
35
+ expect(page).to have_text organization_name
36
+ expect(page).not_to have_text "Go to #{organization_name}"
37
+ end
38
+ end
39
+
40
+ shared_examples 'navigate to content' do |guide_name|
41
+ scenario 'should navigate to content' do
42
+ expect(page).to have_text guide_name
43
+ expect(page).to have_text 'Exercises'
44
+ end
45
+ end
46
+
47
+ shared_examples 'navigate to main page' do
48
+ scenario 'should navigate to main page' do
49
+ expect(page).to have_text 'Start Practicing!'
50
+ end
51
+ end
52
+
53
+ shared_examples 'navigate to discussions main page' do
54
+ scenario 'should navigate to discussions main page' do
55
+ expect(page).to have_text 'Discussions'
56
+ end
57
+ end
58
+
59
+ shared_examples 'navigate to user profile' do
60
+ scenario 'should navigate to user profile' do
61
+ expect(page).to have_text user.full_name
62
+ end
63
+ end
64
+
65
+ context 'with one immersive organization' do
66
+ let(:user) { create(:user, permissions: {student: 'immersive-orga/*'}) }
67
+ let!(:immersive_orga) { create_immersive_organization('immersive-orga', [guide_one]) }
68
+
69
+ feature 'when navigating to an available content' do
70
+ before { visit lesson_path(lesson_one) }
71
+ it_behaves_like 'immersive redirection', 'immersive-orga'
72
+ it_behaves_like 'navigate to content', 'guide one'
73
+ end
74
+
75
+ feature 'when navigating to an unavailable content' do
76
+ before { visit lesson_path(lesson_two) }
77
+ it_behaves_like 'immersive redirection', 'immersive-orga'
78
+ it_behaves_like 'navigate to main page'
79
+ end
80
+
81
+ context 'when navigating to a discussion' do
82
+ feature 'and forum enabled' do
83
+ before { immersive_orga.update(forum_enabled: true) }
84
+ before { visit discussions_path }
85
+ it_behaves_like 'immersive redirection', 'immersive-orga'
86
+ it_behaves_like 'navigate to discussions main page'
87
+ end
88
+
89
+ feature 'and forum not enabled' do
90
+ before { visit discussions_path }
91
+ it_behaves_like 'immersive redirection', 'immersive-orga'
92
+ it_behaves_like 'navigate to main page'
93
+ end
94
+ end
95
+
96
+ feature 'when navigating to another route' do
97
+ before { visit user_path }
98
+ it_behaves_like 'immersive redirection', 'immersive-orga'
99
+ it_behaves_like 'navigate to user profile'
100
+ end
101
+ end
102
+
103
+ context 'with many immersive organizations' do
104
+ let(:user) { create(:user, permissions: {student: 'immersive-orga/*:private/*'}) }
105
+
106
+ let!(:private_orga) { create_immersive_organization('private', [guide_one, guide_two]) }
107
+ let!(:immersive_orga) { create_immersive_organization('immersive-orga', [guide_one]) }
108
+
109
+ shared_examples 'organization chooser' do
110
+ scenario 'should display organization chooser' do
111
+ expect(page).to have_text 'You have registered in another organization'
112
+ end
113
+ end
114
+
115
+ def choose_organization(name)
116
+ within '.modal' do
117
+ click_on "Go to #{name}"
118
+ end
119
+ end
120
+
121
+ feature 'when content is present in one of them' do
122
+ before { visit lesson_path(lesson_two) }
123
+ it_behaves_like 'immersive redirection', 'private'
124
+ it_behaves_like 'navigate to content', 'guide two'
125
+ end
126
+
127
+ feature 'when content is present in two of them' do
128
+ before { visit lesson_path(lesson_one) }
129
+ it_behaves_like 'organization chooser'
130
+
131
+ context 'after choosing an organization' do
132
+ before { choose_organization 'private' }
133
+ it_behaves_like 'immersive redirection', 'private'
134
+ it_behaves_like 'navigate to content', 'guide one'
135
+ end
136
+ end
137
+
138
+ describe 'when content is not present on any of them' do
139
+ before { visit lesson_path(lesson_three) }
140
+ it_behaves_like 'organization chooser'
141
+
142
+ context 'after choosing an organization' do
143
+ before { choose_organization 'immersive-orga' }
144
+ it_behaves_like 'immersive redirection', 'immersive-orga'
145
+ it_behaves_like 'navigate to main page'
146
+ end
147
+ end
148
+
149
+ feature 'when navigating to another route' do
150
+ before { visit user_path }
151
+ it_behaves_like 'organization chooser'
152
+
153
+ context 'after choosing an organization' do
154
+ before { choose_organization 'immersive-orga' }
155
+ it_behaves_like 'immersive redirection', 'immersive-orga'
156
+ it_behaves_like 'navigate to user profile'
157
+ end
158
+ end
159
+
160
+ context 'when navigating to a discussion' do
161
+ before { immersive_orga.update(forum_enabled: true) }
162
+ before { visit discussions_path }
163
+
164
+ it_behaves_like 'organization chooser'
165
+
166
+ feature 'and forum enabled' do
167
+ before { choose_organization 'immersive-orga' }
168
+
169
+ it_behaves_like 'immersive redirection', 'immersive-orga'
170
+ it_behaves_like 'navigate to discussions main page'
171
+ end
172
+
173
+ feature 'and forum not enabled' do
174
+ before { choose_organization 'private' }
175
+
176
+ it_behaves_like 'immersive redirection', 'private'
177
+ it_behaves_like 'navigate to main page'
178
+ end
179
+ end
180
+ end
181
+ end