Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore immersive fix #1609

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ group :development, :test do
gem 'teaspoon-jasmine'
gem 'selenium-webdriver'
end

gem 'mumuki-domain', github: 'mumuki/mumuki-domain', branch: 'chore-retenantize'
gem 'mumukit-platform', github: 'mumuki/mumukit-platform', branch: 'chore-untenantize'
10 changes: 3 additions & 7 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,14 @@ def current_immersive_path(context)
end

def current_immersive_path_for(context, content)
resource = content ? polymorphic_path(content) : default_immersive_path_for(context)
context.url_for resource
resource_path = content ? polymorphic_path(content) : default_immersive_path_for(context)
context.retenantized_url_for(resource_path)
end

private

def default_immersive_path_for(context)
subject.present? ? root_path : inorganic_path_for(request)
end

def inorganic_path_for(request)
Mumukit::Platform.organization_mapping.inorganic_path_for(request)
subject.present? ? root_path : request.path_info
end

def current_immersive_context
Expand Down
26 changes: 0 additions & 26 deletions lib/mumuki/laboratory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,6 @@ class Mumuki::Laboratory::Engine < ::Rails::Engine
config.i18n.available_locales = Mumukit::Platform::Locale.supported
end

module Mumukit::Platform::OrganizationMapping::Path
class << self
alias_method :__organization_name__, :organization_name
def in_actual_organization?(request, domain = nil)
actual_organization_name(request, domain).present?
end

def actual_organization_name(request, domain)
name = __organization_name__(request, domain)
name unless %w(auth login logout).include? name
end

def organization_name(request, domain)
actual_organization_name(request, domain) || 'base'
end

patch :inorganic_path_for do |request, hyper|
if in_actual_organization?(request)
hyper.call(request)
else
path_for(request)
end
end
end
end

require_relative './laboratory/version'
require_relative './laboratory/extensions'
require_relative './laboratory/controllers'
Expand Down
20 changes: 19 additions & 1 deletion spec/features/immersive_redirection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

feature 'Immersive redirection Flow', organization_workspace: :test, subdomain_redirection_without_port: true do
def create_guide(name)
create(:guide, name: name)
create(:guide, name: name, exercises: create_list(:exercise, 3))
end

def create_immersive_organization(name, guides)
Expand All @@ -27,6 +27,9 @@ def create_immersive_organization(name, guides)
let(:lesson_two) { create(:lesson, guide: guide_two) }
let(:lesson_three) { create(:lesson, guide: guide_three) }

let(:discussion_exercise) { guide_one.exercises.first }
let(:discussion) { create(:discussion, item: discussion_exercise, organization: Organization.current) }

before { book.update! chapters: [create(:chapter, lessons: [lesson_one, lesson_two, lesson_three])] }
before { set_current_user! user }

Expand Down Expand Up @@ -79,6 +82,21 @@ def create_immersive_organization(name, guides)
end

context 'when navigating to a discussion' do
feature 'and forum enabled' do
before { immersive_orga.update(forum_enabled: true) }
before { visit exercise_discussion_path(discussion_exercise, discussion) }
it_behaves_like 'immersive redirection', 'immersive-orga'
it_behaves_like 'navigate to discussions main page'
end

feature 'and forum not enabled' do
before { visit exercise_discussion_path(discussion_exercise, discussion) }
it_behaves_like 'immersive redirection', 'immersive-orga'
it_behaves_like 'navigate to main page'
end
end

context 'when navigating to discussions page' do
feature 'and forum enabled' do
before { immersive_orga.update(forum_enabled: true) }
before { visit discussions_path }
Expand Down