From a56898fed7423e18b5347b8ee164718de1bdf447 Mon Sep 17 00:00:00 2001 From: Amaia Castro Date: Wed, 11 Jan 2017 20:14:20 +0100 Subject: [PATCH] Fix version chooser for annotations page --- .../legislation/annotations_controller.rb | 1 + .../legislation/draft_versions_controller.rb | 2 + .../legislation/draft_versions_spec.rb | 40 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/app/controllers/legislation/annotations_controller.rb b/app/controllers/legislation/annotations_controller.rb index ee63574f5..ff4ecf813 100644 --- a/app/controllers/legislation/annotations_controller.rb +++ b/app/controllers/legislation/annotations_controller.rb @@ -10,6 +10,7 @@ class Legislation::AnnotationsController < ApplicationController has_orders %w{most_voted newest oldest}, only: :show def index + @annotations = @draft_version.annotations end def show diff --git a/app/controllers/legislation/draft_versions_controller.rb b/app/controllers/legislation/draft_versions_controller.rb index 0b6af46a6..cdac2c9d5 100644 --- a/app/controllers/legislation/draft_versions_controller.rb +++ b/app/controllers/legislation/draft_versions_controller.rb @@ -20,6 +20,8 @@ class Legislation::DraftVersionsController < Legislation::BaseController if params[:redirect_action] == 'changes' redirect_to legislation_process_draft_version_changes_path(@process, version) + elsif params[:redirect_action] == 'annotations' + redirect_to legislation_process_draft_version_annotations_path(@process, version) else redirect_to legislation_process_draft_version_path(@process, version) end diff --git a/spec/features/legislation/draft_versions_spec.rb b/spec/features/legislation/draft_versions_spec.rb index cd655ae4a..6c39d11ce 100644 --- a/spec/features/legislation/draft_versions_spec.rb +++ b/spec/features/legislation/draft_versions_spec.rb @@ -178,6 +178,7 @@ feature 'Legislation Draft Versions' do @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "first quote") @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "second quote") end + scenario "See all annotations for a draft version" do visit legislation_process_draft_version_annotations_path(@draft_version.process, @draft_version) @@ -185,6 +186,45 @@ feature 'Legislation Draft Versions' do expect(page).to have_content "second quote" end + context "switching versions" do + background do + @process = create(:legislation_process) + @draft_version_1 = create(:legislation_draft_version, :published, process: @process, title: "Version 1", body: Faker::Lorem.paragraph) + @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_1, text: "annotation for version 1", quote: "quote for version 1") + @draft_version_2 = create(:legislation_draft_version, :published, process: @process, title: "Version 2", body: Faker::Lorem.paragraph) + @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_2, text: "annotation for version 2", quote: "quote for version 2") + end + + scenario "without js" do + visit legislation_process_draft_version_annotations_path(@process, @draft_version_1) + expect(page).to have_content("quote for version 1") + + select("Version 2") + click_button "see" + + expect(page).to_not have_content("quote for version 1") + expect(page).to have_content("quote for version 2") + end + + scenario "with js", :js do + visit legislation_process_draft_version_annotations_path(@process, @draft_version_1) + expect(page).to have_content("quote for version 1") + + select("Version 2") + + expect(page).to_not have_content("quote for version 1") + expect(page).to have_content("quote for version 2") + end + end + end + + context "Annotation comments page" do + background do + @draft_version = create(:legislation_draft_version, :published, body: Faker::Lorem.paragraph) + @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "first quote") + @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "second quote") + end + scenario "See one annotation with replies for a draft version" do visit legislation_process_draft_version_annotation_path(@draft_version.process, @draft_version, @annotation_2)