Skip to content

Commit 7b592a4

Browse files
committed
feat: sessions controller and view added
1 parent 9338166 commit 7b592a4

File tree

9 files changed

+112
-0
lines changed

9 files changed

+112
-0
lines changed

app/assets/stylesheets/sessions.scss

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the sessions controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class SessionsController < ApplicationController
2+
def new
3+
end
4+
5+
def create
6+
end
7+
8+
def destroy
9+
end
10+
end

app/helpers/sessions_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module SessionsHelper
2+
end

app/views/sessions/create.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Sessions#create</h1>
2+
<p>Find me in app/views/sessions/create.html.erb</p>

app/views/sessions/destroy.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Sessions#destroy</h1>
2+
<p>Find me in app/views/sessions/destroy.html.erb</p>

app/views/sessions/new.html.erb

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<div class="container mt-4">
2+
<div class="row">
3+
<div class="col-md-8 offset-md-2">
4+
<h1 class="text-center form-header-style mt-5 pt-2 pb-3">
5+
Sign In
6+
</h1>
7+
8+
<!-- <div class="card panel-div"> -->
9+
10+
<div class="form-body-style px-5 pt-4">
11+
<% from_with url: signin_path do |f| %>>
12+
<div class="form-group row">
13+
<div class="col-md-2 col-form-label">
14+
<%= f.label :email %>
15+
</div>
16+
<div class="col-md-9">
17+
<%= f.email_field :email, class: "form-control", placeholder: "Your email address", autofocus: true %>
18+
</div>
19+
</div>
20+
21+
<div class="form-group row">
22+
<div class="col-md-2 col-form-label">
23+
<%= f.label :password %>
24+
</div>
25+
<div class="col-md-9">
26+
<%= f.password_field :password, class: "form-control", placeholder: "Your password" %>
27+
</div>
28+
</div>
29+
30+
31+
<div class="form-group row">
32+
<div class="col-md-9 offset-md-2">
33+
<%= f.submit 'Sign in', class: "btn btn-outline-purple" %>
34+
</div>
35+
</div>
36+
37+
<% end %>>
38+
</div>
39+
<!-- </div> -->
40+
41+
42+
</div>
43+
</div>
44+
</div>
45+

config/routes.rb

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Rails.application.routes.draw do
2+
get 'sessions/new'
3+
get 'sessions/create'
4+
get 'sessions/destroy'
25
get 'users/new', to: 'users#new', as: 'new_user'
36
get '/signup', to: 'users#new'
7+
get '/signin', to: 'sessions#new'
8+
post '/signin', to: 'sessions#create'
9+
delete '/signout', to: 'sessions#destroy', as: 'session'
10+
411
resources :users, only: [:create]
512

613
root to: "products#index"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe SessionsController, :type => :controller do
4+
5+
describe "GET new" do
6+
it "returns http success" do
7+
get :new
8+
expect(response).to be_success
9+
end
10+
end
11+
12+
describe "GET create" do
13+
it "returns http success" do
14+
get :create
15+
expect(response).to be_success
16+
end
17+
end
18+
19+
describe "GET destroy" do
20+
it "returns http success" do
21+
get :destroy
22+
expect(response).to be_success
23+
end
24+
end
25+
26+
end

spec/helpers/sessions_helper_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'rails_helper'
2+
3+
# Specs in this file have access to a helper object that includes
4+
# the SessionsHelper. For example:
5+
#
6+
# describe SessionsHelper do
7+
# describe "string concat" do
8+
# it "concats two strings with spaces" do
9+
# expect(helper.concat_strings("this","that")).to eq("this that")
10+
# end
11+
# end
12+
# end
13+
RSpec.describe SessionsHelper, :type => :helper do
14+
pending "add some examples to (or delete) #{__FILE__}"
15+
end

0 commit comments

Comments
 (0)