From 9539b11cb35db364dbf0660152faa0e1000eb1aa Mon Sep 17 00:00:00 2001 From: Salem Alshehri Date: Mon, 11 Mar 2019 16:12:52 +0300 Subject: [PATCH] test --- Gemfile | 5 + Gemfile.lock | 36 +++ app/assets/javascripts/books.js | 2 + app/assets/javascripts/home.js | 2 + app/assets/stylesheets/books.scss | 3 + app/assets/stylesheets/home.scss | 3 + app/assets/stylesheets/scaffolds.scss | 84 +++++ app/controllers/books_controller.rb | 102 ++++++ app/controllers/home_controller.rb | 13 + app/helpers/books_helper.rb | 2 + app/helpers/home_helper.rb | 2 + app/models/book.rb | 8 + app/models/user.rb | 11 + app/uploaders/image_uploader.rb | 51 +++ app/views/books/_book.json.jbuilder | 3 + app/views/books/_form.html.erb | 45 +++ app/views/books/edit.html.erb | 11 + app/views/books/index.html.erb | 35 ++ app/views/books/index.json.jbuilder | 1 + app/views/books/new.html.erb | 5 + app/views/books/show.html.erb | 37 +++ app/views/books/show.json.jbuilder | 1 + app/views/home/index.html.erb | 23 ++ app/views/layouts/application.html.erb | 8 + config/environments/development.rb | 1 + config/initializers/carrier_wave.rb | 1 + config/initializers/devise.rb | 299 ++++++++++++++++++ config/locales/devise.en.yml | 65 ++++ config/routes.rb | 4 + db/migrate/20190307143025_create_books.rb | 13 + .../20190307144253_devise_create_users.rb | 44 +++ .../20190310114926_add_user_to_books.rb | 5 + ...2354_change_image_to_be_binary_in_books.rb | 5 + db/schema.rb | 43 +++ public/uploads/book/image/10/th.jpeg | Bin 0 -> 5371 bytes public/uploads/book/image/6/th.jpeg | Bin 0 -> 5371 bytes public/uploads/book/image/8/th.jpeg | Bin 0 -> 5371 bytes public/uploads/book/image/9/th.jpeg | Bin 0 -> 5371 bytes test/controllers/books_controller_test.rb | 48 +++ test/controllers/home_controller_test.rb | 9 + test/fixtures/books.yml | 15 + test/fixtures/users.yml | 11 + test/models/book_test.rb | 7 + test/models/user_test.rb | 7 + test/system/books_test.rb | 51 +++ 45 files changed, 1121 insertions(+) create mode 100644 app/assets/javascripts/books.js create mode 100644 app/assets/javascripts/home.js create mode 100644 app/assets/stylesheets/books.scss create mode 100644 app/assets/stylesheets/home.scss create mode 100644 app/assets/stylesheets/scaffolds.scss create mode 100644 app/controllers/books_controller.rb create mode 100644 app/controllers/home_controller.rb create mode 100644 app/helpers/books_helper.rb create mode 100644 app/helpers/home_helper.rb create mode 100644 app/models/book.rb create mode 100644 app/models/user.rb create mode 100644 app/uploaders/image_uploader.rb create mode 100644 app/views/books/_book.json.jbuilder create mode 100644 app/views/books/_form.html.erb create mode 100644 app/views/books/edit.html.erb create mode 100644 app/views/books/index.html.erb create mode 100644 app/views/books/index.json.jbuilder create mode 100644 app/views/books/new.html.erb create mode 100644 app/views/books/show.html.erb create mode 100644 app/views/books/show.json.jbuilder create mode 100644 app/views/home/index.html.erb create mode 100644 config/initializers/carrier_wave.rb create mode 100644 config/initializers/devise.rb create mode 100644 config/locales/devise.en.yml create mode 100644 db/migrate/20190307143025_create_books.rb create mode 100644 db/migrate/20190307144253_devise_create_users.rb create mode 100644 db/migrate/20190310114926_add_user_to_books.rb create mode 100644 db/migrate/20190311122354_change_image_to_be_binary_in_books.rb create mode 100644 db/schema.rb create mode 100644 public/uploads/book/image/10/th.jpeg create mode 100644 public/uploads/book/image/6/th.jpeg create mode 100644 public/uploads/book/image/8/th.jpeg create mode 100644 public/uploads/book/image/9/th.jpeg create mode 100644 test/controllers/books_controller_test.rb create mode 100644 test/controllers/home_controller_test.rb create mode 100644 test/fixtures/books.yml create mode 100644 test/fixtures/users.yml create mode 100644 test/models/book_test.rb create mode 100644 test/models/user_test.rb create mode 100644 test/system/books_test.rb diff --git a/Gemfile b/Gemfile index bf629fa..56b86c8 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,11 @@ gem 'rails', '~> 5.2.2' gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~> 3.11' +gem 'email_validator' +gem 'pry-rails', :group => :development +gem 'devise', '~> 4.6', '>= 4.6.1' +gem 'carrierwave', '~> 0.10.0' +gem 'mini_magick', '~> 4.3' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets diff --git a/Gemfile.lock b/Gemfile.lock index adbb6d4..1920f42 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,6 +47,7 @@ GEM archive-zip (0.12.0) io-like (~> 0.3.0) arel (9.0.0) + bcrypt (3.1.12) bindex (0.5.0) bootsnap (1.4.1) msgpack (~> 1.0) @@ -60,13 +61,27 @@ GEM rack-test (>= 0.6.3) regexp_parser (~> 1.2) xpath (~> 3.2) + carrierwave (0.10.0) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + json (>= 1.7) + mime-types (>= 1.16) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) chromedriver-helper (2.1.0) archive-zip (~> 0.10) nokogiri (~> 1.8) + coderay (1.1.2) concurrent-ruby (1.1.4) crass (1.0.4) + devise (4.6.1) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0, < 6.0) + responders + warden (~> 1.2.3) + email_validator (2.0.1) + activemodel erubi (1.8.0) execjs (2.7.0) ffi (1.10.0) @@ -78,6 +93,7 @@ GEM jbuilder (2.8.0) activesupport (>= 4.2.0) multi_json (>= 1.2) + json (2.2.0) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -90,7 +106,11 @@ GEM marcel (0.3.3) mimemagic (~> 0.3.2) method_source (0.9.2) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2018.0812) mimemagic (0.3.3) + mini_magick (4.9.3) mini_mime (1.0.1) mini_portile2 (2.4.0) minitest (5.11.3) @@ -99,7 +119,13 @@ GEM nio4r (2.3.1) nokogiri (1.10.1) mini_portile2 (~> 2.4.0) + orm_adapter (0.5.0) pg (1.1.4) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-rails (0.3.9) + pry (>= 0.10.4) public_suffix (3.0.3) puma (3.12.0) rack (2.0.6) @@ -134,6 +160,9 @@ GEM rb-inotify (0.10.0) ffi (~> 1.0) regexp_parser (1.3.0) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) ruby_dep (1.5.0) rubyzip (1.2.2) sass (3.7.3) @@ -169,6 +198,8 @@ GEM thread_safe (~> 0.1) uglifier (4.1.20) execjs (>= 0.3.0, < 3) + warden (1.2.8) + rack (>= 2.0.6) web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) @@ -187,10 +218,15 @@ DEPENDENCIES bootsnap (>= 1.1.0) byebug capybara (>= 2.15) + carrierwave (~> 0.10.0) chromedriver-helper + devise (~> 4.6, >= 4.6.1) + email_validator jbuilder (~> 2.5) listen (>= 3.0.5, < 3.2) + mini_magick (~> 4.3) pg (>= 0.18, < 2.0) + pry-rails puma (~> 3.11) rails (~> 5.2.2) sass-rails (~> 5.0) diff --git a/app/assets/javascripts/books.js b/app/assets/javascripts/books.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/books.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/home.js b/app/assets/javascripts/home.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/home.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/books.scss b/app/assets/stylesheets/books.scss new file mode 100644 index 0000000..9fab565 --- /dev/null +++ b/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Books controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/home.scss b/app/assets/stylesheets/home.scss new file mode 100644 index 0000000..7131aac --- /dev/null +++ b/app/assets/stylesheets/home.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Home controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss new file mode 100644 index 0000000..6045188 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.scss @@ -0,0 +1,84 @@ +body { + background-color: #fff; + color: #333; + margin: 33px; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + + &:visited { + color: #666; + } + + &:hover { + color: #fff; + background-color: #000; + } +} + +th { + padding-bottom: 5px; +} + +td { + padding: 0 5px 7px; +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px 7px 0; + margin-bottom: 20px; + background-color: #f0f0f0; + + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px -7px 0; + background-color: #c00; + color: #fff; + } + + ul li { + font-size: 12px; + list-style: square; + } +} + +label { + display: block; +} diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb new file mode 100644 index 0000000..53a9dbb --- /dev/null +++ b/app/controllers/books_controller.rb @@ -0,0 +1,102 @@ +class BooksController < ApplicationController + before_action :authenticate_user!,except: [:index, :show] + before_action :set_book, only: [:show, :edit, :update, :destroy] + # before_action :current_user, only: [:edit, :update, :destroy] + + # GET /books + # GET /books.json + def index + + if current_user + @books = current_user.books + else + redirect_to home_path + end + # binding.pry + end + + + # GET /books/1 + # GET /books/1.json + def show + user_edit + end + + # GET /books/new + def new + @book = Book.new + end + + # GET /books/1/edit + def edit + user_edit + # binding.pry + end + + + # POST /books + # POST /books.json + def create + # @book = Book.new(book_params) + @book = current_user.books.build(book_params) + + respond_to do |format| + if @book.save + format.html { redirect_to @book, notice: 'Book was successfully created.' } + format.json { render :show, status: :created, location: @book } + else + format.html { render :new } + format.json { render json: @book.errors, status: :unprocessable_entity } + end + end + end + + + + + # PATCH/PUT /books/1 + # PATCH/PUT /books/1.json + def update + respond_to do |format| + if @book.update(book_params) + format.html { redirect_to @book, notice: 'Book was successfully updated.' } + format.json { render :show, status: :ok, location: @book } + else + format.html { render :edit } + format.json { render json: @book.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /books/1 + # DELETE /books/1.json + def destroy + @book.destroy + respond_to do |format| + format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_book + @book = Book.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def book_params + params.require(:book).permit(:title, :author, :description, :image, :category) + end + + def user_edit + if (user_signed_in? && (current_user.id == @book.user_id)) + @can_edit = true + else + @can_edit = false + end + end + + + +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..5e293fd --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,13 @@ +class HomeController < ApplicationController + def index + @books = Book.all + my_book + end + def my_book + if (user_signed_in?) + @has_books = true + else + @has_books = false + end + end +end diff --git a/app/helpers/books_helper.rb b/app/helpers/books_helper.rb new file mode 100644 index 0000000..4b9311e --- /dev/null +++ b/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 0000000..23de56a --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,2 @@ +module HomeHelper +end diff --git a/app/models/book.rb b/app/models/book.rb new file mode 100644 index 0000000..0b73b38 --- /dev/null +++ b/app/models/book.rb @@ -0,0 +1,8 @@ +class Book < ApplicationRecord + belongs_to :user + mount_uploader :image, ImageUploader +end + + + + diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..2252442 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,11 @@ +class User < ApplicationRecord + + has_many :books, dependent: :destroy + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :validatable + validates :email, presence: true, format: /\w+@\w+\.{1}[a-zA-Z]{2,}/ +end + + diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb new file mode 100644 index 0000000..4861131 --- /dev/null +++ b/app/uploaders/image_uploader.rb @@ -0,0 +1,51 @@ +# encoding: utf-8 + +class ImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process :resize_to_fit => [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_white_list + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end diff --git a/app/views/books/_book.json.jbuilder b/app/views/books/_book.json.jbuilder new file mode 100644 index 0000000..c241f8c --- /dev/null +++ b/app/views/books/_book.json.jbuilder @@ -0,0 +1,3 @@ +json.extract! book, :id, :title, :author, :description, :image, :category, :created_at, :updated_at +json.url book_url(book, format: :json) + diff --git a/app/views/books/_form.html.erb b/app/views/books/_form.html.erb new file mode 100644 index 0000000..f237428 --- /dev/null +++ b/app/views/books/_form.html.erb @@ -0,0 +1,45 @@ + + +<%= form_with(model: book, local: true) do |form| %> + <% if book.errors.any? %> +
+

<%= pluralize(book.errors.count, "error") %> prohibited this book from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :title %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :author %> + <%= form.text_field :author %> +
+ +
+ <%= form.label :description %> + <%= form.text_field :description %> +
+ +
+ <%= form.label :image %> + <%= form.file_field :image %> +
+ +
+ <%= form.label :category %> + <%= form.select :category, ['option1', 'option2', 'option3']%> + +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/books/edit.html.erb b/app/views/books/edit.html.erb new file mode 100644 index 0000000..e2a7ce2 --- /dev/null +++ b/app/views/books/edit.html.erb @@ -0,0 +1,11 @@ +<% if @can_edit %> +

Editing Book

+ +<%= render 'form', book: @book %> + +<%= link_to 'Show', @book %> | +<%= link_to 'Back', books_path %> + +<% else %> +

forbiden

+<% end %> diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb new file mode 100644 index 0000000..410cb15 --- /dev/null +++ b/app/views/books/index.html.erb @@ -0,0 +1,35 @@ +

<%= notice %>

+ +

Books

+ + + + + + + + + + + + + + + <% @books.each do |book| %> + + + + + + + + + + + <% end %> + +
TitleAuthorDescriptionImageCategory
<%= book.title %><%= book.author %><%= book.description %><%= book.image.url %><%= book.category %><%= link_to 'Show', book %><%= link_to 'Edit', edit_book_path(book) %><%= link_to 'Destroy', book, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Book', new_book_path %> diff --git a/app/views/books/index.json.jbuilder b/app/views/books/index.json.jbuilder new file mode 100644 index 0000000..7ee9cfe --- /dev/null +++ b/app/views/books/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @books, partial: 'books/book', as: :book diff --git a/app/views/books/new.html.erb b/app/views/books/new.html.erb new file mode 100644 index 0000000..9607d41 --- /dev/null +++ b/app/views/books/new.html.erb @@ -0,0 +1,5 @@ +

New Book

+ +<%= render 'form', book: @book %> + +<%= link_to 'Back', books_path %> diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb new file mode 100644 index 0000000..0eb4a2a --- /dev/null +++ b/app/views/books/show.html.erb @@ -0,0 +1,37 @@ +

<%= notice %>

+ +

+ Title: + <%= @book.title %> +

+ +

+ Author: + <%= @book.author %> +

+ +

+ DEscription: + <%= @book.description %> +

+ +

+Image: +<% if @book.image.url != nil %> + <%= image_tag @book.image.url %> +<%else%> +<%= image_tag 'http://insignia.sd23.bc.ca/Library/images/cover/book.png' %> +<%end%> +

+ +

+ Category: + <%= @book.category %> +

+ + +<%= link_to 'Back', books_path %> + +<% if @can_edit %> +<%= link_to "Edit", edit_book_path(@book) %> +<% end %> diff --git a/app/views/books/show.json.jbuilder b/app/views/books/show.json.jbuilder new file mode 100644 index 0000000..c1e5174 --- /dev/null +++ b/app/views/books/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "books/book", book: @book diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..43b3bd4 --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,23 @@ +

All Books

+<%= link_to 'New Book', new_book_path %> + + + + + + + + + + <% @books.each do |book| %> + + + + <% end %> + +
Title
<%= link_to book.title, book %>
+
+ +<% if @has_books %> +<%= link_to 'My books', books_path %> +<%end%> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index aac73db..60bdd58 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,6 +10,14 @@ +

