Skip to content

Commit

Permalink
Merge pull request #498 from commercekitchen/develop
Browse files Browse the repository at this point in the history
Create AT&T subdomain
  • Loading branch information
tmichaelreis authored Aug 10, 2021
2 parents db547b3 + 64068bb commit e920915
Show file tree
Hide file tree
Showing 22 changed files with 143 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ config/secrets.yml
.byebug_history

# Local environment
/config/local_env.yml
/config/local_env.yml

# asdf version
.tool-versions
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 2.6.6
12 changes: 7 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.0)
Expand Down Expand Up @@ -195,9 +195,11 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mimemagic (0.3.4)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_mime (1.0.2)
mini_portile2 (2.5.0)
mini_portile2 (2.5.1)
minitest (5.14.0)
mocha (1.11.2)
msgpack (1.3.3)
Expand All @@ -210,7 +212,7 @@ GEM
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
nio4r (2.5.2)
nokogiri (1.11.1)
nokogiri (1.11.4)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
orm_adapter (0.5.0)
Expand All @@ -237,7 +239,7 @@ GEM
pry-remote (0.1.8)
pry (~> 0.9)
slop (~> 3.0)
public_suffix (4.0.3)
public_suffix (4.0.6)
pundit (2.1.0)
activesupport (>= 3.0.0)
racc (1.5.2)
Expand Down
Binary file added app/assets/images/att_logo_header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/assets/stylesheets/subdomains/_att.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.att {
@include color_scheme($att-dark-blue, $att-light-blue, $att-light-blue);
@include banner($att-light-blue);
@include buttons($att-dark-blue);
@include course_widget($att-light-blue, $att-dark-blue);
@include lesson_tile($att-light-blue, $grey, $att-orange);
@include icons($att-light-blue, $orange);
}
5 changes: 5 additions & 0 deletions app/assets/stylesheets/vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ $mdpls-blue: #145a92;
$mdpls-green: #046434;
$mdpls-gray: #808080;

/* AT&T */
$att-dark-blue: #0057b8;
$att-light-blue: #009fdb;
$att-orange: #ffb000;

$purple: #8945a1;
$purple-2: #7b439b;
$dark-purple: #7d3191;
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/lessons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def update
end

def destroy_asl_attachment
@lesson = @course.lessons.friendly.find(params[:format])
@lesson = @course.lessons.friendly.find(params[:lesson_id])
authorize @lesson, :update?

@lesson.story_line = nil
@lesson.story_line.destroy
@lesson.save
FileUtils.remove_dir "#{Rails.root}/public/storylines/#{@lesson.id}", true
flash[:notice] = 'Story Line successfully removed, please upload a new story line .zip file.'
Expand Down
11 changes: 11 additions & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ def assignable_roles
end
end

def training_site_link
training_site_base = Rails.application.secrets.training_site_base
training_site_domain = Rails.application.secrets.training_site_domain

if use_subdomain_for_training_site
[training_site_base, subdomain, training_site_domain].join('.')
else
[training_site_base, training_site_domain].join('.')
end
end

def self.pla
find_by(subdomain: 'www')
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/lessons/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
to upload a new one, you need to delete the current one first.</p>
<p class="upload-field">
<%= @lesson.story_line.instance.story_line_file_name %>
<%= link_to "Remove", destroy_asl_attachment_admin_course_lessons_path(@course, @lesson), method: "delete", data: { confirm: "Are you sure?" } %>
<%= link_to "Remove", destroy_asl_attachment_admin_course_lessons_path(course_id: @course.id, lesson_id: @lesson.id), method: "delete", data: { confirm: "Are you sure?" } %>
</p>
</fieldset>
<% end %>
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion app/views/shared/header/_trainers_link.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="trainers-link">
<strong>
<%= link_to t('home.trainer_link'), "https://training.digitallearn.org" %>
<%= link_to t('home.trainer_link'), current_organization.training_site_link %>
</strong>
</div>
3 changes: 1 addition & 2 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'colorize'

# GIT Repo URL
set :repo_url, "[email protected]:PublicLibraryAssoc/cpldl.git"
set :repo_url, "[email protected]:commercekitchen/cpldl.git"

# Ruby Version (used for RVM) - MUST MATCH PASSENGER/SERVER CONFIG!
set :ruby_version, '2.6.4'
Expand Down Expand Up @@ -83,7 +83,6 @@
'tmp/sockets',
'vendor/bundle',
'public/system',
'public/storylines',
'public/ckeditor_assets'
)

Expand Down
29 changes: 29 additions & 0 deletions db/data/20210630052420_create_att_subsite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class CreateAttSubsite < ActiveRecord::Migration[5.2]
def up
# Subsite Attributes
subsite_attributes = {
name: 'AT&T',
subdomain: 'att',
branches: false,
accepts_programs: false,
accepts_partners: false
}

# Admin users
admins = ['[email protected],
[email protected],
[email protected]']

# Create the subdomain organization
subsite = Organization.create!(subsite_attributes)

# Invite Admins
admins.each do |email|
AdminInvitationService.invite(email: email, organization: subsite)
end
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
5 changes: 2 additions & 3 deletions db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# frozen_string_literal: true

DataMigrate::Data.define(version: 20_210_209_193_144)
# encoding: UTF-8
DataMigrate::Data.define(version: 20210630052420)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddUseSubdomainForTrainingSiteFlagToOrganizations < ActiveRecord::Migration[5.2]
def change
add_column :organizations, :use_subdomain_for_training_site, :boolean, default: false, null: false
end
end
6 changes: 4 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ CREATE TABLE public.organizations (
accepts_custom_branches boolean DEFAULT false,
login_required boolean DEFAULT true,
preferences jsonb DEFAULT '{}'::jsonb NOT NULL,
accepts_partners boolean DEFAULT false
accepts_partners boolean DEFAULT false,
use_subdomain_for_training_site boolean DEFAULT false NOT NULL
);


Expand Down Expand Up @@ -1829,6 +1830,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200327172506'),
('20200327214039'),
('20200618155234'),
('20200707133604');
('20200707133604'),
('20210726182520');


Binary file modified erd.pdf
Binary file not shown.
9 changes: 9 additions & 0 deletions spec/controllers/admin/lessons_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,13 @@
expect(child_lesson2.reload.lesson_order).to eq(1)
end
end

describe 'DELETE #destroy_asl_attachment' do
let(:params) { { course_id: pla_course.id, lesson_id: lesson1.id } }

it 'should remove lesson upload' do
delete :destroy_asl_attachment, params: params
expect(lesson1.reload.story_line.exists?).to be_falsey
end
end
end
1 change: 0 additions & 1 deletion spec/features/admin/edit_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
expect(current_path).to eq(edit_admin_course_path(subsite_course))
expect(page).to have_content('Course was successfully updated.')
expect(page).to have_select('Publication Status', selected: 'Draft')

end

scenario 'selects existing category for course' do
Expand Down
38 changes: 38 additions & 0 deletions spec/features/admin/edit_lesson_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

require 'feature_helper'

feature 'Admin user updates lesson' do
let(:story_line) do
fixture_file_upload(Rails.root.join('spec', 'fixtures', 'BasicSearch1.zip'), 'application/zip')
end

let(:pla) { FactoryBot.create(:default_organization) }

let(:course) { FactoryBot.create(:course, organization: pla) }
let(:lesson) { FactoryBot.create(:lesson, course: course) }

let(:user) { FactoryBot.create(:user, :admin, organization: pla) }

before do
switch_to_subdomain(pla.subdomain)
log_in_with user.email, user.password
end

scenario 'can change lesson attachment', js: true do
visit edit_admin_course_lesson_path(course, lesson)
expect(page).to have_content('BasicSearch1.zip')
accept_confirm do
click_link 'Remove'
end
expect(page).not_to have_content('BasicSearch1.zip')
expect(page).to have_content('Story Line successfully removed, please upload a new story line .zip file.')

# Re-attach file
attach_file 'Articulate Storyline Package', Rails.root.join('spec', 'fixtures', 'BasicSearch1.zip')
click_button 'Save Lesson'

expect(current_path).to eq(edit_admin_course_lesson_path(course.to_param, Lesson.last.to_param))
expect(page).to have_content('Lesson successfully updated.')
end
end
5 changes: 4 additions & 1 deletion spec/features/admin/new_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,21 @@ def fill_basic_course_info
expect(page).to have_content('Why_Use_a_Computer_Worksheet.pdf')
end

scenario 'adds a lesson' do
scenario 'adds a lesson', js: true do
visit edit_admin_course_path(course_id: course, id: course.id)
click_button 'Save & Edit Lessons'
expect(current_path).to eq(new_admin_course_lesson_path(course))
fill_in :lesson_title, with: 'New Lesson Title'
fill_in :lesson_summary, with: 'Summary for new lesson'
fill_in :lesson_duration, with: '05:15'
attach_file 'Articulate Storyline Package', Rails.root.join('spec', 'fixtures', 'BasicSearch1.zip')

click_button 'Save Lesson'
expect(page).to have_content('Lesson was successfully created.')
expect(current_path).to eq(edit_admin_course_lesson_path(course.to_param, Lesson.last.to_param))

expect(page).to have_content 'BasicSearch1.zip'

click_link 'Add Another Lesson'
expect(current_path).to eq(new_admin_course_lesson_path(course.to_param))
end
Expand Down
11 changes: 11 additions & 0 deletions spec/models/organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,15 @@
expect(Organization.pla).to eq(pla)
end
end

describe '#training_site_link' do
it 'returns main training site by default' do
expect(org.training_site_link).to eq('https://training.test.org')
end

it 'returns subsite link if configured' do
org.update(use_subdomain_for_training_site: true)
expect(org.training_site_link).to eq("https://training.#{org.subdomain}.test.org")
end
end
end

0 comments on commit e920915

Please sign in to comment.