diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb
index 466b6a5ba..b71e1f7d5 100644
--- a/app/models/abilities/everyone.rb
+++ b/app/models/abilities/everyone.rb
@@ -12,7 +12,7 @@ module Abilities
can [:search, :read], Annotation
can :new, DirectMessage
can [:read, :draft_publication, :allegations, :final_version_publication], Legislation::Process
- can [:read], Legislation::DraftVersion
+ can [:read, :changes, :go_to_version], Legislation::DraftVersion
can [:read], Legislation::Question
can [:create], Legislation::Answer
end
diff --git a/app/views/legislation/draft_versions/show.html.erb b/app/views/legislation/draft_versions/show.html.erb
index 32554cf28..14a7cc1f3 100644
--- a/app/views/legislation/draft_versions/show.html.erb
+++ b/app/views/legislation/draft_versions/show.html.erb
@@ -27,12 +27,12 @@
- <%= t('.text_index') %>
+ <%= t('.text_toc') %>
- <%= t('.text_index') %>
+ <%= t('.text_toc') %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 6328a2e20..8fa1cf13f 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -235,7 +235,7 @@ en:
updated_at: updated at %{date}
see_changes: see changes summary
see_comments: See all comments
- text_index: Index
+ text_toc: Table of contents
text_body: Text
text_comments: Comments
processes:
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 8427146cc..a93d44d2e 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -235,7 +235,7 @@ es:
updated_at: actualizada el %{date}
see_changes: ver resumen de cambios
see_comments: Ver todos los comentarios
- text_index: Índice
+ text_toc: Índice
text_body: Texto
text_comments: Comentarios
processes:
diff --git a/spec/features/legislation/draft_versions_spec.rb b/spec/features/legislation/draft_versions_spec.rb
new file mode 100644
index 000000000..6414593e6
--- /dev/null
+++ b/spec/features/legislation/draft_versions_spec.rb
@@ -0,0 +1,75 @@
+require 'rails_helper'
+
+feature 'Legislation Draft Versions' do
+
+ context "See draft text page" do
+ before(:each) do
+ @process = create(:legislation_process)
+ @draft_version_1 = create(:legislation_draft_version, process: @process, title: "Version 1", body: "Body of the first version")
+ @draft_version_2 = create(:legislation_draft_version, process: @process, title: "Version 2", body: "Body of the second version")
+ end
+
+ it "shows the text body for this version" do
+ visit legislation_process_draft_version_path(@process, @draft_version_1)
+
+ expect(page).to have_content("Body of the first version")
+ end
+
+ it "switches to another version without js" do
+ visit legislation_process_draft_version_path(@process, @draft_version_1)
+ expect(page).to have_content("Body of the first version")
+
+ select("Version 2")
+ click_button "see"
+
+ expect(page).to_not have_content("Body of the first version")
+ expect(page).to have_content("Body of the second version")
+ end
+
+ it "switches to another version with js", :js do
+ visit legislation_process_draft_version_path(@process, @draft_version_1)
+ expect(page).to have_content("Body of the first version")
+
+ select("Version 2")
+
+ expect(page).to_not have_content("Body of the first version")
+ expect(page).to have_content("Body of the second version")
+ end
+ end
+
+ context "See changes page" do
+ before(:each) do
+ @process = create(:legislation_process)
+ @draft_version_1 = create(:legislation_draft_version, process: @process, title: "Version 1", body: "Body of the first version", changelog: "Changes for first version")
+ @draft_version_2 = create(:legislation_draft_version, process: @process, title: "Version 2", body: "Body of the second version", changelog: "Changes for second version")
+ end
+
+ it "shows the text body for this version" do
+ visit legislation_process_draft_version_changes_path(@process, @draft_version_1)
+
+ expect(page).to have_content("Changes for first version")
+ end
+
+ it "switches to another version without js" do
+ visit legislation_process_draft_version_changes_path(@process, @draft_version_1)
+ expect(page).to have_content("Changes for first version")
+
+ select("Version 2")
+ click_button "see"
+
+ expect(page).to_not have_content("Changes for first version")
+ expect(page).to have_content("Changes for second version")
+ end
+
+ it "switches to another version with js", :js do
+ visit legislation_process_draft_version_changes_path(@process, @draft_version_1)
+ expect(page).to have_content("Changes for first version")
+
+ select("Version 2")
+
+ expect(page).to_not have_content("Changes for first version")
+ expect(page).to have_content("Changes for second version")
+ end
+ end
+
+end