Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def setup
- @user = User.create(email: "user@hlist.com",
- encrypted_password: Devise.bcrypt(User, 'password1'))
- @post = { title: "This is the title",
- content: "Detailed comment."*10,
- phone: 9991118888,
- email: "email@hlist.com",
- user_id: users(:spiderman).id }
- @p = @user.posts.build(@post)
- end
- test "creates a new post successfully" do
- sign_in_as(@user)
- get new_post_path(@user)
- assert_template 'posts/new'
- assert_difference 'Post.count', 1 do
- post posts_path, post: @post
- end
- assert_template 'posts/show'
- end
- def sign_in_as(user)
- post_via_redirect user_session_path, 'user[:email]' => user.email,
- 'user[:encrypted_password]' => Devise.bcrypt(User, 'password1')
- end
- 1) Failure:
- PostsCrudTest#test_creates_a_new_post_successfully [/Users/harishramachandran/dropbox/documents/harish/coding/workspace/h_list/test/integration/posts_crud_test.rb:19]:
- expecting <"posts/new"> but rendering with <[]>
- require 'test_helper'
- class UserFlowsTest < ActionDispatch::IntegrationTest
- test "user can see home page after login" do
- get user_session_path
- assert_equal 200, status
- @david = User.create(email: "david@mail.com", password: Devise::Encryptor.digest(User, "helloworld"))
- post user_session_path, 'user[email]' => @david.email, 'user[password]' => @david.password
- follow_redirect!
- assert_equal 200, status
- assert_equal "/", path
- end
- test "user can not see home page without login" do
- get "/"
- assert_equal 302, status
- follow_redirect!
- assert_equal "/users/sign_in", path
- assert_equal 200, status
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement