tests and UI changes
This commit is contained in:
parent
de29815686
commit
f7ec73f85e
6 changed files with 32 additions and 33 deletions
|
@ -14,8 +14,6 @@ class BooksController < ApplicationController
|
|||
@books = books.map { |book| BooksPresenter.new(book) }
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<% @books.each do |book| %>
|
||||
<div class='row'>
|
||||
<div class='col s2'>
|
||||
<%= link_to book.title, book %>
|
||||
<%= book.title %>
|
||||
</div>
|
||||
|
||||
<div class='col s3'>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<% @books.each do |book| %>
|
||||
<div class='row'>
|
||||
<div class='col s2'>
|
||||
<%= link_to book.title, book %>
|
||||
<%= book.title %>
|
||||
</div>
|
||||
|
||||
<div class='col s3'>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<div class='container'>
|
||||
<div class='row'>
|
||||
<div class='col s4'>
|
||||
Title: <%= link_to @book.title, @book %>
|
||||
</div>
|
||||
|
||||
<div class='col s4'>
|
||||
Price: <%= @book.price_with_currency %>
|
||||
</div>
|
||||
|
||||
<div class='col s4'>
|
||||
Authors: <%= @book.authors %>
|
||||
</div>
|
||||
</div>
|
||||
<% if current_user&.admin? %>
|
||||
<div class='row'>
|
||||
<%= link_to 'Edit', edit_book_path(@book), class: "btn" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,10 +1,13 @@
|
|||
<div class='container'>
|
||||
<h4>Welcome</h4>
|
||||
<% if logged_in? %>
|
||||
You are Logged In, <%= current_user.email %>
|
||||
<%= button_to "Logout", '/logout', method: :get, class: 'btn' %>
|
||||
<% else %>
|
||||
<%= button_to "Login", '/login', method: :get, class: 'btn' %>
|
||||
<%= button_to "Sign Up", '/users/new', method: :get, class: 'btn' %>
|
||||
<% end %>
|
||||
<div class='row'>
|
||||
<% if logged_in? %>
|
||||
<p>You are logged in, <%= current_user.email %></p>
|
||||
<%= link_to 'Logout', '/logout', method: :get, class: 'btn' %>
|
||||
<% else %>
|
||||
<p>You are not logged in</p>
|
||||
<%= link_to 'Login', '/login', method: :get, class: 'btn' %>
|
||||
<%= link_to 'Sign Up', '/users/new', method: :get, class: 'btn' %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,11 +3,22 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UsersController do
|
||||
before(:all) do # TODO: change it to cleanup after each test
|
||||
before(:all) do # TODO: turn it into cleanup after each test
|
||||
User.destroy_all
|
||||
end
|
||||
let(:user1) do
|
||||
User.create(email: 'test1@example.com', password: 'abcdefgh', recovery_password: 'recovery password')
|
||||
User.create(
|
||||
email: 'test1@example.com',
|
||||
password: 'abcdefgh',
|
||||
recovery_password: 'recovery password',
|
||||
role: :admin
|
||||
)
|
||||
end
|
||||
describe 'get index' do
|
||||
subject { get :index }
|
||||
it 'renders the users/index template' do
|
||||
expect(subject).to render_template('users/index')
|
||||
end
|
||||
end
|
||||
describe 'get new' do
|
||||
subject { get :new }
|
||||
|
@ -106,4 +117,11 @@ RSpec.describe UsersController do
|
|||
end
|
||||
end
|
||||
end
|
||||
describe 'delete destroy' do
|
||||
context 'when admin is logged in' do
|
||||
it 'deletes the user' do
|
||||
# TODO
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue