From 5bb831e9595c6d2f7fa55c3eda0676878ccd0617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Tue, 3 Oct 2017 19:11:39 +0200 Subject: [PATCH 1/7] Removed poll question show --- app/controllers/polls/questions_controller.rb | 9 -- app/views/polls/_poll_group.html.erb | 2 +- app/views/polls/questions/_answers.html.erb | 22 ----- app/views/polls/questions/_comments.html.erb | 31 ------- .../polls/questions/_filter_subnav.html.erb | 22 ----- app/views/polls/questions/_question.html.erb | 9 -- app/views/polls/questions/answer.js.erb | 1 - app/views/polls/questions/show.html.erb | 92 ------------------- config/routes.rb | 6 +- 9 files changed, 2 insertions(+), 192 deletions(-) delete mode 100644 app/views/polls/questions/_answers.html.erb delete mode 100644 app/views/polls/questions/_comments.html.erb delete mode 100644 app/views/polls/questions/_filter_subnav.html.erb delete mode 100644 app/views/polls/questions/_question.html.erb delete mode 100644 app/views/polls/questions/answer.js.erb delete mode 100644 app/views/polls/questions/show.html.erb diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index 1849dff97..74266a6fc 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -5,15 +5,6 @@ class Polls::QuestionsController < ApplicationController has_orders %w{most_voted newest oldest}, only: :show - def show - @commentable = @question.proposal.present? ? @question.proposal : @question - @comment_tree = CommentTree.new(@commentable, params[:page], @current_order) - set_comment_flags(@comment_tree.comments) - - question_answer = @question.answers.where(author_id: current_user.try(:id)).first - @answers_by_question_id = {@question.id => question_answer.try(:answer)} - end - def answer answer = @question.answers.find_or_initialize_by(author: current_user) diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index 9372aee17..fe12c341b 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -51,7 +51,7 @@ <%= poll_dates(poll) %> <% end %> diff --git a/app/views/polls/questions/_answers.html.erb b/app/views/polls/questions/_answers.html.erb deleted file mode 100644 index c88156b68..000000000 --- a/app/views/polls/questions/_answers.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
- <% if can? :answer, question %> - <% question.valid_answers.each do |answer| %> - <% if @answers_by_question_id[question.id] == answer %> - "> - <%= answer %> - - <% else %> - <%= link_to answer, - answer_question_path(question, answer: answer), - method: :post, - remote: true, - title: t("poll_questions.show.vote_answer", answer: answer), - class: "button secondary hollow" %> - <% end %> - <% end %> - <% else %> - <% question.valid_answers.each do |answer| %> - <%= answer %> - <% end %> - <% end %> -
diff --git a/app/views/polls/questions/_comments.html.erb b/app/views/polls/questions/_comments.html.erb deleted file mode 100644 index a967406aa..000000000 --- a/app/views/polls/questions/_comments.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<% cache [locale_and_user_status, @current_order, commentable_cache_key(@commentable), @comment_tree.comments, @comment_tree.comment_authors, @commentable.comments_count, @comment_flags] do %> -
-
-
-

- <%= t("shared.comments.title") %> - (<%= @commentable.comments_count %>) -

