1

なぜこれがうまくいかないのでしょうか?

について話している人もwebratいますが、Rails はフォームのサインアップを直接処理することになっているのではないでしょうか?

User#Create以下のテストではアクションがトリガーされません。何も起こらないようです。

test "should not sign up more than 5 users" do
  get "signup"
  assert_response :success
  assert_difference('User.count',5) do
    for i in 0..10 do
      puts "Signup user"
      post_via_redirect "/signup",
                        :first_name => "Petter",
                        :last_name => "Smart",
                        :email => "petter.smart<%=i%>@prayalot.com",
                        :password => '123456',
                        :password_confirmation => '123456'
      assert_equal '/sentmail', path
    end
  end
end
4

2 に答える 2

0

これは魅力のように機能します!:-) Billy Chan のアドバイスに感謝します。

test "should not sign up more than 10 users from same IP" do
    get "signup"
    assert_response :success
    assert_difference('User.count',10) do
        for i in 1..10 do
            post "users", :user => {
            :first_name => "Petter",
            :last_name => "Smart",
            :email =>  "petter.smart#{i}@prayalot.com",
            :password => '123456',
            :password_confirmation => '123456'}
            assert_redirected_to sentmail_path
        end

        for i in 11..20 do
            post "users", :user => {
            :first_name => "Petter",
            :last_name => "Smart",
            :email =>  "petter.smart#{i}@prayalot.com",
            :password => '123456',
            :password_confirmation => '123456'}
            assert_redirected_to error_path
        end
    end
end
于 2013-06-07T13:02:13.440 に答える