<%= notice %>

+

<%= alert %>

+ <% if user_signed_in? %> + <%= link_to 'logout', destroy_user_session_path, method: :delete %> + <%= link_to "Change your password", edit_user_registration_path %> + <% else %> + <%= link_to "login", new_user_session_path %> + <% end %> <%= yield %> diff --git a/config/environments/development.rb b/config/environments/development.rb index 1311e3e..9ee7954 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -58,4 +58,5 @@ # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } end diff --git a/config/initializers/carrier_wave.rb b/config/initializers/carrier_wave.rb new file mode 100644 index 0000000..5780787 --- /dev/null +++ b/config/initializers/carrier_wave.rb @@ -0,0 +1 @@ +require 'carrierwave/orm/activerecord' \ No newline at end of file diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000..70fb3a8 --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,299 @@ +# frozen_string_literal: true + +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + # Devise will use the `secret_key_base` as its `secret_key` + # by default. You can change it below and use your own secret key. + # config.secret_key = '142643509008b414c7181f28f6104f361320d0b1bb0163685bf1c047601f36b3a287203180df714ee98196930c05d2079d74da76dc9457b8bf3b92006908083e' + + # ==> Controller configuration + # Configure the parent class to the devise controllers. + # config.parent_controller = 'DeviseController' + + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class + # with default "from" parameter. + config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' + + # Configure the class responsible to send e-mails. + # config.mailer = 'Devise::Mailer' + + # Configure the parent class responsible to send e-mails. + # config.parent_mailer = 'ActionMailer::Base' + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [:email] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [:email] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [:email] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:database]` will + # enable it only for database authentication. The supported strategies are: + # :database = Support basic authentication with authentication key + password + # config.http_authenticatable = false + + # If 401 status code should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. 'Application' by default. + # config.http_authentication_realm = 'Application' + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # particular strategies by setting this option. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing skip: :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true + + # When false, Devise will not attempt to reload routes on eager load. + # This can reduce the time taken to boot the app but if your application + # requires the Devise mappings to be loaded during boot time the application + # won't boot properly. + # config.reload_routes = true + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 11. If + # using other algorithms, it sets how many times you want the password to be hashed. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. Note that, for bcrypt (the default + # algorithm), the cost increases exponentially with the number of stretches (e.g. + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). + config.stretches = Rails.env.test? ? 1 : 11 + + # Set up a pepper to generate the hashed password. + # config.pepper = '841bc26df4261a3a67a0c001c3819cb6fc32c7a3f89d7a2d828927d14e75b6f8dcfc9596629a3545c2ebd9860e587195ab2d3699cb65ecde4f348e8bca4bbc35' + + # Send a notification to the original email when the user's email is changed. + # config.send_email_changed_notification = false + + # Send a notification email when the user's password is changed. + # config.send_password_change_notification = false + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming their account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming their account, + # access will be blocked just in the third day. + # You can also set it to nil, which will allow the user to access the website + # without confirming their account. + # Default is 0.days, meaning the user cannot access the website without + # confirming their account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed, new email is stored in + # unconfirmed_email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [:email] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # Invalidates all the remember me tokens when the user signs out. + config.expire_all_remember_me_on_sign_out = true + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # Options to be passed to the created cookie. For instance, you can set + # secure: true in order to force SSL only cookies. + # config.rememberable_options = {} + + # ==> Configuration for :validatable + # Range for password length. + config.password_length = 6..128 + + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [:email] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # Warn on the last attempt before the account is locked. + # config.last_attempt_warning = true + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [:email] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # When set to false, does not sign a user in automatically after their password is + # reset. Defaults to true, so a user is signed in automatically after a reset. + # config.sign_in_after_reset_password = true + + # ==> Configuration for :encryptable + # Allow you to use another hashing or encryption algorithm besides bcrypt (default). + # You can use :sha1, :sha512 or algorithms from others authentication tools as + # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 + # for default behavior) and :restful_authentication_sha1 (then you should set + # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt + # config.encryptor = :sha512 + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ['*/*', :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(scope: :user).unshift :some_external_strategy + # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using OmniAuth, Devise cannot automatically set OmniAuth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' + + # ==> Turbolinks configuration + # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly: + # + # ActiveSupport.on_load(:devise_failure_app) do + # include Turbolinks::Controller + # end + + # ==> Configuration for :registerable + + # When set to false, does not sign a user in automatically after their password is + # changed. Defaults to true, so a user is signed in automatically after changing a password. + # config.sign_in_after_change_password = true +end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 0000000..55617bd --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,65 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + devise: + confirmations: + confirmed: "Your email address has been successfully confirmed." + send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." + failure: + already_authenticated: "You are already signed in." + inactive: "Your account is not activated yet." + invalid: "Invalid %{authentication_keys} or password." + locked: "Your account is locked." + last_attempt: "You have one more attempt before your account is locked." + not_found_in_database: "Invalid %{authentication_keys} or password." + timeout: "Your session expired. Please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your email address before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock instructions" + email_changed: + subject: "Email Changed" + password_change: + subject: "Password Changed" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." + send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." + updated: "Your password has been changed successfully. You are now signed in." + updated_not_active: "Your password has been changed successfully." + registrations: + destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address." + updated: "Your account has been updated successfully." + updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again" + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + already_signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." + errors: + messages: + already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" + expired: "has expired, please request a new one" + not_found: "not found" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" diff --git a/config/routes.rb b/config/routes.rb index 787824f..c6457b7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,7 @@ Rails.application.routes.draw do + devise_for :users + resources :books + get 'home/index', as:'home' + root 'home#index' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/db/migrate/20190307143025_create_books.rb b/db/migrate/20190307143025_create_books.rb new file mode 100644 index 0000000..8c88bc4 --- /dev/null +++ b/db/migrate/20190307143025_create_books.rb @@ -0,0 +1,13 @@ +class CreateBooks < ActiveRecord::Migration[5.2] + def change + create_table :books do |t| + t.string :title + t.string :author + t.string :description + t.string :image + t.string :category + + t.timestamps + end + end +end diff --git a/db/migrate/20190307144253_devise_create_users.rb b/db/migrate/20190307144253_devise_create_users.rb new file mode 100644 index 0000000..e58d4e3 --- /dev/null +++ b/db/migrate/20190307144253_devise_create_users.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +class DeviseCreateUsers < ActiveRecord::Migration[5.2] + def change + create_table :users do |t| + ## Database authenticatable + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + # t.integer :sign_in_count, default: 0, null: false + # t.datetime :current_sign_in_at + # t.datetime :last_sign_in_at + # t.inet :current_sign_in_ip + # t.inet :last_sign_in_ip + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + + t.timestamps null: false + end + + add_index :users, :email, unique: true + add_index :users, :reset_password_token, unique: true + # add_index :users, :confirmation_token, unique: true + # add_index :users, :unlock_token, unique: true + end +end diff --git a/db/migrate/20190310114926_add_user_to_books.rb b/db/migrate/20190310114926_add_user_to_books.rb new file mode 100644 index 0000000..3dcf7e6 --- /dev/null +++ b/db/migrate/20190310114926_add_user_to_books.rb @@ -0,0 +1,5 @@ +class AddUserToBooks < ActiveRecord::Migration[5.2] + def change + add_reference :books, :user, foreign_key: true + end +end diff --git a/db/migrate/20190311122354_change_image_to_be_binary_in_books.rb b/db/migrate/20190311122354_change_image_to_be_binary_in_books.rb new file mode 100644 index 0000000..504b2c5 --- /dev/null +++ b/db/migrate/20190311122354_change_image_to_be_binary_in_books.rb @@ -0,0 +1,5 @@ +class ChangeImageToBeBinaryInBooks < ActiveRecord::Migration[5.2] + def change + change_column :books, :image, 'bytea USING CAST(image AS bytea)' + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..c4bf36f --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,43 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2019_03_11_122354) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "books", force: :cascade do |t| + t.string "title" + t.string "author" + t.string "description" + t.binary "image" + t.string "category" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "user_id" + t.index ["user_id"], name: "index_books_on_user_id" + end + + create_table "users", force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + end + + add_foreign_key "books", "users" +end diff --git a/public/uploads/book/image/10/th.jpeg b/public/uploads/book/image/10/th.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..6455d6f955d7011ac4dd693ae5fbe79cfb092d0b GIT binary patch literal 5371 zcmbW)c{CJm*f;PQgRy06WQi~)%aDw%8S5b1U@T)S6J=*q!iY>N!_N{L#!|?ZJ&f!` zii$}JF-f*$gh>(Elb(Lh^PJ~7=l$z_-|Ig2U-xzHbA8VJ$M@WSCjQI;gfSM@762d+ z2=My50Dq0~=$IHXZ&(9|yBq=N;C@6H|n7F7UOiuBnf}8?W`4mb+8Lq1e zRnR=EsjF{@MxzxqENsk;FeqcR;lGyv`T6;UjtI#J3(FX)D5x0zKi8igfCvwu4#)ul zLIE5iK#&OV&r5(T0089rJMF&%|9AcE;N;>4^YHTV|7~a$25vlI{$b+d@puA)}xVYc$XTYyz*xg5n>svvE% z_Ba~c4N}!GY8i(y>kNq%;lvW?R6nuH4m-Fp7C8n>l_i9y(C%^Ese<$b5zNG_YKRkW z<>ZvjkK5U`j5x*0^U^R1!`Sy4Y4erNe43V!dMA0297qyJIjwob`P6tufBT1&D>83U zjk`?0fLLyY@w_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zB2EjnG_L3m0#h;Iq}2Bfr6XXIkmLQ5y#J-x*qSfaL! zHQX7zh*~=>u%;INP40jZd2LP>vwSzu0oCWXT#~A`3R_hu4jz?Jb)yS>^j0qjcgw&_L{Shx2}T=n4w=xNGa}qh((WN%+NoR^ zYfI5h;Xb37Pkc$TG6!hpzE^+eNVDR(&!1HUCM+)UhCYo+v=r6ivbdCU{(hpNplYS} ocv*x~&zwJ57GviT#6nOX{M>c)#1Z=6SPxkb6X0t4#eY8j2j3~R)&Kwi literal 0 HcmV?d00001 diff --git a/public/uploads/book/image/6/th.jpeg b/public/uploads/book/image/6/th.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..6455d6f955d7011ac4dd693ae5fbe79cfb092d0b GIT binary patch literal 5371 zcmbW)c{CJm*f;PQgRy06WQi~)%aDw%8S5b1U@T)S6J=*q!iY>N!_N{L#!|?ZJ&f!` zii$}JF-f*$gh>(Elb(Lh^PJ~7=l$z_-|Ig2U-xzHbA8VJ$M@WSCjQI;gfSM@762d+ z2=My50Dq0~=$IHXZ&(9|yBq=N;C@6H|n7F7UOiuBnf}8?W`4mb+8Lq1e zRnR=EsjF{@MxzxqENsk;FeqcR;lGyv`T6;UjtI#J3(FX)D5x0zKi8igfCvwu4#)ul zLIE5iK#&OV&r5(T0089rJMF&%|9AcE;N;>4^YHTV|7~a$25vlI{$b+d@puA)}xVYc$XTYyz*xg5n>svvE% z_Ba~c4N}!GY8i(y>kNq%;lvW?R6nuH4m-Fp7C8n>l_i9y(C%^Ese<$b5zNG_YKRkW z<>ZvjkK5U`j5x*0^U^R1!`Sy4Y4erNe43V!dMA0297qyJIjwob`P6tufBT1&D>83U zjk`?0fLLyY@w_xkA&2n1PpUJEHhM@Lk)N2?7cyQO6{~c4zr`ZeYnGs z%irpwjxt_rh_i8T;`*sZEiQq@>8!gc9?NR}A>fj#gqa;uezM>eG*d4t??4Yl*` z_V<}M@wkd}oL5;iThufrD+TX4V?UakI^LY^-NNx=Yg^~hMU6rbCEd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$TG6!hpzE^+eNVDR(&!1HUCM+)UhCYo+v=r6ivbdCU{(hpNplYS} ocv*x~&zwJ57GviT#6nOX{M>c)#1Z=6SPxkb6X0t4#eY8j2j3~R)&Kwi literal 0 HcmV?d00001 diff --git a/public/uploads/book/image/8/th.jpeg b/public/uploads/book/image/8/th.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..6455d6f955d7011ac4dd693ae5fbe79cfb092d0b GIT binary patch literal 5371 zcmbW)c{CJm*f;PQgRy06WQi~)%aDw%8S5b1U@T)S6J=*q!iY>N!_N{L#!|?ZJ&f!` zii$}JF-f*$gh>(Elb(Lh^PJ~7=l$z_-|Ig2U-xzHbA8VJ$M@WSCjQI;gfSM@762d+ z2=My50Dq0~=$IHXZ&(9|yBq=N;C@6H|n7F7UOiuBnf}8?W`4mb+8Lq1e zRnR=EsjF{@MxzxqENsk;FeqcR;lGyv`T6;UjtI#J3(FX)D5x0zKi8igfCvwu4#)ul zLIE5iK#&OV&r5(T0089rJMF&%|9AcE;N;>4^YHTV|7~a$25vlI{$b+d@puA)}xVYc$XTYyz*xg5n>svvE% z_Ba~c4N}!GY8i(y>kNq%;lvW?R6nuH4m-Fp7C8n>l_i9y(C%^Ese<$b5zNG_YKRkW z<>ZvjkK5U`j5x*0^U^R1!`Sy4Y4erNe43V!dMA0297qyJIjwob`P6tufBT1&D>83U zjk`?0fLLyY@w_xkA&2n1PpUJEHhM@Lk)N2?7cyQO6{~c4zr`ZeYnGs z%irpwjxt_rh_i8T;`*sZEiQq@>8!gc9?NR}A>fj#gqa;uezM>eG*d4t??4Yl*` z_V<}M@wkd}oL5;iThufrD+TX4V?UakI^LY^-NNx=Yg^~hMU6rbCEd|uLl-L+-FKPj zF4Bglo|Cnw6Tu^Q?_8Btyw0RmEfN*%3C+@hkrzz>>7WYrY3JNw$Q(eTgzt^kWR^EL zzm-yC5#;Bh(25X?{1Q$y=xkr$FmgJgLWyPDnqN>wZddJj;45N_V#f~RG=+izmC$m8 z^k(ftp%~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kg!6^DiO?-;lJ?Gmox3Iovz8DbuQs%fYa<>d=r zvEt>P7G@AZRIPjn6}hs@bgz13Fvj7~mk0oZ{zlrVQdp_txv*)V{4;3tcO#^4y&@c6YbEHbXA$scUco&G- z;lg3NtSx%p)rZ${-gcvacVjxPXIpeMj$kFP7eCLJ2kcb1 zeOND_5LE?Yf1(z18zb5FA}qRmx>_!|G{MfX8-y=?@f24zG%uS!$So zAr98CtO3L2y4R|Fyh|w1}jxDw%_U1BRM+6mU zMvs+m@C@JVk5w@VZyQykOo3K2qHEi5)tw2Zdm~yhWg(&AT78b~R)X(u(hvM1w(GMj zRUqb~FbPSuZmq2~R~hSo#Z=z54d_;Q;$h%Vxn@=N|Kq;}X8!C0z zM~^|q$!MKv<&#vvn#XK6SzW=|`DHNU;?Y5JLF9?WPVOtVnX2heU9}{o3>!lb4;fX@ zZgvOzY2&61gDSu8zjM!afwVN$4|rOd`xq0#gL`BvZa@me`LQ9LY16u)vR`txJO@pY~{REa#Ce%le9j|@^jXJz)`fl(!FXKFO zs{J&|^ro{TWoyNj`)o~L{LzB2EjnG_L3m0#h;Iq}2Bfr6XXIkmLQ5y#J-x*qSfaL! zHQX7zh*~=>u%;INP40jZd2LP>vwSzu0oCWXT#~A`3R_hu4jz?Jb)yS>^j0qjcgw&_L{Shx2}T=n4w=xNGa}qh((WN%+NoR^ zYfI5h;Xb37Pkc$TG6!hpzE^+eNVDR(&!1HUCM+)UhCYo+v=r6ivbdCU{(hpNplYS} ocv*x~&zwJ57GviT#6nOX{M>c)#1Z=6SPxkb6X0t4#eY8j2j3~R)&Kwi literal 0 HcmV?d00001 diff --git a/test/controllers/books_controller_test.rb b/test/controllers/books_controller_test.rb new file mode 100644 index 0000000..bb21800 --- /dev/null +++ b/test/controllers/books_controller_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class BooksControllerTest < ActionDispatch::IntegrationTest + setup do + @book = books(:one) + end + + test "should get index" do + get books_url + assert_response :success + end + + test "should get new" do + get new_book_url + assert_response :success + end + + test "should create book" do + assert_difference('Book.count') do + post books_url, params: { book: { author: @book.author, category: @book.category, description: @book.description, image: @book.image, title: @book.title } } + end + + assert_redirected_to book_url(Book.last) + end + + test "should show book" do + get book_url(@book) + assert_response :success + end + + test "should get edit" do + get edit_book_url(@book) + assert_response :success + end + + test "should update book" do + patch book_url(@book), params: { book: { author: @book.author, category: @book.category, description: @book.description, image: @book.image, title: @book.title } } + assert_redirected_to book_url(@book) + end + + test "should destroy book" do + assert_difference('Book.count', -1) do + delete book_url(@book) + end + + assert_redirected_to books_url + end +end diff --git a/test/controllers/home_controller_test.rb b/test/controllers/home_controller_test.rb new file mode 100644 index 0000000..6013b68 --- /dev/null +++ b/test/controllers/home_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class HomeControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get home_index_url + assert_response :success + end + +end diff --git a/test/fixtures/books.yml b/test/fixtures/books.yml new file mode 100644 index 0000000..09a4162 --- /dev/null +++ b/test/fixtures/books.yml @@ -0,0 +1,15 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + author: MyString + description: MyString + image: MyString + category: MyString + +two: + title: MyString + author: MyString + description: MyString + image: MyString + category: MyString diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 0000000..80aed36 --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/book_test.rb b/test/models/book_test.rb new file mode 100644 index 0000000..e48079d --- /dev/null +++ b/test/models/book_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class BookTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 0000000..82f61e0 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/system/books_test.rb b/test/system/books_test.rb new file mode 100644 index 0000000..fae9142 --- /dev/null +++ b/test/system/books_test.rb @@ -0,0 +1,51 @@ +require "application_system_test_case" + +class BooksTest < ApplicationSystemTestCase + setup do + @book = books(:one) + end + + test "visiting the index" do + visit books_url + assert_selector "h1", text: "Books" + end + + test "creating a Book" do + visit books_url + click_on "New Book" + + fill_in "Author", with: @book.author + fill_in "Category", with: @book.category + fill_in "Description", with: @book.description + fill_in "Image", with: @book.image + fill_in "Title", with: @book.title + click_on "Create Book" + + assert_text "Book was successfully created" + click_on "Back" + end + + test "updating a Book" do + visit books_url + click_on "Edit", match: :first + + fill_in "Author", with: @book.author + fill_in "Category", with: @book.category + fill_in "Description", with: @book.description + fill_in "Image", with: @book.image + fill_in "Title", with: @book.title + click_on "Update Book" + + assert_text "Book was successfully updated" + click_on "Back" + end + + test "destroying a Book" do + visit books_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Book was successfully destroyed" + end +end