Extract draft version variable to a let block
This way we can reuse the code (in some cases) and we can avoid instance variables (in some other cases).
This commit is contained in:
@@ -142,12 +142,12 @@ describe "Legislation Draft Versions" do
|
||||
|
||||
context "Annotations", :js do
|
||||
let(:user) { create(:user) }
|
||||
let(:draft_version) { create(:legislation_draft_version, :published) }
|
||||
|
||||
before { login_as user }
|
||||
|
||||
scenario "Visit as anonymous" do
|
||||
logout
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
|
||||
@@ -158,8 +158,6 @@ describe "Legislation Draft Versions" do
|
||||
end
|
||||
|
||||
scenario "Create" do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
|
||||
page.find(:css, ".legislation-annotatable").double_click
|
||||
@@ -182,7 +180,6 @@ describe "Legislation Draft Versions" do
|
||||
end
|
||||
|
||||
scenario "View annotations and comments" do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
|
||||
ranges: [{ "start" => "/p[1]", "startOffset" => 5, "end" => "/p[1]", "endOffset" => 10 }])
|
||||
create(:legislation_annotation, draft_version: draft_version, text: "my other annotation",
|
||||
@@ -201,7 +198,6 @@ describe "Legislation Draft Versions" do
|
||||
end
|
||||
|
||||
scenario "Publish new comment for an annotation from comments box" do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
annotation = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
|
||||
ranges: [{ "start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11 }])
|
||||
|
||||
@@ -219,13 +215,12 @@ describe "Legislation Draft Versions" do
|
||||
end
|
||||
|
||||
context "Merged annotations", :js do
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:draft_version) { create(:legislation_draft_version, :published) }
|
||||
|
||||
before { login_as user }
|
||||
|
||||
scenario "View annotations and comments in an included range" do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
|
||||
ranges: [{ "start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5 }])
|
||||
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation",
|
||||
@@ -246,16 +241,17 @@ describe "Legislation Draft Versions" do
|
||||
end
|
||||
|
||||
context "Annotations page" do
|
||||
let(:draft_version) { create(:legislation_draft_version, :published) }
|
||||
|
||||
before do
|
||||
@draft_version = create(:legislation_draft_version, :published)
|
||||
create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum",
|
||||
create(:legislation_annotation, draft_version: draft_version, text: "my annotation", quote: "ipsum",
|
||||
ranges: [{ "start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11 }])
|
||||
create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam",
|
||||
create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", quote: "audiam",
|
||||
ranges: [{ "start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11 }])
|
||||
end
|
||||
|
||||
scenario "See all annotations for a draft version" do
|
||||
visit legislation_process_draft_version_annotations_path(@draft_version.process, @draft_version)
|
||||
visit legislation_process_draft_version_annotations_path(draft_version.process, draft_version)
|
||||
|
||||
expect(page).to have_content "ipsum"
|
||||
expect(page).to have_content "audiam"
|
||||
@@ -298,16 +294,17 @@ describe "Legislation Draft Versions" do
|
||||
end
|
||||
|
||||
context "Annotation comments page" do
|
||||
let(:draft_version) { create(:legislation_draft_version, :published) }
|
||||
|
||||
before do
|
||||
@draft_version = create(:legislation_draft_version, :published)
|
||||
create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum",
|
||||
create(:legislation_annotation, draft_version: draft_version, text: "my annotation", quote: "ipsum",
|
||||
ranges: [{ "start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11 }])
|
||||
@annotation = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam",
|
||||
@annotation = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", quote: "audiam",
|
||||
ranges: [{ "start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11 }])
|
||||
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)
|
||||
visit legislation_process_draft_version_annotation_path(draft_version.process, draft_version, @annotation)
|
||||
|
||||
expect(page).not_to have_content "ipsum"
|
||||
expect(page).not_to have_content "my annotation"
|
||||
|
||||
Reference in New Issue
Block a user