diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index 98071eb..88479ed 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -14,8 +14,6 @@ class BooksController < ApplicationController @books = books.map { |book| BooksPresenter.new(book) } end - def show; end - def edit; end def update diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb index 412346b..8dd3a2b 100644 --- a/app/views/books/index.html.erb +++ b/app/views/books/index.html.erb @@ -9,7 +9,7 @@ <% @books.each do |book| %>
- <%= link_to book.title, book %> + <%= book.title %>
diff --git a/app/views/books/shopping_cart.erb b/app/views/books/shopping_cart.erb index 39f6cdf..dc6121d 100644 --- a/app/views/books/shopping_cart.erb +++ b/app/views/books/shopping_cart.erb @@ -7,7 +7,7 @@ <% @books.each do |book| %>
- <%= link_to book.title, book %> + <%= book.title %>
diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb deleted file mode 100644 index 5370cff..0000000 --- a/app/views/books/show.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -
-
-
- Title: <%= link_to @book.title, @book %> -
- -
- Price: <%= @book.price_with_currency %> -
- -
- Authors: <%= @book.authors %> -
-
- <% if current_user&.admin? %> -
- <%= link_to 'Edit', edit_book_path(@book), class: "btn" %> -
- <% end %> -
diff --git a/app/views/sessions/welcome.html.erb b/app/views/sessions/welcome.html.erb index 5a3f277..f2a1bcd 100644 --- a/app/views/sessions/welcome.html.erb +++ b/app/views/sessions/welcome.html.erb @@ -1,10 +1,13 @@

Welcome

- <% 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 %> +
+ <% if logged_in? %> +

You are logged in, <%= current_user.email %>

+ <%= link_to 'Logout', '/logout', method: :get, class: 'btn' %> + <% else %> +

You are not logged in

+ <%= link_to 'Login', '/login', method: :get, class: 'btn' %> + <%= link_to 'Sign Up', '/users/new', method: :get, class: 'btn' %> + <% end %> +
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index db741e1..8595b6c 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -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