Skip to content

Commit

Permalink
standardrb
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmckissock committed Jun 13, 2024
1 parent 27ef7e6 commit bae59b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/controllers/application_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ class ApplicationControllerTest < ActionDispatch::IntegrationTest

# Simulate a logged-in user
def log_in_as(user)
post login_url, params: { name: user.name, password: "password" }
post login_url, params: {name: user.name, password: "password"}
end
end
2 changes: 1 addition & 1 deletion test/controllers/articles_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ class ArticlesControllerTest < ActionDispatch::IntegrationTest

# Simulate a logged-in user
def log_in_as(user)
post login_url, params: { name: user.name, password: "password" }
post login_url, params: {name: user.name, password: "password"}
end
end
6 changes: 3 additions & 3 deletions test/controllers/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
end

test "should create session with valid credentials" do
post login_path, params: { name: @user.name, password: "password" }
post login_path, params: {name: @user.name, password: "password"}
assert_redirected_to @user
assert_equal @user.id, session[:user_id]
end

test "should not create session with invalid credentials" do
post login_path, params: { name: @user.name, password: "wrongpassword" }
post login_path, params: {name: @user.name, password: "wrongpassword"}
assert_redirected_to root_path
assert_nil session[:user_id]
end
Expand All @@ -34,6 +34,6 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
private

def log_in_as(user)
post login_path, params: { name: user.name, password: "password" }
post login_path, params: {name: user.name, password: "password"}
end
end
13 changes: 6 additions & 7 deletions test/controllers/users_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
require 'test_helper'
require "test_helper"

class UsersControllerTest < ActionDispatch::IntegrationTest
include FactoryBot::Syntax::Methods

def setup
@user = create(:user)
@valid_user_params = { user: attributes_for(:user) }
@invalid_user_params = { user: { name: '', email: 'invalid', password: 'pass', password_confirmation: 'word' } }
@valid_user_params = {user: attributes_for(:user)}
@invalid_user_params = {user: {name: "", email: "invalid", password: "pass", password_confirmation: "word"}}
end


test "should create user with valid params" do
assert_difference('User.count', 1) do
assert_difference("User.count", 1) do
post users_path, params: @valid_user_params
end
assert_redirected_to user_path(User.last)
end

test "should not create user with invalid params" do
assert_no_difference('User.count') do
assert_no_difference("User.count") do
post users_path, params: @invalid_user_params
end
assert_redirected_to root_path
Expand All @@ -39,6 +38,6 @@ def setup
private

def login_as(user)
post login_path, params: { name: user.name, password: user.password }
post login_path, params: {name: user.name, password: user.password}
end
end

0 comments on commit bae59b5

Please sign in to comment.