Skip to content

Commit

Permalink
Merge 3aac392 into c1d70ef
Browse files Browse the repository at this point in the history
  • Loading branch information
decabeza committed Feb 22, 2023
2 parents c1d70ef + 3aac392 commit 253f4fc
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 13 deletions.
12 changes: 7 additions & 5 deletions app/assets/stylesheets/legislation_process.scss
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,15 @@
margin-bottom: 0;
text-transform: uppercase;
}
}

h4 a {
@include brand-color;
a {
@include brand-color;
font-size: rem-calc(18);
font-weight: 700;

&:hover {
text-decoration: none;
&:hover {
text-decoration: none;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions app/models/legislation/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Legislation::Question < ApplicationRecord
include Notifiable

translates :title, touch: true
translates :description, touch: true
include Globalizable

belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :legislation_questions
Expand Down
6 changes: 5 additions & 1 deletion app/views/admin/legislation/questions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<div class="row">
<%= f.translatable_fields do |translations_form| %>
<div class="small-12 medium-9 column end">
<%= translations_form.text_area :title, rows: 5 %>
<%= translations_form.text_field :title %>
</div>

<div class="small-12 medium-9 column end">
<%= translations_form.text_area :description, class: "html-area admin" %>
</div>
<% end %>
</div>
Expand Down
7 changes: 4 additions & 3 deletions app/views/legislation/questions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="small-12 medium-9 column">
<div class="quiz-title">
<p class="quiz-header-title"><%= t("legislation.questions.show.title") %></p>
<h4><%= link_to @process.title, @process %></h4>
<%= link_to @process.title, @process %>
</div>
</div>
<div class="small-12 medium-3 column">
Expand All @@ -28,15 +28,16 @@
</div>
<div class="row">
<div class="small-12 medium-9 column">
<h3 class="quiz-question"><%= @question.title %></h3>
<h1 class="quiz-question"><%= @question.title %></h1>
<%= AdminWYSIWYGSanitizer.new.sanitize(@question.description) %>
<div class="debate-questions" id="legislation-answer-form">
<%= render "answer_form", process: @process, question: @question, answer: @answer %>
</div>
</div>

<aside class="small-12 medium-3 column">
<div id="social-share" class="sidebar-divider"></div>
<h3><%= t("legislation.questions.show.share") %></h3>
<h2><%= t("legislation.questions.show.share") %></h2>
<%= render "/shared/social_share", title: @question.title, url: legislation_process_question_url(@question.process, @question) %>
</aside>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDescriptionToLegislationQuestionTranslations < ActiveRecord::Migration[6.0]
def change
add_column :legislation_question_translations, :description, :text
end
end
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@
t.datetime "updated_at", null: false
t.text "title"
t.datetime "hidden_at"
t.text "description"
t.index ["hidden_at"], name: "index_legislation_question_translations_on_hidden_at"
t.index ["legislation_question_id"], name: "index_d34cc1e1fe6d5162210c41ce56533c5afabcdbd3"
t.index ["locale"], name: "index_legislation_question_translations_on_locale"
Expand Down
5 changes: 4 additions & 1 deletion spec/system/admin/legislation/questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
click_link "Create question"

fill_in "Question", with: "Question 3"
fill_in_ckeditor "Description", with: "A little description about question 3"
click_button "Create question"

expect(page).to have_content "Question 3"
Expand All @@ -40,7 +41,7 @@

context "Update" do
scenario "Valid legislation question" do
create(:legislation_question, title: "Question 2", process: process)
create(:legislation_question, title: "Question 2", description: "Description 2", process: process)

visit admin_root_path

Expand All @@ -57,9 +58,11 @@
click_link "Question 2"

fill_in "Question", with: "Question 2b"
fill_in_ckeditor "Description", with: "Description 2b"
click_button "Save changes"

expect(page).to have_content "Question 2b"
expect(page).to have_ckeditor "Description", with: "Description 2b"
end
end

Expand Down
13 changes: 10 additions & 3 deletions spec/system/legislation/questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
end

before do
create(:legislation_question, process: process, title: "Question 1")
create(:legislation_question, process: process, title: "Question 2")
create(:legislation_question, process: process, title: "Question 3")
create(:legislation_question, process: process, title: "Question 1", description: "Description 1")
create(:legislation_question, process: process, title: "Question 2", description: "Description 2")
create(:legislation_question, process: process, title: "Question 3", description: "Description 3")
end

scenario "shows question list" do
Expand All @@ -24,40 +24,47 @@
click_link "Question 1"

expect(page).to have_content("Question 1")
expect(page).to have_content("Description 1")
expect(page).to have_content("NEXT QUESTION")

click_link "Next question"

expect(page).to have_content("Question 2")
expect(page).to have_content("Description 2")
expect(page).to have_content("NEXT QUESTION")

click_link "Next question"

expect(page).to have_content("Question 3")
expect(page).to have_content("Description 3")
expect(page).not_to have_content("NEXT QUESTION")
end

scenario "shows question page" do
visit legislation_process_question_path(process, process.questions.first)

expect(page).to have_content("Question 1")
expect(page).to have_content("Description 1")
expect(page).to have_content("Open answers (0)")
end

scenario "shows next question link in question page" do
visit legislation_process_question_path(process, process.questions.first)

expect(page).to have_content("Question 1")
expect(page).to have_content("Description 1")
expect(page).to have_content("NEXT QUESTION")

click_link "Next question"

expect(page).to have_content("Question 2")
expect(page).to have_content("Description 2")
expect(page).to have_content("NEXT QUESTION")

click_link "Next question"

expect(page).to have_content("Question 3")
expect(page).to have_content("Description 3")
expect(page).not_to have_content("NEXT QUESTION")
end

Expand Down

0 comments on commit 253f4fc

Please sign in to comment.