ユーザーがログに記録するシナリオ(admin)をテストしてから、さらにユーザーを作成しようとしています。
ログでは、コントロールがログインページに移動し、管理者ユーザーがログインし、コントロールが他のユーザー作成ページにリダイレクトされると、ログインフィルターが停止し、コントロールをログインページにリダイレクトすることがわかります。
キュウリの初心者なので、コードの品質が良くないため、ログインしたユーザーサービスをテストするためのガイドが役立ちます
これが私のシナリオです
Feature: Create user from LMS
In order to create lms user with multiple groups
As a author
I want to create lms user with multipl groups
Scenario: Add new user with multiple groups
Given the following user information
And I am logged in as author "gulled" with password "thebest"
When I request for new lms user creation
Then the new user "user1" should be created
そしてここに定義があります
Given /^the following user information$/ do
# Factory(:login)
# Factory(:author)
end
Given /^I am logged in as author "([^"]*)" with password "([^"]*)"$/ do |username, password|
visit "account/login"
fill_in "loginfield", :with => username
fill_in "password", :with => password
click_button "submit_button"
end
When /^I request for new lms user creation$/ do
visit "/author_backend_lms/new_user"
fill_in "login_first_name", :with => ""
fill_in "login_last_name", :with => ""
fill_in "login_login", :with => ""
fill_in "login_email", :with => ""
fill_in "login_password_confirmation", :with => ""
click_button "create_user_form_submit_button"
end
Then /^the new user "([^"]*)" should be created$/ do |user_login|
login = Login.find_by_login user
assert_no_nil login, "Record creation failed"
end
「新しいlmsユーザー作成のリクエスト」で、lmsユーザー作成ページにアクセスしようとすると、コントロールはログインページにリダイレクトします。
これが私のテスト用の宝石リストです
gem "capybara", "1.1.1"
gem "cucumber", "1.1.0"
gem "cucumber-rails", "0.3.2"