Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix friends bug #159

Open
wants to merge 102 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
830a95b
Initial commit - add test data
xengeo Nov 14, 2023
07f7ab4
Update lombok version
NatalieJClark Nov 14, 2023
94c3e5f
add route for users show page and html file for users show
Nov 14, 2023
81cbd3c
write tests for users controller
Nov 14, 2023
a924737
Merge pull request #1 from davidsholoye/users_controller
davidsholoye Nov 14, 2023
b4418a9
Update post model fields and add sign up button
NatalieJClark Nov 14, 2023
6fd6da6
Merge pull request #2 from davidsholoye/navigation
NatalieJClark Nov 14, 2023
51dd9c6
update column types to bigint and complete comment model implementation
xengeo Nov 15, 2023
2546362
Merge pull request #3 from davidsholoye/add_comment_model
xengeo Nov 15, 2023
6f562d9
update V11 migration file for column type change
xengeo Nov 15, 2023
b7f4cc6
Merge pull request #4 from davidsholoye/add_comment_model
xengeo Nov 15, 2023
533486a
Add header and links to profile, friends and timeline. And signout
davidsholoye Nov 16, 2023
95c4d7d
tested sign up features, checked for empty credentials
xengeo Nov 16, 2023
3034112
Merge pull request #5 from davidsholoye/signup-testing
xengeo Nov 16, 2023
a1227ea
Friend request system with errors
davidsholoye Nov 16, 2023
41ffd26
posts appear by newest first
xengeo Nov 16, 2023
e182e72
Merge pull request #6 from davidsholoye/order-posts
xengeo Nov 16, 2023
1cbb2be
add friend controller and friend model
zakkariyaa Nov 17, 2023
d40fdb2
Add routes to friend controller and update model to be able to make a…
Nov 17, 2023
bd2552f
Merge changes with main
Nov 17, 2023
ae1460e
Merge pull request #7 from davidsholoye/userControllerTesting
NatalieJClark Nov 17, 2023
7eec94b
Rename V12__alter_friends_table.sql to V13__alter_friends_table.sql
xengeo Nov 17, 2023
920d81a
rename v12 and v13 to v12 and v14
zakkariyaa Nov 17, 2023
303c1e8
Merge pull request #8 from davidsholoye/fixdb
zakkariyaa Nov 17, 2023
ef6da3e
Delete flyway versions
NatalieJClark Nov 17, 2023
b6359dc
Add user_id to new post
NatalieJClark Nov 17, 2023
5c2da42
Resolved conflicts
NatalieJClark Nov 17, 2023
1d57d36
fixed the logout issue by changing the anchor tag to form
zakkariyaa Nov 17, 2023
f3d66d2
Resolved conflicts
NatalieJClark Nov 17, 2023
ea13863
Merge pull request #9 from davidsholoye/fix-logout-issue
zakkariyaa Nov 17, 2023
cd880f1
Merge pull request #10 from davidsholoye/Assign_user_id_to_post
xengeo Nov 17, 2023
c9ca0bf
add migration file test users into authorities table
xengeo Nov 17, 2023
3d7b663
Merge pull request #11 from davidsholoye/insert_users_into_authoritie…
xengeo Nov 17, 2023
d29d881
display names of request users with buttons
zakkariyaa Nov 20, 2023
b47fdb6
Add comment and like buttons
NatalieJClark Nov 20, 2023
c74c088
backend accept or deny working
zakkariyaa Nov 20, 2023
9181346
accept and deny fully functional
zakkariyaa Nov 20, 2023
f6d82f7
make button text conditional
zakkariyaa Nov 20, 2023
091d4e4
Comment button links to individual post page, and start to implement …
xengeo Nov 20, 2023
52c6c9d
fix accept request and double confirmation issues
zakkariyaa Nov 20, 2023
af06f93
Merge pull request #12 from davidsholoye/friend-request-backend
zakkariyaa Nov 21, 2023
05c1063
Merge pull request #13 from davidsholoye/comment_on_posts
xengeo Nov 21, 2023
2381874
Add field to upload picture
Nov 21, 2023
ae32ea4
trying to save a comment
xengeo Nov 21, 2023
356fff6
image upload in signup works
zakkariyaa Nov 21, 2023
de7280a
posts showing with names and images
zakkariyaa Nov 21, 2023
93dae21
add comments progress.. sort of
xengeo Nov 22, 2023
3625215
fix image showing on profile
zakkariyaa Nov 22, 2023
6c460a9
Merge pull request #14 from davidsholoye/upload-pic
zakkariyaa Nov 22, 2023
697452d
Add CommentController
NatalieJClark Nov 22, 2023
945069d
add comment form is working!
xengeo Nov 22, 2023
4a42347
Show user list of comments on post page
NatalieJClark Nov 22, 2023
08a9f4f
Editing add comment test
NatalieJClark Nov 22, 2023
20beaf1
Merge branch 'main' into comment_on_posts
NatalieJClark Nov 22, 2023
8df87ee
Merge pull request #15 from davidsholoye/comment_on_posts
NatalieJClark Nov 22, 2023
cb76165
Add CSS changes to the code
davidsholoye Nov 22, 2023
968faa0
Merge branch 'main' into css
davidsholoye Nov 22, 2023
5050087
Merge pull request #16 from davidsholoye/css
davidsholoye Nov 22, 2023
784b91b
Made tests work
NatalieJClark Nov 22, 2023
c06255b
fix bugs
Nov 22, 2023
022e160
like functionality working and likes showing on page
zakkariyaa Nov 22, 2023
e3f81fd
display username and photo next to comment
xengeo Nov 22, 2023
4753664
Merge branch 'main' into comment_on_posts
xengeo Nov 22, 2023
e41e624
Merge pull request #17 from davidsholoye/comment_on_posts
xengeo Nov 22, 2023
7543439
tidy styling for show and index page
Nov 22, 2023
eb30f29
add posts to show page and more styling
Nov 22, 2023
1c4e6a3
add posts to show page but only posts for that specific user
Nov 23, 2023
71d1c92
add posts to show page but only posts for that specific user
Nov 23, 2023
9edb05d
Merge branch 'main' into bug-fixes
somunachima Nov 23, 2023
a65d0a3
Merge pull request #18 from davidsholoye/bug-fixes
somunachima Nov 23, 2023
87bd2f3
order comments by id and test
xengeo Nov 23, 2023
39996d6
Merge pull request #19 from davidsholoye/order_comments
xengeo Nov 23, 2023
43cfdb4
display image and username next to post content on post/index.html
xengeo Nov 23, 2023
6ee33d8
Merge pull request #20 from davidsholoye/display_username_image_on_post
xengeo Nov 23, 2023
12d8a12
add more styling to timeline/posts index
Nov 23, 2023
9175240
Merge branch 'main' into timeline-css
somunachima Nov 23, 2023
39677eb
Merge pull request #21 from davidsholoye/timeline-css
somunachima Nov 23, 2023
234aef9
add more styling to friends index page
Nov 23, 2023
b99c6b5
Merge pull request #22 from davidsholoye/friends-css
somunachima Nov 23, 2023
b433901
Made changes to the css
davidsholoye Nov 23, 2023
2361673
add correct links to navbar to go to current user's profile page
Nov 23, 2023
bddf518
Merge pull request #24 from davidsholoye/navbar-links
somunachima Nov 23, 2023
47343c7
Merge branch 'main' into css_changes
davidsholoye Nov 23, 2023
9f5e860
Merge pull request #23 from davidsholoye/css_changes
davidsholoye Nov 23, 2023
3ab4d44
add correct links to navbar to go to current user's profile page
Nov 23, 2023
92c8a01
Merge pull request #25 from davidsholoye/check-navbar
somunachima Nov 23, 2023
5594e77
like functionality + changes from main'
zakkariyaa Nov 23, 2023
6f33b4d
Merge pull request #26 from davidsholoye/like-functionality
zakkariyaa Nov 23, 2023
9bf8f75
photo update works
zakkariyaa Nov 23, 2023
5a944d9
Fix broken tests
NatalieJClark Nov 23, 2023
ddaed85
Merge pull request #27 from davidsholoye/post-photo
zakkariyaa Nov 23, 2023
c3b2b5f
Merge branch 'main' into create_dockerfile
NatalieJClark Nov 23, 2023
9c0a21e
Merge pull request #28 from davidsholoye/create_dockerfile
NatalieJClark Nov 23, 2023
04acabd
Fix photo
NatalieJClark Nov 23, 2023
e9161f9
Fix photo
NatalieJClark Nov 23, 2023
08cca0b
users can upload photos as posts
zakkariyaa Nov 23, 2023
8adb2c4
merge with changes from main
zakkariyaa Nov 23, 2023
685f920
Merge pull request #29 from davidsholoye/post-photo2
zakkariyaa Nov 23, 2023
c559c47
add styling to post-show
Nov 23, 2023
ae783ab
Merge branch 'main' into posts-show-css
somunachima Nov 23, 2023
d576eb7
Merge pull request #30 from davidsholoye/posts-show-css
somunachima Nov 23, 2023
64eed9b
fix bugs in friends
Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tested sign up features, checked for empty credentials
xengeo committed Nov 16, 2023
commit 95c4d7de68638fb2f8144402cea3a753805e9b48
Original file line number Diff line number Diff line change
@@ -12,10 +12,14 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.view.RedirectView;

import java.util.ArrayList;
import java.util.Optional;

import static java.lang.Boolean.valueOf;

@Controller
public class UsersController {

@@ -31,7 +35,23 @@ public String signup(Model model) {
}

@PostMapping("/users")
public RedirectView signup(@ModelAttribute User user) {
public RedirectView signup(@ModelAttribute User user, RedirectAttributes attributes) {

String usernameErrorMsg = "Please enter a username";
String passwordErrorMsg = "Please enter a password";

if (user.getUsername().trim().isEmpty() && user.getPassword().trim().isEmpty()){
attributes.addAttribute("usernameError", usernameErrorMsg);
attributes.addAttribute("passwordError", passwordErrorMsg);
return new RedirectView("/users/new");
} else if (user.getPassword().trim().isEmpty()) {
attributes.addAttribute("passwordError", passwordErrorMsg);
return new RedirectView("/users/new");
} else if (user.getUsername().trim().isEmpty()) {
attributes.addAttribute("usernameError", usernameErrorMsg);
return new RedirectView("/users/new");
}

userRepository.save(user);
Authority authority = new Authority(user.getUsername(), "ROLE_USER");
authoritiesRepository.save(authority);
4 changes: 2 additions & 2 deletions src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
<head>
<title tiles:fragment="title">Messages : Create</title>
<title tiles:fragment="title">Please log in</title>
</head>
<body>
<div tiles:fragment="content">
@@ -24,7 +24,7 @@
</form>
<form name="f" th:action="@{/users/new}" method="get">
<div>
<button type="submit" class="btn">Sign up</button>
<button id="sign-up-btn" type="submit" class="btn">Sign up</button>
</div>
</form>
</div>
5 changes: 3 additions & 2 deletions src/main/resources/templates/users/new.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Signup</title>
</head>
<body>
<form action="#" th:action="@{/users}" th:object="${user}" method="post">
<p id="usernameError" class="alert alert-error" th:text="${param.usernameError}"></p>
<p id="passwordError" class="alert alert-error" th:text="${param.passwordError}"></p>
<p>Username: <input type="text" th:field="*{username}" /></p>
<p>Password: <input type="password" th:field="*{password}" /></p>
<p><input type="submit" value="Submit" id="submit"/> <input type="reset" value="Reset" /></p>
40 changes: 39 additions & 1 deletion src/test/java/SignUpTest.java
Original file line number Diff line number Diff line change
@@ -7,7 +7,10 @@
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -38,6 +41,41 @@ public void successfulSignUpRedirectsToSignIn() {
driver.findElement(By.id("password")).sendKeys("password");
driver.findElement(By.id("submit")).click();
String title = driver.getTitle();
Assert.assertEquals("Please sign in", title);
Assert.assertEquals("Please log in", title);
}


@Test
public void signUpButtonLinksToSignUpPage() {
driver.get("http://localhost:8080/login");
driver.findElement(By.id("sign-up-btn")).click();
String title = driver.getTitle();
Assert.assertEquals("Signup", title);
}

@Test
public void testBlankUsernameReturnsError() {
driver.get("http://localhost:8080/users/new");
driver.findElement(By.id("username")).sendKeys(" ");
driver.findElement(By.id("password")).sendKeys("password");
driver.findElement(By.id("submit")).click();
// Explicitly wait for the error message to be visible
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement usernameError = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("usernameError")));
String errorString = usernameError.getText();
Assert.assertEquals("Please enter a username", errorString);
}

@Test
public void testBlankPasswordReturnsError() {
driver.get("http://localhost:8080/users/new");
driver.findElement(By.id("username")).sendKeys("username_1");
driver.findElement(By.id("password")).sendKeys(" ");
driver.findElement(By.id("submit")).click();
// Explicitly wait for the error message to be visible
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement passwordError = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("passwordError")));
String errorString = passwordError.getText();
Assert.assertEquals("Please enter a password", errorString);
}
}
10 changes: 5 additions & 5 deletions src/test/java/com/makersacademy/acebook/model/PostTest.java
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@ public void postHasContent() {
assertThat(post.getContent(), containsString("hello"));
}

// @Test
// public void postHasContent() {
// assertThat(post.getContent(), containsString("hello"));
// }
//
@Test
public void postHasU() {
assertThat(post.getContent(), containsString("hello"));
}

}