Skip to content
Merged
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
2 changes: 1 addition & 1 deletion app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ def ensure_group_manager
end

def group_params
params.require(:group).permit(:name, :description, :privacy, :focus, :reading_list)
params.require(:group).permit(:name, :description, :privacy, :plan, :focus, :reading_list)
end
end
15 changes: 15 additions & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ def starting_location
{ translation: "kjv", book: first_red.book.downcase, chapter: first_red.number }
end

# What the study reads, as the one choice the form offers: "bible",
# "red" (Highlighted in Red, chapter by chapter), or a reading list.
def plan
reading_list.presence || focus
end

def plan=(value)
if FOCUSES.key?(value.to_s.to_sym)
self.focus = value
self.reading_list = nil
else
self.reading_list = value
end
end

# The passages on the study's list, in the order the list presents
# them. Empty for a study with no list.
def passages
Expand Down
25 changes: 9 additions & 16 deletions app/views/groups/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,21 @@
<% end %>
</fieldset>

<fieldset class="space-y-2">
<legend class="<%= label_classes %>"><%= t("groups.focus.label") %></legend>
<% Group::FOCUSES.each_key do |key| %>
<label class="flex items-center gap-2 font-ui text-sm text-surface-700">
<%= f.radio_button :focus, key, class: radio_classes %>
<%= t("groups.focus.#{key}") %>
</label>
<% end %>
<p class="font-ui text-xs text-surface-600"><%= t("groups.focus.hint") %></p>
</fieldset>

<%# One choice for what the study reads: the whole Bible, Highlighted
in Red chapter by chapter, or one of the lists or themes read a
passage at a time. %>
<div>
<%= f.label :reading_list, t("groups.reading_list.label"), class: label_classes %>
<%= f.select :reading_list,
<%= f.label :plan, t("groups.focus.label"), class: label_classes %>
<%= f.select :plan,
options_for_select([ [ t("groups.plan.bible"), "bible" ], [ t("groups.plan.red"), "red" ] ], group.plan) +
grouped_options_for_select(
{ t("groups.reading_list.lists_group") => Bible::Passages::COLLECTIONS.keys.map { |list| [ t("red.#{list}.title"), list ] },
t("groups.reading_list.themes_group") => Bible::Themes.all.map { |theme| [ theme.name, "#{Group::THEME_PREFIX}#{theme.slug}" ] } },
group.reading_list
group.plan
),
{ include_blank: t("groups.reading_list.none") },
{},
class: "#{input_classes} [&_option]:bg-surface-50 [&_option]:text-surface-900" %>
<p class="mt-1.5 font-ui text-xs text-surface-600"><%= t("groups.reading_list.hint") %></p>
<p class="mt-1.5 font-ui text-xs text-surface-600"><%= t("groups.plan.hint") %></p>
</div>

<div class="flex items-center justify-end gap-3">
Expand Down
10 changes: 7 additions & 3 deletions app/views/groups/bible/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@

<header class="space-y-3 border-b border-surface-200 pb-6">
<div class="flex items-center justify-between gap-3">
<p class="font-ui text-xs font-medium uppercase tracking-wider text-surface-500">
<%= @translation.name %>
</p>
<%# On a passage page the translation is named beside the
reference, under the title. %>
<% unless @passage %>
<p class="font-ui text-xs font-medium uppercase tracking-wider text-surface-500">
<%= @translation.name %>
</p>
<% end %>
<% if @passage %>
<% if @appearances.size > 1 %>
<nav aria-label="<%= t("red.parables.told_in") %>" class="passage-tellings flex flex-wrap items-center gap-1 font-ui text-sm">
Expand Down
13 changes: 6 additions & 7 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,14 @@ en:
open_group: Open
focus:
label: What this study reads
bible: The whole Bible
red: Highlighted in Red
hint: A study of Highlighted in Red reads Jesus's words, chapter by chapter, with the story around them dimmed.
plan:
bible: The whole Bible
red: Highlighted in Red, chapter by chapter
hint: Highlighted in Red reads Jesus's words with the story around them dimmed. Pick a list or a theme to read one passage at a time, with a marker for where the study is.
reading_list:
label: Work through a list
none: No list. Read chapter by chapter
lists_group: Lists
themes_group: Themes
hint: Optional. The study reads one passage at a time, and a manager marks where you are. Choosing a list makes this a Highlighted in Red study.
lists_group: One passage at a time
themes_group: A theme, one passage at a time
working_through: "Working through: %{list}"
intro: Read one passage at a time. A manager marks where the study is.
open_current: "Open: %{title}"
Expand Down
13 changes: 6 additions & 7 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,14 @@ es:
open_group: Abierto
focus:
label: Qué lee este estudio
bible: Toda la Biblia
red: En Rojo
hint: Un estudio de En Rojo lee las palabras de Jesús, capítulo por capítulo, con el relato que las rodea atenuado.
plan:
bible: Toda la Biblia
red: En Rojo, capítulo por capítulo
hint: En Rojo lee las palabras de Jesús con el relato que las rodea atenuado. Elige una lista o un tema para leer un pasaje a la vez, con una marca de por dónde va el estudio.
reading_list:
label: Recorrer una lista
none: Sin lista. Leer capítulo por capítulo
lists_group: Listas
themes_group: Temas
hint: Opcional. El estudio lee un pasaje a la vez, y un administrador marca por dónde van. Al elegir una lista, este será un estudio de En Rojo.
lists_group: Un pasaje a la vez
themes_group: Un tema, un pasaje a la vez
working_through: "Recorriendo: %{list}"
intro: Lean un pasaje a la vez. Un administrador marca por dónde va el estudio.
open_current: "Abrir: %{title}"
Expand Down
19 changes: 19 additions & 0 deletions spec/models/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@
expect(group).to be_focus_red
end

it "is chosen through one plan: the whole Bible, red chapters, a list or a theme" do
expect(build(:group).plan).to eq("bible")
expect(build(:group, focus: :red).plan).to eq("red")
expect(build(:group, reading_list: "parables").plan).to eq("parables")

group = create(:group, plan: "theme:forgiveness")
expect([ group.focus, group.reading_list ]).to eq([ "red", "theme:forgiveness" ])

group.update!(plan: "red")
expect([ group.focus, group.reading_list ]).to eq([ "red", nil ])

group.update!(plan: "bible")
expect([ group.focus, group.reading_list ]).to eq([ "bible", nil ])
end

it "rejects a plan that does not exist" do
expect(build(:group, plan: "miracles")).not_to be_valid
end

it "treats a blank list as none" do
expect(create(:group, reading_list: "").reading_list).to be_nil
end
Expand Down
3 changes: 2 additions & 1 deletion spec/requests/study_focus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def verse!(book, chapter_number, number, text, red: nil)

it "is offered when starting a study and saved" do
get "/studies/new"
expect(response.body).to include(I18n.t("groups.focus.red"))
options = Nokogiri::HTML(response.body).css("select[name='group[plan]'] option").map { |o| o[:value] }
expect(options.first(2)).to eq(%w[bible red])

post "/studies", params: { group: { name: "Red letters", privacy: "invite_only", focus: "red" } }
expect(Group.find_by!(name: "Red letters")).to be_focus_red
Expand Down
28 changes: 25 additions & 3 deletions spec/requests/study_reading_lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,32 @@ def verse!(book, chapter_number, number, text, red: true)
end

describe "starting one" do
it "offers the lists and themes on the new-study form" do
it "offers everything a study can read in one control on the new-study form" do
get "/studies/new"

options = Nokogiri::HTML(response.body).css("select[name='group[reading_list]'] option").map { |o| o[:value] }
expect(options).to include("", "parables", "encounters", "sayings", "theme:forgiveness")
page = Nokogiri::HTML(response.body)
options = page.css("select[name='group[plan]'] option").map { |o| o[:value] }
expect(options).to include("bible", "red", "parables", "encounters", "sayings", "theme:forgiveness")
expect(page.at_css("select[name='group[reading_list]']")).to be_nil
expect(page.at_css("input[name='group[focus]']")).to be_nil
end

it "starts a list study from that one control" do
post "/studies", params: { group: { name: "Sayings", privacy: "invite_only", plan: "sayings" } }

group = Group.find_by!(name: "Sayings")
expect([ group.focus, group.reading_list ]).to eq(%w[red sayings])
end

it "shows the study's current choice when editing, and can change it" do
group = create(:group, owner: owner, reading_list: "parables")

get "/studies/#{group.id}/edit"
selected = Nokogiri::HTML(response.body).at_css("select[name='group[plan]'] option[selected]")
expect(selected[:value]).to eq("parables")

patch "/studies/#{group.id}", params: { group: { plan: "red" } }
expect([ group.reload.focus, group.reading_list ]).to eq([ "red", nil ])
end

it "saves the list and makes it a red study" do
Expand Down Expand Up @@ -94,6 +115,7 @@ def verse!(book, chapter_number, number, text, red: true)

expect(response).to have_http_status(:ok)
page = Nokogiri::HTML(response.body)
expect(page.at_css("article header").text.scan(kjv.name).size).to eq(1)
expect(page.at_css("h1").text).to include("The Sower")
expect(page.css(".chapter-body .verse").map { |v| v["data-osis-ref"] })
.to eq((3..9).map { |n| "Bible.KJV.Matt.13.#{n}" })
Expand Down
2 changes: 1 addition & 1 deletion spec/system/study_focus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def verse!(book, chapter_number, number, text, red: nil)
visit "/studies/new"
fill_in "Name", with: "Red letters"
find("input[value='invite_only']").click
choose I18n.t("groups.focus.red")
select I18n.t("groups.plan.red"), from: I18n.t("groups.focus.label")
find('input[type="submit"]').click

expect(page).to have_content(/red letters/i)
Expand Down
2 changes: 1 addition & 1 deletion spec/system/study_reading_lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def verse!(book, chapter_number, number, text, red: true)
visit "/studies/new"
fill_in "Name", with: "Parables together"
find("input[value='invite_only']").click
select I18n.t("red.parables.title"), from: I18n.t("groups.reading_list.label")
select I18n.t("red.parables.title"), from: I18n.t("groups.focus.label")
find('input[type="submit"]').click

expect(page).to have_content(/parables together/i)
Expand Down
Loading