- - <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> - - <% if user_signed_in? %> - <%= render 'comments/form', {commentable: @commentable, parent_id: nil, toggeable: false} %> - <% else %> -
- -
- <%= t("shared.comments.login_to_comment", - signin: link_to(t("votes.signin"), new_user_session_path), - signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %> -
- <% end %> - - <% @comment_tree.root_comments.each do |comment| %> - <%= render 'comments/comment', comment: comment %> - <% end %> - <%= paginate @comment_tree.root_comments %> -
-
-
-<% end %> \ No newline at end of file diff --git a/app/views/polls/questions/_filter_subnav.html.erb b/app/views/polls/questions/_filter_subnav.html.erb deleted file mode 100644 index 738fc3700..000000000 --- a/app/views/polls/questions/_filter_subnav.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
-
-
    -
  • - <%= link_to "#tab-comments" do %> -

    - <%= t("proposals.show.comments_tab") %> - (<%= @question.comments_count %>) -

    - <% end %> -
  • -
  • - <%= link_to "#tab-documents" do %> -

    - <%= t("documents.tab") %> - (<%= @question.documents.count %>) -

    - <% end %> -
  • -
-
-
diff --git a/app/views/polls/questions/_question.html.erb b/app/views/polls/questions/_question.html.erb deleted file mode 100644 index f0958b6e4..000000000 --- a/app/views/polls/questions/_question.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -
-

- <%= link_to question.title, question_path(question) %> -

- -
- <%= render 'polls/questions/answers', question: question %> -
-
diff --git a/app/views/polls/questions/answer.js.erb b/app/views/polls/questions/answer.js.erb deleted file mode 100644 index aabbd8d89..000000000 --- a/app/views/polls/questions/answer.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#<%= dom_id(@question) %>_answers").html('<%= j render("polls/questions/answers", question: @question) %>'); diff --git a/app/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb deleted file mode 100644 index f67633129..000000000 --- a/app/views/polls/questions/show.html.erb +++ /dev/null @@ -1,92 +0,0 @@ -<% provide :title do %><%= @question.title %><% end %> - -
-
-
- <%= back_link_to %> - -

<%= @question.title %>

- - <% if @question.proposal.present? %> -
- <%= link_to t('poll_questions.show.original_proposal'), @question.proposal %> -
- <% end %> - - <% if can? :answer, @question %> - <%= link_to t('poll_questions.show.answer_this_question'), - @question.poll, - class: 'large button' %> - <% else %> - <%= render 'polls/reasons_for_not_answering', poll: @question.poll %> - <% end %> -
- -
-

- - <%= t('poll_questions.show.author') %> - -
- <% if @question.author_visible_name.present? %> - <%= @question.author_visible_name %> - <% else %> - <%= link_to @question.author.name, @question.author %> - <% end %> - -

- -

- - <%= t('poll_questions.show.poll') %> - -
- <%= link_to @question.poll.name, @question.poll %> -

- -

- - <%= t('poll_questions.show.dates_title') %> - -
- <%= poll_dates(@question.poll) %> -

-
-
-
- -<% if @question.video_url.present? %> -
-
- -
-
- -<% end %> - -
-
-

<%= t('poll_questions.show.more_info') %>

- <%= @question.description %> -
-
- -
- <%= render "polls/questions/filter_subnav" %> - -
- <%= render "polls/questions/comments" %> -
- -
- <%= render 'documents/documents', - documents: @question.documents, - max_documents_allowed: Poll::Question.max_documents_allowed %> -
-
diff --git a/config/routes.rb b/config/routes.rb index 410f2dced..6c893c24a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -112,11 +112,7 @@ Rails.application.routes.draw do get :search, on: :collection end - resources :polls, only: [:show, :index] do - resources :questions, only: [:show], controller: 'polls/questions', shallow: true do - post :answer, on: :member - end - end + resources :polls, only: [:show, :index] namespace :legislation do resources :processes, only: [:index, :show] do From 348e4e54f324ec18f16c93e530fc2267717aa863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Tue, 3 Oct 2017 19:11:54 +0200 Subject: [PATCH 2/7] Removed question description --- app/controllers/admin/poll/questions_controller.rb | 2 +- app/models/poll/question.rb | 7 ------- app/views/admin/poll/questions/_form.html.erb | 6 ------ ...0171003170029_remove_description_from_poll_questions.rb | 5 +++++ db/schema.rb | 3 +-- 5 files changed, 7 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20171003170029_remove_description_from_poll_questions.rb diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 97b301d43..107c06740 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -56,7 +56,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController private def question_params - params.require(:poll_question).permit(:poll_id, :title, :question, :description, :proposal_id, :valid_answers, :video_url, + params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :valid_answers, :video_url, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) end diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index a46f28a8c..55396fd3b 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -23,7 +23,6 @@ class Poll::Question < ActiveRecord::Base validates :poll_id, presence: true validates :title, length: { minimum: 4 } - validates :description, length: { maximum: Poll::Question.description_max_length } scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) } @@ -40,15 +39,10 @@ class Poll::Question < ActiveRecord::Base def searchable_values { title => 'A', proposal.try(:title) => 'A', - description => 'B', author.username => 'C', author_visible_name => 'C' } end - def description - super.try :html_safe - end - def valid_answers (super.try(:split, ',').compact || []).map(&:strip) end @@ -59,7 +53,6 @@ class Poll::Question < ActiveRecord::Base self.author_visible_name = proposal.author.name self.proposal_id = proposal.id self.title = proposal.title - self.description = proposal.description self.valid_answers = I18n.t('poll_questions.default_valid_answers') end end diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 7881936e4..6091c024f 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -20,12 +20,6 @@

