adds search and create specs

This commit is contained in:
rgarcia
2015-12-15 17:46:37 +01:00
parent 60d6f1c41b
commit 1702426414
3 changed files with 76 additions and 7 deletions

View File

@@ -5,6 +5,6 @@
<% end %>
<div><%= @legislation.title %></div>
<div><%= @legislation.body %></div>
<div id="test"><%= @legislation.body %></div>
</section>
</section>

View File

@@ -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

View File

@@ -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