diff --git a/app/views/legislations/show.html.erb b/app/views/legislations/show.html.erb index a1da0a060..2d957d6fa 100644 --- a/app/views/legislations/show.html.erb +++ b/app/views/legislations/show.html.erb @@ -5,6 +5,6 @@ <% end %>
<%= @legislation.title %>
-
<%= @legislation.body %>
+
<%= @legislation.body %>
- \ No newline at end of file + diff --git a/spec/factories.rb b/spec/factories.rb index add33a1fb..61c09373e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,9 +1,4 @@ FactoryGirl.define do - factory :annotation do - quote "MyString" - text "MyText" - end - sequence(:document_number) { |n| "#{n.to_s.rjust(8, '0')}X" } @@ -227,6 +222,18 @@ FactoryGirl.define do end end + factory :legislation do + sequence(:title) { |n| "Legislation #{n}" } + body "In order to achieve this..." + end + + factory :annotation do + quote "ipsum" + text "Loremp ipsum dolor" + legislation + user + end + factory :administrator do user end diff --git a/spec/features/legislation_spec.rb b/spec/features/legislation_spec.rb new file mode 100644 index 000000000..d8df3351e --- /dev/null +++ b/spec/features/legislation_spec.rb @@ -0,0 +1,62 @@ +require 'rails_helper' + +feature 'Legislation' do + + scenario 'Show' do + legislation = create(:legislation, title: 'Change the world', body: 'To achieve this...') + + visit legislation_path(legislation) + + expect(page).to have_content 'Change the world' + expect(page).to have_content 'To achieve this...' + end + + context 'Annotations', :js, :focus do + + scenario 'Create' do + user = create(:user) + legislation = create(:legislation, title: 'Participatory Democracy', body: "In order to achieve...") + + login_as(user) + visit legislation_path(legislation) + + page.find(:css, "#test").double_click + page.find(:css, ".annotator-adder button").click + fill_in 'annotator-field-0', with: 'this is my annotation' + page.find(:css, ".annotator-controls a[href='#save']").click + + within ".annotate" do + expect(page).to have_css ".annotator-hl" + end + + annotation = Annotation.last + within ".annotate" do + expect(page).to have_css ".annotator-hl[data-annotation-id='#{annotation.id}']" + end + + visit legislation_path(legislation) + within ".annotate" do + expect(page).to have_css ".annotator-hl[data-annotation-id='#{annotation.id}']" + end + end + + scenario 'Search' do + user = create(:user) + legislation = create(:legislation, title: 'Participatory Democracy', body: "In order to achieve...") + annotation = create(:annotation, legislation: legislation, text: "this one" , quote: "achieve", ranges: [{"start"=>"/div[2]", "startOffset"=>12, "end"=>"/div[2]", "endOffset"=>19}]) + + login_as(user) + visit legislation_path(legislation) + + within ".annotate" do + expect(page).to have_css ".annotator-hl[data-annotation-id='#{annotation.id}']" + end + end + + scenario 'Update' + scenario 'Destroy' + end + +end + +## Notes logged in and not logged in users \ No newline at end of file