<%= t("admin.questions.new.valid_answers_note") %>

<%= f.text_field :valid_answers, label: false, aria: {describedby: "valid-answers-help-text"} %> -
- <%= f.cktext_area :description, - maxlength: Poll::Question.description_max_length, - ckeditor: { language: I18n.locale } %> -
-
<%= render 'documents/nested_documents', documentable: @question, f: f %>
diff --git a/db/migrate/20171003170029_remove_description_from_poll_questions.rb b/db/migrate/20171003170029_remove_description_from_poll_questions.rb new file mode 100644 index 000000000..31e1b9578 --- /dev/null +++ b/db/migrate/20171003170029_remove_description_from_poll_questions.rb @@ -0,0 +1,5 @@ +class RemoveDescriptionFromPollQuestions < ActiveRecord::Migration + def change + remove_column :poll_questions, :description + end +end diff --git a/db/schema.rb b/db/schema.rb index e75c2aac3..9381f8e2c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171003095936) do +ActiveRecord::Schema.define(version: 20171003170029) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -675,7 +675,6 @@ ActiveRecord::Schema.define(version: 20171003095936) do t.string "author_visible_name" t.string "title" t.string "valid_answers" - t.text "description" t.integer "comments_count" t.datetime "hidden_at" t.datetime "created_at" From 9871503c5e8a8bf33088fba5a00e1ca48958a8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Tue, 3 Oct 2017 21:00:40 +0200 Subject: [PATCH 3/7] Restored views --- app/views/admin/poll/questions/show.html.erb | 8 ------- app/views/polls/questions/_answers.html.erb | 22 ++++++++++++++++++++ app/views/polls/questions/_question.html.erb | 9 ++++++++ app/views/polls/questions/answer.js.erb | 1 + config/routes.rb | 6 +++++- 5 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 app/views/polls/questions/_answers.html.erb create mode 100644 app/views/polls/questions/_question.html.erb create mode 100644 app/views/polls/questions/answer.js.erb diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 3f776c5c0..438ee3a40 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -34,12 +34,6 @@ <% end %> -

- <%= t("admin.questions.show.description") %> -
- <%= @question.description %> -

- <% if @question.video_url.present? %>

<%= t("admin.questions.show.video_url") %> @@ -55,7 +49,5 @@ <%= @question.documents.first.title %>

<% end %> - - <%= link_to t("admin.questions.show.preview"), question_path(@question) %> diff --git a/app/views/polls/questions/_answers.html.erb b/app/views/polls/questions/_answers.html.erb new file mode 100644 index 000000000..c88156b68 --- /dev/null +++ b/app/views/polls/questions/_answers.html.erb @@ -0,0 +1,22 @@ +
+ <% if can? :answer, question %> + <% question.valid_answers.each do |answer| %> + <% if @answers_by_question_id[question.id] == answer %> + "> + <%= answer %> + + <% else %> + <%= link_to answer, + answer_question_path(question, answer: answer), + method: :post, + remote: true, + title: t("poll_questions.show.vote_answer", answer: answer), + class: "button secondary hollow" %> + <% end %> + <% end %> + <% else %> + <% question.valid_answers.each do |answer| %> + <%= answer %> + <% end %> + <% end %> +
diff --git a/app/views/polls/questions/_question.html.erb b/app/views/polls/questions/_question.html.erb new file mode 100644 index 000000000..982d0a070 --- /dev/null +++ b/app/views/polls/questions/_question.html.erb @@ -0,0 +1,9 @@ +
+

