@@ -50,7 +50,7 @@
<%= f.association :windows_type,
- label: "Windows Type",
+ label: "Windows audience",
include_blank: true,
required: false,
input_html: {
diff --git a/app/views/organizations/_search_boxes.html.erb b/app/views/organizations/_search_boxes.html.erb
index 8fa0d0bc0..c06da8533 100644
--- a/app/views/organizations/_search_boxes.html.erb
+++ b/app/views/organizations/_search_boxes.html.erb
@@ -10,7 +10,7 @@
focus:border-blue-500 focus:ring focus:ring-blue-200 focus:outline-none" %>
- <%= label_tag :windows_type_name, "Windows type", class: "text-sm font-medium text-gray-700 mb-1 block" %>
+ <%= label_tag :windows_type_name, "Windows audience", class: "text-sm font-medium text-gray-700 mb-1 block" %>
<%= select_tag :windows_type_name,
options_for_select(WindowsType::TYPES.map { |wt| [wt, wt] },
params[:windows_type_name]),
diff --git a/app/views/stories/_story_results.html.erb b/app/views/stories/_story_results.html.erb
index 2f978e48e..7573b259d 100644
--- a/app/views/stories/_story_results.html.erb
+++ b/app/views/stories/_story_results.html.erb
@@ -22,7 +22,7 @@
| <%= sort_link.call("title", "Title") %> |
- <%= sort_link.call("windows_type", "Windows Type") %> |
+ <%= sort_link.call("windows_type", "Windows audience") %> |
<%= sort_link.call("workshop", "Workshop") %> |
<%= sort_link.call("author", "Author") %> |
<%= sort_link.call("organization", "Organization") %> |
diff --git a/app/views/story_ideas/index.html.erb b/app/views/story_ideas/index.html.erb
index 47112e8a6..6624fdc6d 100644
--- a/app/views/story_ideas/index.html.erb
+++ b/app/views/story_ideas/index.html.erb
@@ -22,7 +22,7 @@
Image |
Author |
Name |
- Windows Type |
+ Windows audience |
Workshop |
Organization |
Updated At |
diff --git a/app/views/workshop_log_creation_wizard/_form.html.erb b/app/views/workshop_log_creation_wizard/_form.html.erb
index feb5d759b..c2b79ac76 100644
--- a/app/views/workshop_log_creation_wizard/_form.html.erb
+++ b/app/views/workshop_log_creation_wizard/_form.html.erb
@@ -9,7 +9,7 @@
<%= f.hidden_field :id %>
<%= f.hidden_field :log_id, value: @old_report ? @old_report.id : nil %>
<% if @windows_types && !workshop.id %>
- <%= f.label 'New Workshop Windows Type', class: 'bold' %>
+ <%= f.label 'New workshop windows audience', class: 'bold' %>
<%= f.select :windows_type_id, @windows_types.map { |wtype| [wtype.name, wtype.id]} %>
<% end %>
diff --git a/app/views/workshops/_dropdown_filter.html.erb b/app/views/workshops/_dropdown_filter.html.erb
index d83dbba21..fa4fe75ff 100644
--- a/app/views/workshops/_dropdown_filter.html.erb
+++ b/app/views/workshops/_dropdown_filter.html.erb
@@ -41,7 +41,7 @@
id: "#{param_name}_#{item.id}",
class: "category-checkbox" %>
<%= label_tag "#{param_name}_#{item.id}",
- item.public_send(label_method).titleize,
+ item.public_send(label_method).humanize,
class: "text-sm text-gray-700" %>
<% end %>
diff --git a/app/views/workshops/_filters.html.erb b/app/views/workshops/_filters.html.erb
index 1d176ffe5..07d1c2955 100644
--- a/app/views/workshops/_filters.html.erb
+++ b/app/views/workshops/_filters.html.erb
@@ -26,7 +26,7 @@
<%= render "dropdown_filter",
dom_id_prefix: "windows-types",
- label_text: "Windows Audience",
+ label_text: "Windows audience",
items: @windows_types,
label_method: :short_name,
param_name: :windows_types %>
diff --git a/db/seeds.rb b/db/seeds.rb
index be5255c60..944138a96 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -283,10 +283,10 @@ def find_or_create_by_name!(klass, name, **attrs, &block)
category_type_categories = [
[ "AgeRange", "3-5" ],
[ "AgeRange", "6-12" ],
- [ "AgeRange", "Teen" ],
+ [ "AgeRange", "13-17" ],
[ "AgeRange", "18+" ],
[ "AgeRange", "Mixed-age groups" ],
- [ "AgeRange", "Family Windows" ],
+ [ "AgeRange", "Family windows" ],
# ["ArtType", "Boxes", 1],
[ "ArtType", "Clay", 11 ],
[ "ArtType", "Collage", 2 ],
@@ -399,6 +399,12 @@ def find_or_create_by_name!(klass, name, **attrs, &block)
cat.update!(published: true) unless cat.published?
end
+puts "Setting AgeRange category positions…"
+age_range_order = [ "3-5", "6-12", "13-17", "18+", "Mixed-age groups", "Family windows" ]
+age_range_order.each_with_index do |name, i|
+ Category.where("LOWER(name) = LOWER(?)", name).update_all(position: i + 1)
+end
+
puts "Creating StoryPopulation CategoryType…"
story_population_type = find_or_create_by_name!(CategoryType, "StoryPopulation") do |ct|
ct.display_text = "Who is this story about?"
diff --git a/spec/decorators/category_type_decorator_spec.rb b/spec/decorators/category_type_decorator_spec.rb
new file mode 100644
index 000000000..16b06853c
--- /dev/null
+++ b/spec/decorators/category_type_decorator_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+RSpec.describe CategoryTypeDecorator do
+ describe '#title' do
+ it 'returns the name in sentence case' do
+ category_type = build(:category_type, name: "art_type").decorate
+ expect(category_type.title).to eq("Art type")
+ end
+
+ it 'capitalizes only the first word' do
+ category_type = build(:category_type, name: "emotional_theme").decorate
+ expect(category_type.title).to eq("Emotional theme")
+ end
+ end
+end
diff --git a/spec/models/category_type_spec.rb b/spec/models/category_type_spec.rb
index a652e9790..c403c0e16 100644
--- a/spec/models/category_type_spec.rb
+++ b/spec/models/category_type_spec.rb
@@ -17,6 +17,18 @@
it { should validate_presence_of(:name) }
end
+ describe '#display_label' do
+ it 'returns display_text when present' do
+ category_type = build(:category_type, name: "art_type", display_text: "Custom Label")
+ expect(category_type.display_label).to eq("Custom Label")
+ end
+
+ it 'returns sentence-cased name when display_text is blank' do
+ category_type = build(:category_type, name: "art_type", display_text: nil)
+ expect(category_type.display_label).to eq("Art type")
+ end
+ end
+
describe 'scopes' do
let!(:published_category_type) { create(:category_type, :published) }
let!(:unpublished_category_type) { create(:category_type) }
diff --git a/spec/system/person_filters_workshops_test.rb b/spec/system/person_filters_workshops_test.rb
index 64d6977fe..f483c918d 100644
--- a/spec/system/person_filters_workshops_test.rb
+++ b/spec/system/person_filters_workshops_test.rb
@@ -41,7 +41,7 @@
expect(page).to have_content('The best workshop in the world')
expect(page).to have_content('oh hello!')
expect(page).to have_content('The best workshop on mars')
- expect(page).to have_content('Windows Type')
+ expect(page).to have_content('Windows audience')
expect(page).to have_content('Sector')
expect(page).to have_content('Visibility')
end
diff --git a/spec/system/workshops_spec.rb b/spec/system/workshops_spec.rb
index 5ee3b95e7..f9a6918e8 100644
--- a/spec/system/workshops_spec.rb
+++ b/spec/system/workshops_spec.rb
@@ -34,7 +34,7 @@
fill_in 'query', with: 'best workshop'
# Open the dropdown
- click_on "Windows Audience" # this clicks the