Created
May 15, 2018 13:41
-
-
Save mattb20/e1554a4935d25b6fd5e4baa64bba82c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
def new | |
@post = Post.new | |
end | |
def create | |
@post = current_user.posts.build(post_params) | |
redirect_to posts_url | |
end | |
def index | |
@posts = Post.all | |
end | |
private | |
def post_params | |
params.require(:post).permit(:message) | |
end | |
end | |
require 'rails_helper' | |
def user_makes_a_post | |
user_signs_up | |
visit "/posts" | |
click_link "New post" | |
fill_in "Message", with: "Hello, world!" | |
click_button "Submit" | |
end | |
def user_signs_up | |
visit "/users/sign_up" | |
fill_in "user_email", with: "[email protected]" | |
fill_in "user_password", with: "123456abc" | |
fill_in "user_password_confirmation", with: "123456abc" | |
click_button "Sign up" | |
end | |
RSpec.feature "Timeline", type: :feature do | |
scenario "User email displayed with a post" do | |
user_signs_up | |
user_makes_a_post | |
expect(page).to have_content("Hello, world! [email protected]") | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment