-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* User profile page Profile page url: `/users/:login` Search by user login url: `/?user=login&type=blog_post` Partially fixes #3 * User#me & profile navigation links * Allow searching by user together with other queries * Improve sidebar * Save space on sidebar
- Loading branch information
Showing
16 changed files
with
248 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require "./spec_helper" | ||
|
||
describe UserController do | ||
let(:user) { user(login: "UserControllerTest").tap &.save } | ||
|
||
before do | ||
Announcement.clear | ||
User.clear | ||
end | ||
|
||
describe "GET #show" do | ||
it "renders show template if user is found" do | ||
get "/users/#{user.login}" | ||
expect(response.status_code).to eq 200 | ||
expect(response.body.includes? user.login.not_nil!).to be_true | ||
end | ||
|
||
it "redirects to root if user is not found" do | ||
get "/users/no-such-login" | ||
expect(response.status_code).to eq 302 | ||
expect(response).to redirect_to "/" | ||
end | ||
end | ||
|
||
describe "GET #me" do | ||
it "renders user#show template if user is signed in" do | ||
login_as user | ||
get "/me" | ||
expect(response.status_code).to eq 200 | ||
expect(response.body.includes? user.login.not_nil!).to be_true | ||
end | ||
|
||
it "redirects to root if user is not signed in" do | ||
get "/me" | ||
expect(response.status_code).to eq 302 | ||
expect(response).to redirect_to "/" | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class UserController < ApplicationController | ||
def show | ||
if user = User.find_by_login params["login"] | ||
render "show.slang" | ||
else | ||
redirect_to "/" | ||
end | ||
end | ||
|
||
def me | ||
if user = current_user | ||
render "show.slang" | ||
else | ||
redirect_to "/" | ||
end | ||
end | ||
end |
Oops, something went wrong.