+ <%= question.title %> +

+ +
+ <%= render 'polls/questions/answers', question: question %> +
+
diff --git a/app/views/polls/questions/answer.js.erb b/app/views/polls/questions/answer.js.erb new file mode 100644 index 000000000..aabbd8d89 --- /dev/null +++ b/app/views/polls/questions/answer.js.erb @@ -0,0 +1 @@ +$("#<%= dom_id(@question) %>_answers").html('<%= j render("polls/questions/answers", question: @question) %>'); diff --git a/config/routes.rb b/config/routes.rb index 6c893c24a..9e7c8d307 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -112,7 +112,11 @@ Rails.application.routes.draw do get :search, on: :collection end - resources :polls, only: [:show, :index] + resources :polls, only: [:show, :index] do + resources :questions, controller: 'polls/questions', shallow: true do + post :answer, on: :member + end + end namespace :legislation do resources :processes, only: [:index, :show] do From 81e9682aa3bc4142436dcc47b9a6dd447ace0c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Tue, 3 Oct 2017 22:30:15 +0200 Subject: [PATCH 4/7] Fixed tests --- spec/factories.rb | 1 - spec/features/polls/questions_spec.rb | 117 -------------------------- 2 files changed, 118 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index c21c35b4e..f311f58d4 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -498,7 +498,6 @@ FactoryGirl.define do poll association :author, factory: :user sequence(:title) { |n| "Question title #{n}" } - sequence(:description) { |n| "Question description #{n}" } valid_answers { Faker::Lorem.words(3).join(', ') } end diff --git a/spec/features/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index 1563ca81a..9e7efeedc 100644 --- a/spec/features/polls/questions_spec.rb +++ b/spec/features/polls/questions_spec.rb @@ -11,121 +11,4 @@ feature 'Poll Questions' do expect(proposal_question.title).to appear_before(normal_question.title) end - - scenario 'shows the author visible name instead of a link to the author' do - poll = create(:poll) - question_with_author = create(:poll_question, poll: poll) - question_with_author_visible_name = create(:poll_question, poll: poll, author_visible_name: 'potato') - - visit question_path(question_with_author) - expect(page).to have_link(question_with_author.author.name) - - visit question_path(question_with_author_visible_name) - expect(page).to_not have_link(question_with_author_visible_name.author.name) - expect(page).to have_content(question_with_author_visible_name.author_visible_name) - end - - scenario '#show view has video_url present' do - poll = create(:poll) - normal_question = create(:poll_question, poll: poll, video_url: "https://puppyvideos.com") - - visit question_path(normal_question) - - expect(page).to have_link(normal_question.video_url) - end - - scenario '#show view has document present' do - poll = create(:poll) - normal_question = create(:poll_question, poll: poll) - document = create(:document, documentable: normal_question) - - visit question_path(normal_question) - - expect(page).to have_content(document.title) - end - - context 'Answering' do - let(:geozone) { create(:geozone) } - let(:poll) { create(:poll, geozone_restricted: true, geozone_ids: [geozone.id]) } - - scenario 'Non-logged in users' do - question = create(:poll_question, valid_answers: 'Han Solo, Chewbacca') - - visit question_path(question) - - expect(page).to have_content('You must Sign in or Sign up to participate') - end - - scenario 'Level 1 users' do - question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca') - - login_as(create(:user, geozone: geozone)) - visit question_path(question) - - expect(page).to have_content('You must verify your account in order to answer') - end - - scenario 'Level 2 users in an poll question for a geozone which is not theirs' do - - other_poll = create(:poll, geozone_restricted: true, geozone_ids: [create(:geozone).id]) - question = create(:poll_question, poll: other_poll, valid_answers: 'Vader, Palpatine') - - login_as(create(:user, :level_two, geozone: geozone)) - visit question_path(question) - - expect(page).to have_content('This question is not available on your geozone') - end - - scenario 'Level 2 users who can answer' do - question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca') - - login_as(create(:user, :level_two, geozone: geozone)) - visit question_path(question) - - expect(page).to have_link('Answer this question') - end - - scenario 'Level 2 users who have already answered' do - question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca') - - user = create(:user, :level_two, geozone: geozone) - create(:poll_answer, question: question, author: user, answer: 'Chewbacca') - - login_as user - visit question_path(question) - - expect(page).to have_link('Answer this question') - end - - scenario 'Level 2 users answering', :js do - question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca') - user = create(:user, :level_two, geozone: geozone) - - login_as user - visit question_path(question) - - expect(page).to have_link('Answer this question') - end - - scenario 'Records participation', :js do - question = create(:poll_question, poll: poll, valid_answers: 'Han Solo, Chewbacca') - user = create(:user, :level_two, geozone: geozone, gender: 'female', date_of_birth: 33.years.ago) - - login_as user - visit question_path(question) - - click_link 'Answer this question' - click_link 'Han Solo' - - expect(page).to_not have_link('Han Solo') - - voter = poll.voters.first - expect(voter.document_number).to eq(user.document_number) - expect(voter.geozone_id).to eq(user.geozone_id) - expect(voter.gender).to eq(user.gender) - expect(voter.age).to eq(33) - expect(voter.poll_id).to eq(poll.id) - end - - end end From bdfe822ddf2b27631ab40df8a339c17fbdc0f9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Tue, 3 Oct 2017 23:05:06 +0200 Subject: [PATCH 5/7] Removed unused translations --- config/locales/en/admin.yml | 1 - config/locales/en/general.yml | 9 --------- config/locales/es/admin.yml | 1 - config/locales/es/general.yml | 9 --------- 4 files changed, 20 deletions(-) diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index a3751615a..c4694b310 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -593,7 +593,6 @@ en: author: Author title: Title valid_answers: Valid answers - description: Description video_url: External video documents: Documents (1) recounts: diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index ff8a77014..fbaa3e4d0 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -494,11 +494,6 @@ en: create_question: "Create question" default_valid_answers: "Yes, No" show: - answer_this_question: "Go to voting page" - original_proposal: "Original proposal" - author: "Created by" - dates_title: "Participation dates" - more_info: "More information" not_logged_in: "You must %{signin} or %{signup} to participate." signin: Sign in signup: Sign up @@ -509,7 +504,6 @@ en: cant_answer_wrong_geozone: "This question is not available on your geozone." vote_answer: "Vote %{answer}" voted: "You have voted %{answer}" - poll: "Poll" proposal_notifications: new: title: "Send message" @@ -524,9 +518,6 @@ en: edit: 'Edit' save: 'Save' delete: 'Delete' - comments: - title: 'Comments' - login_to_comment: 'You must %{signin} or %{signup} to leave a comment.' "yes": "Yes" "no": "No" search_results: "Search results" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index f95c2d39f..c1c2cbf9d 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -593,7 +593,6 @@ es: author: Autor title: Título valid_answers: Respuestas válidas - description: Descripción video_url: Video externo documents: Documentos (1) recounts: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index aaa59a900..898826c0e 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -494,11 +494,6 @@ es: create_question: "Crear pregunta para votación" default_valid_answers: "Sí, No" show: - answer_this_question: "Responder a esta pregunta" - original_proposal: "Propuesta original" - author: "Creado por" - dates_title: "Fechas de participación" - more_info: "Más información" not_logged_in: "Necesitas %{signin} o %{signup} para participar." signin: iniciar sesión signup: registrarte @@ -509,7 +504,6 @@ es: cant_answer_wrong_geozone: "Esta votación no está disponible en tu zona." vote_answer: "Votar %{answer}" voted: "Has votado %{answer}" - poll: "Votación" proposal_notifications: new: title: "Enviar mensaje" @@ -524,9 +518,6 @@ es: edit: 'Editar' save: 'Guardar' delete: 'Borrar' - comments: - title: 'Comentarios' - login_to_comment: 'Necesitas %{signin} o %{signup} para comentar.' "yes": "Sí" "no": "No" search_results: "Resultados de búsqueda" From 8dc05d399b9ba1343ef5efbe8e111cf7453866d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 4 Oct 2017 10:03:44 +0200 Subject: [PATCH 6/7] Fixed tests --- spec/features/admin/poll/questions_spec.rb | 5 ----- spec/shared/features/nested_documentable.rb | 1 - 2 files changed, 6 deletions(-) diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index ca3706a24..52e3783f0 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -24,7 +24,6 @@ feature 'Admin poll questions' do visit admin_question_path(question) expect(page).to have_content(question.title) - expect(page).to have_content(question.description) expect(page).to have_content(question.author.name) expect(page).to have_content(question.valid_answers.join(" ")) end @@ -45,13 +44,11 @@ feature 'Admin poll questions' do select 'Movies', from: 'poll_question_poll_id' fill_in 'poll_question_title', with: title - fill_in 'poll_question_description', with: description fill_in 'poll_question_video_url', with: video_url click_button 'Save' expect(page).to have_content(title) - expect(page).to have_content(description) expect(page).to have_content(video_url) end @@ -64,7 +61,6 @@ feature 'Admin poll questions' do expect(current_path).to eq(new_admin_question_path) expect(page).to have_field('poll_question_title', with: proposal.title) - expect(page).to have_field('poll_question_description', with: proposal.description) expect(page).to have_field('poll_question_valid_answers', with: "Yes, No") select 'Proposals', from: 'poll_question_poll_id' @@ -72,7 +68,6 @@ feature 'Admin poll questions' do click_button 'Save' expect(page).to have_content(proposal.title) - expect(page).to have_content(proposal.description) expect(page).to have_link(proposal.title, href: proposal_path(proposal)) expect(page).to have_link(proposal.author.name, href: user_path(proposal.author)) end diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 10a2c9fbf..8780936a7 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -322,5 +322,4 @@ end def documentable_fill_new_valid_poll_question page.select documentable.poll.name, from: 'poll_question_poll_id' fill_in 'poll_question_title', with: "Star Wars: Episode IV - A New Hope" - fill_in_ckeditor "poll_question_description", with: "Description" end From 5b7a90221aab7ed780fa09c7531c83bbaf077ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Checa?= Date: Wed, 4 Oct 2017 11:18:09 +0200 Subject: [PATCH 7/7] Fixed tests --- spec/features/polls/voter_spec.rb | 15 +++++++-------- spec/support/common_actions.rb | 11 ++++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/features/polls/voter_spec.rb b/spec/features/polls/voter_spec.rb index c12a9f0e4..d925d3394 100644 --- a/spec/features/polls/voter_spec.rb +++ b/spec/features/polls/voter_spec.rb @@ -10,12 +10,13 @@ feature "Voter" do user = create(:user, :level_two) login_as user - visit question_path(question) + visit poll_path(poll) - click_link 'Go to voting page' - click_link 'Yes' + within("#poll_question_#{question.id}_answers") do + click_link 'Yes' + expect(page).to_not have_link('Yes') + end - expect(page).to_not have_link('Yes') expect(Poll::Voter.count).to eq(1) expect(Poll::Voter.first.origin).to eq("web") end @@ -56,7 +57,7 @@ feature "Voter" do scenario "Trying to vote in web and then in booth", :js do login_as user - vote_for_poll_via_web + vote_for_poll_via_web(poll, question) click_link "Sign out" @@ -79,9 +80,7 @@ feature "Voter" do click_link "Sign out" login_as user - visit question_path(question) - - click_link 'Go to voting page' + visit poll_path(poll) expect(page).to_not have_link('Yes') expect(page).to have_content "You have already participated in a booth for this poll." diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index eda55986f..256b070e4 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -298,13 +298,14 @@ module CommonActions end end - def vote_for_poll_via_web - visit question_path(question) + def vote_for_poll_via_web(poll, question) + visit poll_path(poll) - click_link 'Go to voting page' - click_link 'Yes' + within("#poll_question_#{question.id}_answers") do + click_link 'Yes' + expect(page).to_not have_link('Yes') + end - expect(page).to_not have_link('Yes') expect(Poll::Voter.count).to eq(1) end