diff --git a/app/controllers/admin/footer_links_controller.rb b/app/controllers/admin/footer_links_controller.rb
index fd7cab89..9c81c9ee 100644
--- a/app/controllers/admin/footer_links_controller.rb
+++ b/app/controllers/admin/footer_links_controller.rb
@@ -36,7 +36,7 @@ def destroy
private
def footer_link_params
- params.require(:footer_link).permit(:label, :url)
+ params.require(:footer_link).permit(:label, :url, :language_id)
end
end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 38987c31..74c17a7b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -108,7 +108,7 @@ def set_cms_footer_pages
org_id = current_organization.id
@footer_pages = CmsPage.where(pub_status: 'P', language: current_language, organization_id: org_id, audience: user_audience_list)
- @footer_links = FooterLink.where(organization_id: org_id)
+ @footer_links = FooterLink.where(organization_id: org_id, language: current_language)
end
def set_cms_marketing_pages
diff --git a/app/models/footer_link.rb b/app/models/footer_link.rb
index 96982c1b..4da54c1d 100644
--- a/app/models/footer_link.rb
+++ b/app/models/footer_link.rb
@@ -1,5 +1,6 @@
class FooterLink < ApplicationRecord
belongs_to :organization
+ belongs_to :language
validates :label, presence: true
validates :url, presence: true
diff --git a/app/views/admin/footer_links/_footer_link_row.html.erb b/app/views/admin/footer_links/_footer_link_row.html.erb
index ee0e545b..1cdaaa3f 100644
--- a/app/views/admin/footer_links/_footer_link_row.html.erb
+++ b/app/views/admin/footer_links/_footer_link_row.html.erb
@@ -5,6 +5,9 @@
<%= link.url %>
+
+ <%= link.language.name %>
+
<%= link_to 'Delete', admin_footer_link_path(link), method: :delete, remote: true, data: { confirm: "Delete #{link.label} (#{link.url})?" }, id: "delete_footer_link_link_#{link.id}" %>
diff --git a/app/views/admin/footer_links/create.js.erb b/app/views/admin/footer_links/create.js.erb
index 4261e1ec..073d575e 100644
--- a/app/views/admin/footer_links/create.js.erb
+++ b/app/views/admin/footer_links/create.js.erb
@@ -1,4 +1,5 @@
$('#footer_link_list').append("<%= escape_javascript(render partial: 'footer_link_row', locals: { link: @link }) %>");
$('#footer_link_section').append("<%= escape_javascript(render partial: "shared/layout/footer_link", locals: { link: @link }) %>");
$('#footer_link_label').val('');
-$('#footer_link_url').val('');
\ No newline at end of file
+$('#footer_link_url').val('');
+$('#footer_link_language_id').val(<%= Language.first.id %>); // Reset language to default
\ No newline at end of file
diff --git a/app/views/admin/footer_links/index.html.erb b/app/views/admin/footer_links/index.html.erb
index 81d95396..96274c8e 100644
--- a/app/views/admin/footer_links/index.html.erb
+++ b/app/views/admin/footer_links/index.html.erb
@@ -26,6 +26,10 @@
<%= f.label :url, "URL", class: "plain" %>
<%= f.text_field :url %>
+
+ <%= f.label :language_id, "Language", class: "plain" %>
+ <%= f.collection_select :language_id, Language.all, :id, :name, { selected: Language.find_by(name: "English") } %>
+
<%= f.submit "Add Link", class: "skinny" %>
diff --git a/config/locales/es.yml b/config/locales/es.yml
index ea3ab473..d11b9b45 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -265,10 +265,10 @@ es:
practice_skills: "Ahora usar mis habilidades"
there_are_no_notes_for_course: "No hay notas o recursos de los asociados para este curso"
certificate:
- this_award: "Este certificado acredita que ha completado"
+ this_award: "Este certificado acredita que"
name_fill: "_____________________"
name_fill_long: "_________________________________________"
- has_completed: "ha completado el curso de"
+ has_completed: "ha completado"
as_of: "el"
att:
disclaimer: "Exención de responsabilidad: Ninguna de las otras compañías cuyos nombres o logotipos aparecen en estos materiales educativos han participado en la creación de estos materiales, ni los han aprobado ni patrocinado. Tampoco están afiliadas de ninguna manera con estos materiales."
diff --git a/db/migrate/20190509152342_add_organization_id_to_course.rb b/db/migrate/20190509152342_add_organization_id_to_course.rb
index 8d4712c5..c60e4518 100644
--- a/db/migrate/20190509152342_add_organization_id_to_course.rb
+++ b/db/migrate/20190509152342_add_organization_id_to_course.rb
@@ -1,6 +1,7 @@
class AddOrganizationIdToCourse < ActiveRecord::Migration[4.2]
def change
add_reference :courses, :organization, index: true
+
OrganizationCourse.find_each do |org_course|
next if org_course.course.nil?
org_course.course.update(organization: org_course.organization)
diff --git a/db/migrate/20210823165603_add_language_to_footer_links.rb b/db/migrate/20210823165603_add_language_to_footer_links.rb
new file mode 100644
index 00000000..24b64cea
--- /dev/null
+++ b/db/migrate/20210823165603_add_language_to_footer_links.rb
@@ -0,0 +1,6 @@
+class AddLanguageToFooterLinks < ActiveRecord::Migration[5.2]
+ def change
+ add_reference :footer_links, :language, index: true
+ add_foreign_key :footer_links, :languages
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index bee01b77..28359287 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -389,15 +389,6 @@ CREATE SEQUENCE public.courses_id_seq
ALTER SEQUENCE public.courses_id_seq OWNED BY public.courses.id;
---
--- Name: data_migrations; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.data_migrations (
- version character varying NOT NULL
-);
-
-
--
-- Name: footer_links; Type: TABLE; Schema: public; Owner: -
--
@@ -408,7 +399,8 @@ CREATE TABLE public.footer_links (
label character varying NOT NULL,
url character varying NOT NULL,
created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL
+ updated_at timestamp without time zone NOT NULL,
+ language_id bigint
);
@@ -1299,14 +1291,6 @@ ALTER TABLE ONLY public.courses
ADD CONSTRAINT courses_pkey PRIMARY KEY (id);
---
--- Name: data_migrations data_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.data_migrations
- ADD CONSTRAINT data_migrations_pkey PRIMARY KEY (version);
-
-
--
-- Name: footer_links footer_links_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -1507,6 +1491,13 @@ CREATE INDEX index_courses_on_slug ON public.courses USING btree (slug);
CREATE INDEX index_courses_on_title ON public.courses USING btree (title);
+--
+-- Name: index_footer_links_on_language_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_footer_links_on_language_id ON public.footer_links USING btree (language_id);
+
+
--
-- Name: index_footer_links_on_organization_id; Type: INDEX; Schema: public; Owner: -
--
@@ -1736,6 +1727,14 @@ ALTER TABLE ONLY public.users
ADD CONSTRAINT fk_rails_b517ecf66a FOREIGN KEY (partner_id) REFERENCES public.partners(id);
+--
+-- Name: footer_links fk_rails_bd7708fd9c; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.footer_links
+ ADD CONSTRAINT fk_rails_bd7708fd9c FOREIGN KEY (language_id) REFERENCES public.languages(id);
+
+
--
-- Name: lesson_completions fk_rails_d03dba97f9; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -1887,6 +1886,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200618155234'),
('20200707133604'),
('20210726182520'),
-('20210812220205');
+('20210812220205'),
+('20210823165603');
diff --git a/spec/controllers/admin/footer_links_controller_spec.rb b/spec/controllers/admin/footer_links_controller_spec.rb
index 38744e9a..ed36aaee 100644
--- a/spec/controllers/admin/footer_links_controller_spec.rb
+++ b/spec/controllers/admin/footer_links_controller_spec.rb
@@ -30,7 +30,7 @@
end
describe 'POST #create' do
- let(:link_params) { { label: 'Test Link', url: 'https://example.com' } }
+ let(:link_params) { { label: 'Test Link', url: 'https://example.com', language_id: @english.id } }
it 'should create a footer link' do
expect do
diff --git a/spec/factories/footer_links.rb b/spec/factories/footer_links.rb
index bc350e49..106c5464 100644
--- a/spec/factories/footer_links.rb
+++ b/spec/factories/footer_links.rb
@@ -5,5 +5,6 @@
organization
label { Faker::Lorem.sentence(word_count: 3) }
url { Faker::Internet.url }
+ language
end
end
diff --git a/spec/features/admin/footer_link_management_spec.rb b/spec/features/admin/footer_link_management_spec.rb
index 822bb5a6..75d586b4 100644
--- a/spec/features/admin/footer_link_management_spec.rb
+++ b/spec/features/admin/footer_link_management_spec.rb
@@ -19,11 +19,15 @@
expect(page).to have_content('These links will appear in addition to any of your subsite\'s CMS Pages in the "LEARN MORE" section of the footer.')
end
- scenario 'admin sees existing footer links' do
+ scenario 'admin sees existing footer link entries' do
link = FactoryBot.create(:footer_link, organization: organization)
visit admin_footer_links_path
- expect(page).to have_content link.label
- expect(page).to have_content link.url
+
+ within('#footer_link_list') do
+ expect(page).to have_content link.label
+ expect(page).to have_content link.url
+ expect(page).to have_content 'English'
+ end
end
scenario 'admin can add new footer link', js: true do
@@ -32,12 +36,22 @@
visit admin_footer_links_path
fill_in 'Label', with: label
fill_in 'URL', with: url
+ expect(page).to have_select('Language', selected: 'English')
+ select 'Spanish', from: 'Language'
click_on 'Add Link'
- expect(page).to have_content label
- expect(page).to have_link(label, href: url)
- expect(page).to have_content url
+
+ within('#footer_link_list') do
+ expect(page).to have_content label
+ expect(page).to have_content url
+ expect(page).to have_content 'Spanish'
+ end
+
expect(page).to have_field('Label', with: '')
expect(page).to have_field('URL', with: '')
+ expect(page).to have_select('Language', selected: 'English')
+
+ # Link in footer
+ expect(page).to have_link(label, href: url)
end
scenario 'admin can delete existing footer link', js: true do
diff --git a/spec/features/user/user_completes_course_spec.rb b/spec/features/user/user_completes_course_spec.rb
index c1913f82..7be82352 100644
--- a/spec/features/user/user_completes_course_spec.rb
+++ b/spec/features/user/user_completes_course_spec.rb
@@ -35,9 +35,9 @@
visit course_completion_path(course)
click_link 'Español'
- message = "Este diploma certifica que\n"\
+ message = "Este certificado acredita que\n"\
"#{user.full_name}\n"\
- "ha completado el curso de\n"\
+ "ha completado\n"\
"#{course.title}\n"\
'el 10/3/2021'
expect(page).to have_content(message)
@@ -103,9 +103,9 @@
visit course_completion_path(course)
click_link 'Español'
- message = "Este diploma certifica que\n"\
+ message = "Este certificado acredita que\n"\
"_____________________\n"\
- "ha completado el curso de\n"\
+ "ha completado\n"\
"#{course.title}\n"\
'el 10/3/2021'
expect(page).to have_content(message)
diff --git a/spec/features/user/user_walkthrough_spec.rb b/spec/features/user/user_walkthrough_spec.rb
index 8bdd3368..12da6733 100644
--- a/spec/features/user/user_walkthrough_spec.rb
+++ b/spec/features/user/user_walkthrough_spec.rb
@@ -86,13 +86,28 @@
let!(:link2) { FactoryBot.create(:footer_link, organization: org) }
let!(:other_org_link) { FactoryBot.create(:footer_link) }
let!(:cms_page) { FactoryBot.create(:cms_page, organization: org, pub_status: 'P') }
+ let!(:other_org_cms_page) { FactoryBot.create(:cms_page, pub_status: 'P') }
+ let!(:spanish_cms_page) { FactoryBot.create(:cms_page, organization: org, pub_status: 'P', language: @spanish) }
+ let!(:spanish_link) { FactoryBot.create(:footer_link, organization: org, language: @spanish) }
- scenario 'correct LEARN MORE links display' do
+ scenario 'english LEARN MORE links display' do
visit root_path
expect(page).to have_link(cms_page.title, href: cms_page_path(cms_page))
expect(page).to have_link(link1.label, href: link1.url)
expect(page).to have_link(link2.label, href: link2.url)
expect(page).not_to have_link(other_org_link.label)
+ expect(page).not_to have_link(other_org_cms_page.title)
+ expect(page).not_to have_link(spanish_cms_page.title)
+ expect(page).not_to have_link(spanish_link.label)
+ end
+
+ scenario 'spanish LEARN MORE links display' do
+ visit root_path
+ click_link 'Español'
+ expect(page).to have_link(spanish_cms_page.title)
+ expect(page).to have_link(spanish_link.label)
+ expect(page).not_to have_link(cms_page.title)
+ expect(page).not_to have_link(link1.label)
end
end
diff --git a/spec/models/footer_link_spec.rb b/spec/models/footer_link_spec.rb
index 136cd3a5..3ee02da4 100644
--- a/spec/models/footer_link_spec.rb
+++ b/spec/models/footer_link_spec.rb
@@ -21,4 +21,9 @@
link.organization = nil
expect(link).not_to be_valid
end
+
+ it 'should require a language' do
+ link.language = nil
+ expect(link).not_to be_valid
+ end
end