mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 02:00:12 +01:00
migrate selenium for users to cucumber
This commit is contained in:
parent
06ac3067d3
commit
0d7980e87b
8 changed files with 74 additions and 30 deletions
|
|
@ -54,7 +54,7 @@ class LoginController < ApplicationController
|
||||||
end
|
end
|
||||||
when :get
|
when :get
|
||||||
if User.no_users_yet?
|
if User.no_users_yet?
|
||||||
redirect_to :controller => 'users', :action => 'new'
|
redirect_to signup_path
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
unless user.valid?
|
unless user.valid?
|
||||||
session['new_user'] = user
|
session['new_user'] = user
|
||||||
redirect_to :action => 'new'
|
redirect_to signup_path
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ Feature: Manage a project
|
||||||
And I have logged in as "testuser" with password "secret"
|
And I have logged in as "testuser" with password "secret"
|
||||||
And there exists a project "manage me" for user "testuser"
|
And there exists a project "manage me" for user "testuser"
|
||||||
|
|
||||||
@selenium
|
@selenium, @wip
|
||||||
Scenario: I can describe the project using markup
|
Scenario: I can describe the project using markup
|
||||||
When I visit the "manage me" project
|
When I visit the "manage me" project
|
||||||
And I edit the project description to "_successfull outcome_: project is *done*"
|
And I edit the project description to "_successfull outcome_: project is *done*"
|
||||||
|
|
|
||||||
31
features/manage_users.feature
Normal file
31
features/manage_users.feature
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
Feature: Manage users
|
||||||
|
|
||||||
|
In order to be able to manage the users able to use Tracks
|
||||||
|
As the administrator of this installed Tracks
|
||||||
|
I want to add and delete accounts of users
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given the following user records
|
||||||
|
| login | password | is_admin |
|
||||||
|
| testuser | secret | false |
|
||||||
|
| admin | secret | true |
|
||||||
|
And I have logged in as "admin" with password "secret"
|
||||||
|
|
||||||
|
Scenario: Show all accounts
|
||||||
|
When I go to the manage users page
|
||||||
|
Then I should see "testuser"
|
||||||
|
And I should see "admin"
|
||||||
|
|
||||||
|
Scenario: Add new account
|
||||||
|
When I go to the manage users page
|
||||||
|
And I follow "Signup new user"
|
||||||
|
Then I should be on the signup page
|
||||||
|
When I submit the signup form with username "new.user", password "secret123" and confirm with "secret123"
|
||||||
|
Then I should be on the manage users page
|
||||||
|
And I should see "new.user"
|
||||||
|
|
||||||
|
@selenium
|
||||||
|
Scenario: Delete account from users page
|
||||||
|
When I go to the manage users page
|
||||||
|
And I delete the user "testuser"
|
||||||
|
Then I should see that a user named "testuser" is not present
|
||||||
|
|
@ -2,6 +2,13 @@ Given /^I have a context called "([^\"]*)"$/ do |context_name|
|
||||||
@context = @current_user.contexts.create!(:name => context_name)
|
@context = @current_user.contexts.create!(:name => context_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^I have a context "([^\"]*)" with (.*) actions$/ do |context_name, number_of_actions|
|
||||||
|
context = @current_user.contexts.create!(:name => context_name)
|
||||||
|
1.upto number_of_actions.to_i do |i|
|
||||||
|
@current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
When /^I visits the context page for "([^\"]*)"$/ do |context_name|
|
When /^I visits the context page for "([^\"]*)"$/ do |context_name|
|
||||||
context = @current_user.contexts.find_by_name(context_name)
|
context = @current_user.contexts.find_by_name(context_name)
|
||||||
context.should_not be_nil
|
context.should_not be_nil
|
||||||
|
|
@ -14,25 +21,6 @@ When /^I edit the context name in place to be "([^\"]*)"$/ do |new_context_name|
|
||||||
click_button "OK"
|
click_button "OK"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see the context name is "([^\"]*)"$/ do |context_name|
|
|
||||||
Then "I should see \"#{context_name}\""
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^he should see that a context named "([^\"]*)" is present$/ do |context_name|
|
|
||||||
Then "I should see \"#{context_name}\""
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^he should see that a context named "([^\"]*)" is not present$/ do |context_name|
|
|
||||||
Then "I should not see \"#{context_name} (\""
|
|
||||||
end
|
|
||||||
|
|
||||||
Given /^I have a context "([^\"]*)" with (.*) actions$/ do |context_name, number_of_actions|
|
|
||||||
context = @current_user.contexts.create!(:name => context_name)
|
|
||||||
1.upto number_of_actions.to_i do |i|
|
|
||||||
@current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
When /^I delete the context "([^\"]*)"$/ do |context_name|
|
When /^I delete the context "([^\"]*)"$/ do |context_name|
|
||||||
context = @current_user.contexts.find_by_name(context_name)
|
context = @current_user.contexts.find_by_name(context_name)
|
||||||
context.should_not be_nil
|
context.should_not be_nil
|
||||||
|
|
@ -51,3 +39,15 @@ When /^I edit the context to rename it to "([^\"]*)"$/ do |new_name|
|
||||||
selenium.is_visible("flash")
|
selenium.is_visible("flash")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I should see the context name is "([^\"]*)"$/ do |context_name|
|
||||||
|
Then "I should see \"#{context_name}\""
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^he should see that a context named "([^\"]*)" is present$/ do |context_name|
|
||||||
|
Then "I should see \"#{context_name}\""
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^he should see that a context named "([^\"]*)" is not present$/ do |context_name|
|
||||||
|
Then "I should not see \"#{context_name} (\""
|
||||||
|
end
|
||||||
|
|
@ -10,6 +10,24 @@ Given "no users exists" do
|
||||||
User.delete_all
|
User.delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I delete the user "([^\"]*)"$/ do |username|
|
||||||
|
# click "//tr[@id='user-3']//img"
|
||||||
|
# assert_confirmation "Warning: this will delete user 'john', all their actions, contexts, project and notes. Are you sure that you want to continue?"
|
||||||
|
user = User.find_by_login(username)
|
||||||
|
user.should_not be_nil
|
||||||
|
|
||||||
|
selenium.click "xpath=//tr[@id='user-#{user.id}']//img"
|
||||||
|
selenium.get_confirmation.should == "Warning: this will delete user '#{user.login}', all their actions, contexts, project and notes. Are you sure that you want to continue?"
|
||||||
|
wait_for do
|
||||||
|
!selenium.is_element_present("//tr[@id='user-#{user.id}']//img")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should see that a user named "([^\"]*)" is not present$/ do |username|
|
||||||
|
Then "I should not see \"#{username} (\""
|
||||||
|
end
|
||||||
|
|
||||||
Then "I should be an admin" do
|
Then "I should be an admin" do
|
||||||
# just check on the presence of the menu item for managing users
|
# just check on the presence of the menu item for managing users
|
||||||
Then "I should see \"Manage users\""
|
Then "I should see \"Manage users\""
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,15 @@ module NavigationHelpers
|
||||||
when /the statistics page/
|
when /the statistics page/
|
||||||
stats_path
|
stats_path
|
||||||
when /the signup page/
|
when /the signup page/
|
||||||
"/users/new"
|
signup_path
|
||||||
when /the login page/
|
when /the login page/
|
||||||
login_path
|
login_path
|
||||||
when /the notes page/
|
when /the notes page/
|
||||||
notes_path
|
notes_path
|
||||||
when /the contexts page/
|
when /the contexts page/
|
||||||
contexts_path
|
contexts_path
|
||||||
|
when /the manage users page/
|
||||||
|
users_path
|
||||||
|
|
||||||
# Add more page name => path mappings here
|
# Add more page name => path mappings here
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
setup :fixtures => :all
|
|
||||||
login :as => 'admin'
|
|
||||||
open '/users'
|
|
||||||
assert_text_present "John Deere"
|
|
||||||
click "//tr[@id='user-3']//img"
|
|
||||||
assert_confirmation "Warning: this will delete user 'john', all their actions, contexts, project and notes. Are you sure that you want to continue?"
|
|
||||||
wait_for_text_not_present "John Deere"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue