Skip to content

Commit

Permalink
migrate calendar feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lrbalt committed Mar 1, 2012
1 parent e9c9e79 commit 600f110
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 223 deletions.
2 changes: 1 addition & 1 deletion app/views/todos/_todo.html.erb
Expand Up @@ -12,7 +12,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<%= remote_toggle_checkbox(todo) %>
<%= remote_edit_button(todo) unless suppress_edit_button %>
<ul class="sf-menu sf-item-menu">
<li style="z-index:<%=@z_index_counter%>"><%= image_tag "downarrow.png", :alt=> "" %>
<li style="z-index:<%=@z_index_counter%>"><%= image_tag "downarrow.png", :id => "todo-submenu", :alt=> "" %>
<ul id="ul<%= dom_id(todo) %>">
<li><%= remote_delete_menu_item(todo) %></li>
<% unless todo.completed? || todo.deferred? -%>
Expand Down
7 changes: 2 additions & 5 deletions config/database.yml.tmpl
Expand Up @@ -6,7 +6,7 @@ development:
# encoding: utf8
host: localhost
username: root
password:
password:

test: &TEST
adapter: sqlite3
Expand All @@ -20,10 +20,7 @@ production:
# encoding: utf8
host: localhost
username: root
password:
password:

cucumber:
<<: *TEST

selenium:
<<: *TEST
1 change: 0 additions & 1 deletion config/environments/cucumber.rb
Expand Up @@ -21,7 +21,6 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

# Unique cookies
# Unique cookies and use cookies for session
config.action_controller.session_store = :cookie_store
config.action_controller.session = { :key => 'TracksCucumber', :secret => SITE_CONFIG['salt'] * (30.0 / SITE_CONFIG['salt'].length).ceil }
26 changes: 0 additions & 26 deletions config/environments/selenium.rb

This file was deleted.

107 changes: 0 additions & 107 deletions config/initializers/mongrel_workaround.rb

This file was deleted.

55 changes: 28 additions & 27 deletions features/calendar.feature
Expand Up @@ -10,48 +10,49 @@ Feature: Show all due actions in a calendar view
And I have logged in as "testuser" with password "secret"
And I have a context called "@calendar"

@selenium
@javascript
Scenario: Setting due date of a todo will show it in the calendar
When I submit a new action with description "a new next action" in the context "@calendar"
When I submit a new action with description "something new" in the context "@calendar"
And I go to the calendar page
Then the badge should show 0
And I should not see "a new next action"
And I should not see "something new"
When I go to the home page
And I edit the due date of "a new next action" to tomorrow
Then I should see "something new"
When I edit the due date of "something new" to tomorrow
And I go to the calendar page
Then the badge should show 1
And I should see "a new next action"
Then I should see "something new"
And the badge should show 1

@selenium
@javascript
Scenario: Clearing the due date of a todo will remove it from the calendar
When I go to the home page
And I submit a new action with description "a new next action" in the context "@calendar"
And I edit the due date of "a new next action" to tomorrow
And I submit a new action with description "something new" in the context "@calendar"
And I edit the due date of "something new" to tomorrow
And I go to the calendar page
Then I should see "a new next action"
When I clear the due date of "a new next action"
Then I should not see "a new next action"
Then I should see "something new"
When I clear the due date of "something new"
Then I should not see "something new"

@selenium
@javascript
Scenario: Marking a todo complete will remove it from the calendar
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
Given I have a todo "something new" in the context "@calendar" which is due tomorrow
When I go to the calendar page
Then I should see "a new next action"
When I clear the due date of "a new next action"
Then I should not see "a new next action"
Then I should see "something new"
When I clear the due date of "something new"
Then I should not see "something new"

@selenium
@javascript
Scenario: Deleting a todo will remove it from the calendar
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
Given I have a todo "something new" in the context "@calendar" which is due tomorrow
When I go to the calendar page
Then I should see "a new next action"
When I delete the action "a new next action"
Then I should not see "a new next action"
Then I should see "something new"
When I delete the action "something new"
Then I should not see "something new"

@selenium
@javascript
Scenario: Changing due date of a todo will move it in the calendar
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
Given I have a todo "something new" in the context "@calendar" which is due tomorrow
When I go to the calendar page
Then I should see "a new next action"
When I edit the due date of "a new next action" to next month
Then I should see "a new next action" in the due next month container
Then I should see "something new"
When I edit the due date of "something new" to next month
Then I should see "something new" in the due next month container
6 changes: 2 additions & 4 deletions features/step_definitions/container_steps.rb
Expand Up @@ -193,10 +193,8 @@
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil

xpath = "//div[@id='due_after_this_month']//div[@id='line_todo_#{todo.id}']"

wait_for :timeout => 5 do
selenium.is_element_present(xpath)
within "div#due_after_this_month" do
find("div#line_todo_#{todo.id}").should_not be_nil
end
end

Expand Down
13 changes: 1 addition & 12 deletions features/step_definitions/generic_steps.rb
Expand Up @@ -11,18 +11,7 @@
end

Then /the badge should show (.*)/ do |number|
badge = -1
xpath= "//span[@id='badge_count']"

if response.respond_to? :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

badge = find("span#badge_count").text.to_i
badge.should == number.to_i
end

Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/login_steps.rb
Expand Up @@ -6,7 +6,7 @@
click_button "Sign in »"

logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
response.should contain(logout_regexp)
page.should have_content(logout_regexp)
@current_user = User.find_by_login(username)
end

Expand Down
7 changes: 6 additions & 1 deletion features/step_definitions/todo_edit_steps.rb
Expand Up @@ -117,7 +117,12 @@
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
open_edit_form_for(todo)
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='due_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
within "div#edit_todo_#{todo.id}" do
find("a#due_x_todo_#{todo.id}").click
wait_until do
find("input#due_todo_#{todo.id}").value == ""
end
end
submit_edit_todo_form(todo)
end

Expand Down
10 changes: 4 additions & 6 deletions features/step_definitions/todo_steps.rb
Expand Up @@ -4,13 +4,11 @@
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil

delete_todo_button = "xpath=//a[@id='delete_todo_#{todo.id}']/img"
selenium.click delete_todo_button
selenium.get_confirmation.should == "Are you sure that you want to delete the action '#{todo.description}'?"

wait_for :timeout => 5 do
!selenium.is_element_present("//div[@id='line_todo_#{todo.id}']")
handle_js_confirm do
open_submenu_for(todo)
find("a#delete_todo_#{todo.id}").click
end
get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?"
end

When /^I delete the todo "([^"]*)"$/ do |action_description|
Expand Down
3 changes: 3 additions & 0 deletions features/support/env.rb
Expand Up @@ -18,6 +18,8 @@
require 'capybara/session'
# BUG in this version of cucumber/capybara: require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript

Capybara.default_wait_time = 5

# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
Expand Down Expand Up @@ -48,6 +50,7 @@
# subsequent scenarios. If you do this, we recommend you create a Before
# block that will explicitly put your database in a known state.
Cucumber::Rails::World.use_transactional_fixtures = true

# How to clean your database when transactions are turned off. See
# http://github.com/bmabey/database_cleaner for more info.
if defined?(ActiveRecord::Base)
Expand Down
19 changes: 0 additions & 19 deletions features/support/selenium.rb

This file was deleted.

0 comments on commit 600f110

Please sign in to comment.