get all selenium features to run and fix the badge update for notes

This commit is contained in:
Reinier Balt 2010-02-06 22:36:13 +01:00
parent c9566047fc
commit e1c693dfdc
4 changed files with 21 additions and 71 deletions

View file

@ -6,17 +6,12 @@
<div class="note_footer"> <div class="note_footer">
<%= link_to_remote( <%= link_to_remote(
image_tag("blank.png", image_tag("blank.png", :title =>"Delete this note", :class=>"delete_item", :id => "delete_note_"+note.id.to_s),
:title =>"Delete this note", :url => note_path(note),
:class=>"delete_item", :html => {:class => 'delete_note', :title => "delete note"},
:id => "delete_note_"+note.id.to_s),
{:update => dom_id(note),
:loading => visual_effect(:fade, dom_id(note, 'container')),
:complete => "$('#{dom_id(note, 'container')}').remove();",
:url => note_path(note),
:method => :delete, :method => :delete,
:confirm => "Are you sure that you want to delete the note \'#{note.id.to_s}\'?" }, :confirm => "Are you sure that you want to delete the note \'#{note.id.to_s}\'?",
{ :class => 'delete_note', :title => "delete note" }) -%>&nbsp; :before => visual_effect(:fade, dom_id(note, 'container'))) -%>&nbsp;
<%= link_to_function(image_tag( "blank.png", :title => "Edit item", :class=>"edit_item"), <%= link_to_function(image_tag( "blank.png", :title => "Edit item", :class=>"edit_item"),
"$('##{dom_id(note)}').toggle(); $('##{dom_id(note, 'edit')}').show(); $('##{dom_id(note, 'edit_form')} textarea').focus();" ) + " | " %> "$('##{dom_id(note)}').toggle(); $('##{dom_id(note, 'edit')}').show(); $('##{dom_id(note, 'edit_form')} textarea').focus();" ) + " | " %>
<%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %>&nbsp;|&nbsp; <%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %>&nbsp;|&nbsp;
@ -38,3 +33,4 @@
</div> </div>
</div> </div>
<% note = nil -%> <% note = nil -%>

View file

@ -37,10 +37,3 @@ Feature: View, add, remove notes
When I visit the "Pass Final Exam" project When I visit the "Pass Final Exam" project
And I click the icon next to the note And I click the icon next to the note
Then I should see the note text Then I should see the note text
@selenium
Scenario: Toggle notes
Given I have two projects with one note each
When I go to the notes page
And I click Toggle Notes
Then I should see the body of the notes

View file

@ -1,8 +1,16 @@
Then /the badge should show (.*)/ do |number| Then /the badge should show (.*)/ do |number|
# puts response.body.inspect # puts response.body.inspect
badge = -1 badge = -1
response.should have_xpath("//span[@id='badge_count']") do |node| xpath= "//span[@id='badge_count']"
badge = node.first.content.to_i
if Rails.env == 'selenium'
response.should have_xpath(xpath)
badge = response.selenium.get_text("xpath=#{xpath}").to_i
else
response.should have_xpath(xpath) do |node|
badge = node.first.content.to_i
end
end end
badge.should == number.to_i badge.should == number.to_i
end end

View file

@ -38,8 +38,8 @@ end
Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num| Given /^I have a project "([^\"]*)" with (.*) notes?$/ do |project_name, num|
project = @current_user.projects.create!(:name => project_name) project = @current_user.projects.create!(:name => project_name)
0.upto num.to_i do |i| 1.upto num.to_i do |i|
project.notes.create!(:user_id => @current_user.id, :body => "A note #{i+1}") project.notes.create!(:user_id => @current_user.id, :body => "A note #{i}. This is the very long body of note #{i} where you should not see the last part of the note after 50 characters")
end end
end end
@ -49,61 +49,14 @@ When /^I delete the first note$/ do
end end
Then /^the first note should disappear$/ do Then /^the first note should disappear$/ do
# the first note contains "A note 1" # the first note contains "A note 1", generated by the Given def above
Then "I should not see \"A note 1\"" Then "I should not see \"A note 1\""
end end
Given /^I have one project "([^\"]*)" with 1 note$/ do |arg1|
pending
end
When /^I click the icon next to the note$/ do When /^I click the icon next to the note$/ do
# need selenium for this to check on the js click_link "Show note"
pending
end end
Then /^I should see the note text$/ do Then /^I should see the note text$/ do
# need selenium for this to check on the js Then "I should see \"after 50 characters\""
pending
end
Then /^I should see the body of the notes$/ do
pending
end
#------ left over from old stories. can be removed if pending stuff is done
When "Luis adds a note from the Pass Final Exam project page" do
When "Luis visits the Pass Final Exam project page"
clicks_link 'Add a note', :wait => :ajax
fills_in 'new_note_body', :with => 'new exam note'
clicks_button 'Add note', :wait => :ajax
end
When "Luis deletes the first note" do
selenium.click "css=a.delete_note"
selenium.get_confirmation.should =~ /delete/
end
When "clicks the icon next to the note" do
selenium.click "css=a.link_to_notes"
wait_for_page_to_load
end
When "Luis clicks Toggle Notes" do
clicks_link 'Toggle notes', :wait => :effects
end
Then "Luis should see the note on the Pass Final Exam project page" do
should_see "new exam note"
end
Then "Luis should see the note on the notes page" do
visits '/notes'
should_see "new exam note"
end
Then "he should see the note text" do
should_see 'exam note 1'
end end