diff --git a/library/.gitignore b/library/.gitignore new file mode 100644 index 0000000..18b43c9 --- /dev/null +++ b/library/.gitignore @@ -0,0 +1,27 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +/node_modules +/yarn-error.log + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/library/.ruby-version b/library/.ruby-version new file mode 100644 index 0000000..b8d12d7 --- /dev/null +++ b/library/.ruby-version @@ -0,0 +1 @@ +2.6.1 \ No newline at end of file diff --git a/library/Gemfile b/library/Gemfile new file mode 100644 index 0000000..198f844 --- /dev/null +++ b/library/Gemfile @@ -0,0 +1,62 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.6.1' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.2' +# Use postgresql as the database for Active Record +gem 'pg', '>= 0.18', '< 2.0' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/library/Gemfile.lock b/library/Gemfile.lock new file mode 100644 index 0000000..26bcca3 --- /dev/null +++ b/library/Gemfile.lock @@ -0,0 +1,220 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.2) + actionpack (= 5.2.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.2) + actionview (= 5.2.2) + activesupport (= 5.2.2) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.2) + activesupport (= 5.2.2) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.2) + activesupport (= 5.2.2) + globalid (>= 0.3.6) + activemodel (5.2.2) + activesupport (= 5.2.2) + activerecord (5.2.2) + activemodel (= 5.2.2) + activesupport (= 5.2.2) + arel (>= 9.0) + activestorage (5.2.2) + actionpack (= 5.2.2) + activerecord (= 5.2.2) + marcel (~> 0.3.1) + activesupport (5.2.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.6.0) + public_suffix (>= 2.0.2, < 4.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + bindex (0.5.0) + bootsnap (1.4.1) + msgpack (~> 1.0) + builder (3.2.3) + byebug (11.0.0) + capybara (3.14.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.2) + xpath (~> 3.2) + childprocess (0.9.0) + ffi (~> 1.0, >= 1.0.11) + chromedriver-helper (2.1.0) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.4) + crass (1.0.4) + erubi (1.8.0) + execjs (2.7.0) + ffi (1.10.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.6.0) + concurrent-ruby (~> 1.0) + io-like (0.3.0) + jbuilder (2.8.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.2.3) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mimemagic (0.3.3) + mini_mime (1.0.1) + mini_portile2 (2.4.0) + minitest (5.11.3) + msgpack (1.2.7) + multi_json (1.13.1) + nio4r (2.3.1) + nokogiri (1.10.1) + mini_portile2 (~> 2.4.0) + pg (1.1.4) + public_suffix (3.0.3) + puma (3.12.0) + rack (2.0.6) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.2) + actioncable (= 5.2.2) + actionmailer (= 5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + activemodel (= 5.2.2) + activerecord (= 5.2.2) + activestorage (= 5.2.2) + activesupport (= 5.2.2) + bundler (>= 1.3.0) + railties (= 5.2.2) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + railties (5.2.2) + actionpack (= 5.2.2) + activesupport (= 5.2.2) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (12.3.2) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + regexp_parser (1.3.0) + ruby_dep (1.5.0) + rubyzip (1.2.2) + sass (3.7.3) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.141.0) + childprocess (~> 0.5) + rubyzip (~> 1.2, >= 1.2.2) + spring (2.0.2) + activesupport (>= 4.2) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.9) + turbolinks (5.2.0) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uglifier (4.1.20) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + coffee-rails (~> 4.2) + jbuilder (~> 2.5) + listen (>= 3.0.5, < 3.2) + pg (>= 0.18, < 2.0) + puma (~> 3.11) + rails (~> 5.2.2) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.6.1p33 + +BUNDLED WITH + 1.17.2 diff --git a/library/README.md b/library/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/library/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/library/Rakefile b/library/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/library/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/library/app/assets/config/manifest.js b/library/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/library/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/library/app/assets/images/.keep b/library/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/app/assets/javascripts/application.js b/library/app/assets/javascripts/application.js new file mode 100644 index 0000000..82e6f0f --- /dev/null +++ b/library/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's +// vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/library/app/assets/javascripts/articles.coffee b/library/app/assets/javascripts/articles.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/articles.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/library/app/assets/javascripts/books.coffee b/library/app/assets/javascripts/books.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/books.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/library/app/assets/javascripts/cable.js b/library/app/assets/javascripts/cable.js new file mode 100644 index 0000000..739aa5f --- /dev/null +++ b/library/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/library/app/assets/javascripts/channels/.keep b/library/app/assets/javascripts/channels/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/app/assets/javascripts/comments.coffee b/library/app/assets/javascripts/comments.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/comments.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/library/app/assets/javascripts/ingredients.coffee b/library/app/assets/javascripts/ingredients.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/ingredients.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/library/app/assets/javascripts/movies.coffee b/library/app/assets/javascripts/movies.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/movies.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/library/app/assets/javascripts/paintings.coffee b/library/app/assets/javascripts/paintings.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/library/app/assets/javascripts/paintings.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/library/app/assets/stylesheets/application.css b/library/app/assets/stylesheets/application.css new file mode 100644 index 0000000..d05ea0f --- /dev/null +++ b/library/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/library/app/assets/stylesheets/articles.scss b/library/app/assets/stylesheets/articles.scss new file mode 100644 index 0000000..cca5487 --- /dev/null +++ b/library/app/assets/stylesheets/articles.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the articles controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/books.scss b/library/app/assets/stylesheets/books.scss new file mode 100644 index 0000000..81379d1 --- /dev/null +++ b/library/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/library/app/assets/stylesheets/comments.scss b/library/app/assets/stylesheets/comments.scss new file mode 100644 index 0000000..e730912 --- /dev/null +++ b/library/app/assets/stylesheets/comments.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Comments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/ingredients.scss b/library/app/assets/stylesheets/ingredients.scss new file mode 100644 index 0000000..98f8d50 --- /dev/null +++ b/library/app/assets/stylesheets/ingredients.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the ingredients controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/movies.scss b/library/app/assets/stylesheets/movies.scss new file mode 100644 index 0000000..70aaa8a --- /dev/null +++ b/library/app/assets/stylesheets/movies.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the movies controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/paintings.scss b/library/app/assets/stylesheets/paintings.scss new file mode 100644 index 0000000..a1e9084 --- /dev/null +++ b/library/app/assets/stylesheets/paintings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the paintings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/library/app/assets/stylesheets/scaffolds.scss b/library/app/assets/stylesheets/scaffolds.scss new file mode 100644 index 0000000..6045188 --- /dev/null +++ b/library/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/library/app/channels/application_cable/channel.rb b/library/app/channels/application_cable/channel.rb new file mode 100644 index 0000000..d672697 --- /dev/null +++ b/library/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/library/app/channels/application_cable/connection.rb b/library/app/channels/application_cable/connection.rb new file mode 100644 index 0000000..0ff5442 --- /dev/null +++ b/library/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/library/app/controllers/application_controller.rb b/library/app/controllers/application_controller.rb new file mode 100644 index 0000000..09705d1 --- /dev/null +++ b/library/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/library/app/controllers/articles_controller.rb b/library/app/controllers/articles_controller.rb new file mode 100644 index 0000000..4536962 --- /dev/null +++ b/library/app/controllers/articles_controller.rb @@ -0,0 +1,74 @@ +class ArticlesController < ApplicationController + before_action :set_article, only: [:show, :edit, :update, :destroy] + + # GET /articles + # GET /articles.json + def index + @articles = Article.all + end + + # GET /articles/1 + # GET /articles/1.json + def show + end + + # GET /articles/new + def new + @article = Article.new + end + + # GET /articles/1/edit + def edit + end + + # POST /articles + # POST /articles.json + def create + @article = Article.new(article_params) + + respond_to do |format| + if @article.save + format.html { redirect_to @article, notice: 'Article was successfully created.' } + format.json { render :show, status: :created, location: @article } + else + format.html { render :new } + format.json { render json: @article.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /articles/1 + # PATCH/PUT /articles/1.json + def update + respond_to do |format| + if @article.update(article_params) + format.html { redirect_to @article, notice: 'Article was successfully updated.' } + format.json { render :show, status: :ok, location: @article } + else + format.html { render :edit } + format.json { render json: @article.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /articles/1 + # DELETE /articles/1.json + def destroy + @article.destroy + respond_to do |format| + format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_article + @article = Article.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def article_params + params.require(:article).permit(:title, :text) + end +end diff --git a/library/app/controllers/books_controller.rb b/library/app/controllers/books_controller.rb new file mode 100644 index 0000000..9f5aace --- /dev/null +++ b/library/app/controllers/books_controller.rb @@ -0,0 +1,74 @@ +class BooksController < ApplicationController + before_action :set_book, only: [:show, :edit, :update, :destroy] + + # GET /books + # GET /books.json + def index + @books = Book.all + end + + # GET /books/1 + # GET /books/1.json + def show + end + + # GET /books/new + def new + @book = Book.new + end + + # GET /books/1/edit + def edit + end + + # POST /books + # POST /books.json + def create + @book = Book.new(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) + end +end diff --git a/library/app/controllers/comments_controller.rb b/library/app/controllers/comments_controller.rb new file mode 100644 index 0000000..b89253e --- /dev/null +++ b/library/app/controllers/comments_controller.rb @@ -0,0 +1,21 @@ +class CommentsController < ApplicationController + + def create + @article = Article.find(params[:article_id]) + @comment = @article.comments.create(comment_params) + redirect_to article_path(@article) + end + + def destroy + @article = Article.find(params[:article_id]) + @comment = @article.comments.find(params[:id]) + @comment.destroy + redirect_to article_path(@article) + end + + private + def comment_params + params.require(:comment).permit(:commenter, :body) + end + +end diff --git a/library/app/controllers/concerns/.keep b/library/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/app/controllers/ingredients_controller.rb b/library/app/controllers/ingredients_controller.rb new file mode 100644 index 0000000..c479ade --- /dev/null +++ b/library/app/controllers/ingredients_controller.rb @@ -0,0 +1,74 @@ +class IngredientsController < ApplicationController + before_action :set_ingredient, only: [:show, :edit, :update, :destroy] + + # GET /ingredients + # GET /ingredients.json + def index + @ingredients = Ingredient.all + end + + # GET /ingredients/1 + # GET /ingredients/1.json + def show + end + + # GET /ingredients/new + def new + @ingredient = Ingredient.new + end + + # GET /ingredients/1/edit + def edit + end + + # POST /ingredients + # POST /ingredients.json + def create + @ingredient = Ingredient.new(ingredient_params) + + respond_to do |format| + if @ingredient.save + format.html { redirect_to @ingredient, notice: 'Ingredient was successfully created.' } + format.json { render :show, status: :created, location: @ingredient } + else + format.html { render :new } + format.json { render json: @ingredient.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /ingredients/1 + # PATCH/PUT /ingredients/1.json + def update + respond_to do |format| + if @ingredient.update(ingredient_params) + format.html { redirect_to @ingredient, notice: 'Ingredient was successfully updated.' } + format.json { render :show, status: :ok, location: @ingredient } + else + format.html { render :edit } + format.json { render json: @ingredient.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /ingredients/1 + # DELETE /ingredients/1.json + def destroy + @ingredient.destroy + respond_to do |format| + format.html { redirect_to ingredients_url, notice: 'Ingredient was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_ingredient + @ingredient = Ingredient.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def ingredient_params + params.require(:ingredient).permit(:name, :unit, :amount, :purchased_on, :is_rotten) + end +end diff --git a/library/app/controllers/movies_controller.rb b/library/app/controllers/movies_controller.rb new file mode 100644 index 0000000..5b6fc06 --- /dev/null +++ b/library/app/controllers/movies_controller.rb @@ -0,0 +1,74 @@ +class MoviesController < ApplicationController + before_action :set_movie, only: [:show, :edit, :update, :destroy] + + # GET /movies + # GET /movies.json + def index + @movies = Movie.all + end + + # GET /movies/1 + # GET /movies/1.json + def show + end + + # GET /movies/new + def new + @movie = Movie.new + end + + # GET /movies/1/edit + def edit + end + + # POST /movies + # POST /movies.json + def create + @movie = Movie.new(movie_params) + + respond_to do |format| + if @movie.save + format.html { redirect_to @movie, notice: 'Movie was successfully created.' } + format.json { render :show, status: :created, location: @movie } + else + format.html { render :new } + format.json { render json: @movie.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /movies/1 + # PATCH/PUT /movies/1.json + def update + respond_to do |format| + if @movie.update(movie_params) + format.html { redirect_to @movie, notice: 'Movie was successfully updated.' } + format.json { render :show, status: :ok, location: @movie } + else + format.html { render :edit } + format.json { render json: @movie.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /movies/1 + # DELETE /movies/1.json + def destroy + @movie.destroy + respond_to do |format| + format.html { redirect_to movies_url, notice: 'Movie was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_movie + @movie = Movie.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def movie_params + params.require(:movie).permit(:director, :title, :rating) + end +end diff --git a/library/app/controllers/paintings_controller.rb b/library/app/controllers/paintings_controller.rb new file mode 100644 index 0000000..d801653 --- /dev/null +++ b/library/app/controllers/paintings_controller.rb @@ -0,0 +1,74 @@ +class PaintingsController < ApplicationController + before_action :set_painting, only: [:show, :edit, :update, :destroy] + + # GET /paintings + # GET /paintings.json + def index + @paintings = Painting.all + end + + # GET /paintings/1 + # GET /paintings/1.json + def show + end + + # GET /paintings/new + def new + @painting = Painting.new + end + + # GET /paintings/1/edit + def edit + end + + # POST /paintings + # POST /paintings.json + def create + @painting = Painting.new(painting_params) + + respond_to do |format| + if @painting.save + format.html { redirect_to @painting, notice: 'Painting was successfully created.' } + format.json { render :show, status: :created, location: @painting } + else + format.html { render :new } + format.json { render json: @painting.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /paintings/1 + # PATCH/PUT /paintings/1.json + def update + respond_to do |format| + if @painting.update(painting_params) + format.html { redirect_to @painting, notice: 'Painting was successfully updated.' } + format.json { render :show, status: :ok, location: @painting } + else + format.html { render :edit } + format.json { render json: @painting.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /paintings/1 + # DELETE /paintings/1.json + def destroy + @painting.destroy + respond_to do |format| + format.html { redirect_to paintings_url, notice: 'Painting was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_painting + @painting = Painting.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def painting_params + params.require(:painting).permit(:title, :artist) + end +end diff --git a/library/app/helpers/application_helper.rb b/library/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/library/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/library/app/helpers/articles_helper.rb b/library/app/helpers/articles_helper.rb new file mode 100644 index 0000000..2968277 --- /dev/null +++ b/library/app/helpers/articles_helper.rb @@ -0,0 +1,2 @@ +module ArticlesHelper +end diff --git a/library/app/helpers/books_helper.rb b/library/app/helpers/books_helper.rb new file mode 100644 index 0000000..4b9311e --- /dev/null +++ b/library/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/library/app/helpers/comments_helper.rb b/library/app/helpers/comments_helper.rb new file mode 100644 index 0000000..0ec9ca5 --- /dev/null +++ b/library/app/helpers/comments_helper.rb @@ -0,0 +1,2 @@ +module CommentsHelper +end diff --git a/library/app/helpers/ingredients_helper.rb b/library/app/helpers/ingredients_helper.rb new file mode 100644 index 0000000..dd54783 --- /dev/null +++ b/library/app/helpers/ingredients_helper.rb @@ -0,0 +1,2 @@ +module IngredientsHelper +end diff --git a/library/app/helpers/movies_helper.rb b/library/app/helpers/movies_helper.rb new file mode 100644 index 0000000..493eee5 --- /dev/null +++ b/library/app/helpers/movies_helper.rb @@ -0,0 +1,2 @@ +module MoviesHelper +end diff --git a/library/app/helpers/paintings_helper.rb b/library/app/helpers/paintings_helper.rb new file mode 100644 index 0000000..cfbc294 --- /dev/null +++ b/library/app/helpers/paintings_helper.rb @@ -0,0 +1,2 @@ +module PaintingsHelper +end diff --git a/library/app/jobs/application_job.rb b/library/app/jobs/application_job.rb new file mode 100644 index 0000000..a009ace --- /dev/null +++ b/library/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/library/app/mailers/application_mailer.rb b/library/app/mailers/application_mailer.rb new file mode 100644 index 0000000..286b223 --- /dev/null +++ b/library/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/library/app/models/application_record.rb b/library/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/library/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/library/app/models/article.rb b/library/app/models/article.rb new file mode 100644 index 0000000..32b3c0c --- /dev/null +++ b/library/app/models/article.rb @@ -0,0 +1,5 @@ +class Article < ApplicationRecord + has_many :comments, dependent: :destroy + validates :title, presence: true, + length: { minimum: 5 } +end \ No newline at end of file diff --git a/library/app/models/book.rb b/library/app/models/book.rb new file mode 100644 index 0000000..03d56b4 --- /dev/null +++ b/library/app/models/book.rb @@ -0,0 +1,2 @@ +class Book < ApplicationRecord +end diff --git a/library/app/models/comment.rb b/library/app/models/comment.rb new file mode 100644 index 0000000..889a476 --- /dev/null +++ b/library/app/models/comment.rb @@ -0,0 +1,3 @@ +class Comment < ApplicationRecord + belongs_to :article +end diff --git a/library/app/models/concerns/.keep b/library/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/app/models/ingredient.rb b/library/app/models/ingredient.rb new file mode 100644 index 0000000..a1faeb5 --- /dev/null +++ b/library/app/models/ingredient.rb @@ -0,0 +1,2 @@ +class Ingredient < ApplicationRecord +end diff --git a/library/app/models/movie.rb b/library/app/models/movie.rb new file mode 100644 index 0000000..dc614df --- /dev/null +++ b/library/app/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ApplicationRecord +end diff --git a/library/app/models/painting.rb b/library/app/models/painting.rb new file mode 100644 index 0000000..9daeb53 --- /dev/null +++ b/library/app/models/painting.rb @@ -0,0 +1,2 @@ +class Painting < ApplicationRecord +end diff --git a/library/app/views/articles/_article.json.jbuilder b/library/app/views/articles/_article.json.jbuilder new file mode 100644 index 0000000..8f4e2e8 --- /dev/null +++ b/library/app/views/articles/_article.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! article, :id, :title, :text, :created_at, :updated_at +json.url article_url(article, format: :json) diff --git a/library/app/views/articles/_form.html.erb b/library/app/views/articles/_form.html.erb new file mode 100644 index 0000000..7ece14a --- /dev/null +++ b/library/app/views/articles/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: article, local: true) do |form| %> + <% if article.errors.any? %> +
+

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

+ + +
+ <% end %> + +
+ <%= form.label :title %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :text %> + <%= form.text_field :text %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/library/app/views/articles/edit.html.erb b/library/app/views/articles/edit.html.erb new file mode 100644 index 0000000..65565c0 --- /dev/null +++ b/library/app/views/articles/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Article

+ +<%= render 'form', article: @article %> + +<%= link_to 'Show', @article %> | +<%= link_to 'Back', articles_path %> diff --git a/library/app/views/articles/index.html.erb b/library/app/views/articles/index.html.erb new file mode 100644 index 0000000..ab60d0b --- /dev/null +++ b/library/app/views/articles/index.html.erb @@ -0,0 +1,36 @@ +

<%= notice %>

+ +

Articles

+ + + + + + + + + + + + <% @articles.each do |article| %> + + + + + + + + <% end %> + +
TitleText
<%= article.title %><%= article.text %><%= link_to 'Show', article %><%= link_to 'Edit', edit_article_path(article) %><%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Article', new_article_path %> + + \ No newline at end of file diff --git a/library/app/views/articles/index.json.jbuilder b/library/app/views/articles/index.json.jbuilder new file mode 100644 index 0000000..4b23e9e --- /dev/null +++ b/library/app/views/articles/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @articles, partial: 'articles/article', as: :article diff --git a/library/app/views/articles/new.html.erb b/library/app/views/articles/new.html.erb new file mode 100644 index 0000000..056f863 --- /dev/null +++ b/library/app/views/articles/new.html.erb @@ -0,0 +1,5 @@ +

New Article

+ +<%= render 'form', article: @article %> + +<%= link_to 'Back', articles_path %> diff --git a/library/app/views/articles/show.html.erb b/library/app/views/articles/show.html.erb new file mode 100644 index 0000000..7d7b182 --- /dev/null +++ b/library/app/views/articles/show.html.erb @@ -0,0 +1,18 @@ +

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

+ +

+ Text: + <%= @article.text %> +

+ +

Comments

+<%= render @article.comments %> + +

Add a comment:

+<%= render 'comments/form' %> + +<%= link_to 'Edit', edit_article_path(@article) %> | +<%= link_to 'Back', articles_path %> \ No newline at end of file diff --git a/library/app/views/articles/show.json.jbuilder b/library/app/views/articles/show.json.jbuilder new file mode 100644 index 0000000..dd1fbb4 --- /dev/null +++ b/library/app/views/articles/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "articles/article", article: @article diff --git a/library/app/views/books/_book.json.jbuilder b/library/app/views/books/_book.json.jbuilder new file mode 100644 index 0000000..d0931c3 --- /dev/null +++ b/library/app/views/books/_book.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! book, :id, :title, :author, :created_at, :updated_at +json.url book_url(book, format: :json) diff --git a/library/app/views/books/_form.html.erb b/library/app/views/books/_form.html.erb new file mode 100644 index 0000000..86872f5 --- /dev/null +++ b/library/app/views/books/_form.html.erb @@ -0,0 +1,27 @@ +<%= 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.submit %> +
+<% end %> diff --git a/library/app/views/books/edit.html.erb b/library/app/views/books/edit.html.erb new file mode 100644 index 0000000..ff28963 --- /dev/null +++ b/library/app/views/books/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Book

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

<%= notice %>

+ +

Books

+ + + + + + + + + + + + <% @books.each do |book| %> + + + + + + + + <% end %> + +
TitleAuthor
<%= book.title %><%= book.author %><%= 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/library/app/views/books/index.json.jbuilder b/library/app/views/books/index.json.jbuilder new file mode 100644 index 0000000..7ee9cfe --- /dev/null +++ b/library/app/views/books/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @books, partial: 'books/book', as: :book diff --git a/library/app/views/books/new.html.erb b/library/app/views/books/new.html.erb new file mode 100644 index 0000000..9607d41 --- /dev/null +++ b/library/app/views/books/new.html.erb @@ -0,0 +1,5 @@ +

New Book

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

<%= notice %>

+ +

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

+ +

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

+ +<%= link_to 'Edit', edit_book_path(@book) %> | +<%= link_to 'Back', books_path %> diff --git a/library/app/views/books/show.json.jbuilder b/library/app/views/books/show.json.jbuilder new file mode 100644 index 0000000..c1e5174 --- /dev/null +++ b/library/app/views/books/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "books/book", book: @book diff --git a/library/app/views/comments/_comment.html.erb b/library/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..77eb04a --- /dev/null +++ b/library/app/views/comments/_comment.html.erb @@ -0,0 +1,15 @@ +

+ Commenter: + <%= comment.commenter %> +

+ +

+ Comment: + <%= comment.body %> +

+ +

+ <%= link_to 'Destroy Comment', [comment.article, comment], + method: :delete, + data: { confirm: 'Are you sure?' } %> +

\ No newline at end of file diff --git a/library/app/views/comments/_form.html.erb b/library/app/views/comments/_form.html.erb new file mode 100644 index 0000000..7feef50 --- /dev/null +++ b/library/app/views/comments/_form.html.erb @@ -0,0 +1,13 @@ +<%= form_with(model: [ @article, @article.comments.build ], local: true) do |form| %> +

+ <%= form.label :commenter %>
+ <%= form.text_field :commenter %> +

+

+ <%= form.label :body %>
+ <%= form.text_area :body %> +

+

+ <%= form.submit %> +

+<% end %> \ No newline at end of file diff --git a/library/app/views/ingredients/_form.html.erb b/library/app/views/ingredients/_form.html.erb new file mode 100644 index 0000000..ccae3aa --- /dev/null +++ b/library/app/views/ingredients/_form.html.erb @@ -0,0 +1,42 @@ +<%= form_with(model: ingredient, local: true) do |form| %> + <% if ingredient.errors.any? %> +
+

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

+ + +
+ <% end %> + +
+ <%= form.label :name %> + <%= form.text_field :name %> +
+ +
+ <%= form.label :unit %> + <%= form.text_field :unit %> +
+ +
+ <%= form.label :amount %> + <%= form.number_field :amount %> +
+ +
+ <%= form.label :purchased_on %> + <%= form.date_select :purchased_on %> +
+ +
+ <%= form.label :is_rotten %> + <%= form.check_box :is_rotten %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/library/app/views/ingredients/_ingredient.json.jbuilder b/library/app/views/ingredients/_ingredient.json.jbuilder new file mode 100644 index 0000000..ed38a4e --- /dev/null +++ b/library/app/views/ingredients/_ingredient.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! ingredient, :id, :name, :unit, :amount, :purchased_on, :is_rotten, :created_at, :updated_at +json.url ingredient_url(ingredient, format: :json) diff --git a/library/app/views/ingredients/edit.html.erb b/library/app/views/ingredients/edit.html.erb new file mode 100644 index 0000000..6a7bff5 --- /dev/null +++ b/library/app/views/ingredients/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Ingredient

+ +<%= render 'form', ingredient: @ingredient %> + +<%= link_to 'Show', @ingredient %> | +<%= link_to 'Back', ingredients_path %> diff --git a/library/app/views/ingredients/index.html.erb b/library/app/views/ingredients/index.html.erb new file mode 100644 index 0000000..0fe394c --- /dev/null +++ b/library/app/views/ingredients/index.html.erb @@ -0,0 +1,43 @@ +

<%= notice %>

+ +

Ingredients

+ + + + + + + + + + + + + + + <% @ingredients.each do |ingredient| %> + + + + + + + + + + + <% end %> + +
NameUnitAmountPurchased onIs rotten
<%= ingredient.name %><%= ingredient.unit %><%= ingredient.amount %><%= ingredient.purchased_on %><%= ingredient.is_rotten %><%= link_to 'Show', ingredient %><%= link_to 'Edit', edit_ingredient_path(ingredient) %><%= link_to 'Destroy', ingredient, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Ingredient', new_ingredient_path %> + + + \ No newline at end of file diff --git a/library/app/views/ingredients/index.json.jbuilder b/library/app/views/ingredients/index.json.jbuilder new file mode 100644 index 0000000..ce491b1 --- /dev/null +++ b/library/app/views/ingredients/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @ingredients, partial: 'ingredients/ingredient', as: :ingredient diff --git a/library/app/views/ingredients/new.html.erb b/library/app/views/ingredients/new.html.erb new file mode 100644 index 0000000..cc32807 --- /dev/null +++ b/library/app/views/ingredients/new.html.erb @@ -0,0 +1,5 @@ +

New Ingredient

+ +<%= render 'form', ingredient: @ingredient %> + +<%= link_to 'Back', ingredients_path %> diff --git a/library/app/views/ingredients/show.html.erb b/library/app/views/ingredients/show.html.erb new file mode 100644 index 0000000..65310d9 --- /dev/null +++ b/library/app/views/ingredients/show.html.erb @@ -0,0 +1,29 @@ +

<%= notice %>

+ +

+ Name: + <%= @ingredient.name %> +

+ +

+ Unit: + <%= @ingredient.unit %> +

+ +

+ Amount: + <%= @ingredient.amount %> +

+ +

+ Purchased on: + <%= @ingredient.purchased_on %> +

+ +

+ Is rotten: + <%= @ingredient.is_rotten %> +

+ +<%= link_to 'Edit', edit_ingredient_path(@ingredient) %> | +<%= link_to 'Back', ingredients_path %> diff --git a/library/app/views/ingredients/show.json.jbuilder b/library/app/views/ingredients/show.json.jbuilder new file mode 100644 index 0000000..6ab0df7 --- /dev/null +++ b/library/app/views/ingredients/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "ingredients/ingredient", ingredient: @ingredient diff --git a/library/app/views/layouts/application.html.erb b/library/app/views/layouts/application.html.erb new file mode 100644 index 0000000..871b419 --- /dev/null +++ b/library/app/views/layouts/application.html.erb @@ -0,0 +1,15 @@ + + + + Library + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + <%= yield %> + + diff --git a/library/app/views/layouts/mailer.html.erb b/library/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/library/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/library/app/views/layouts/mailer.text.erb b/library/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/library/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/library/app/views/movies/_form.html.erb b/library/app/views/movies/_form.html.erb new file mode 100644 index 0000000..c17f8c3 --- /dev/null +++ b/library/app/views/movies/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: movie, local: true) do |form| %> + <% if movie.errors.any? %> +
+

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

+ + +
+ <% end %> + +
+ <%= form.label :director %> + <%= form.text_field :director %> +
+ +
+ <%= form.label :title %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :rating %> + <%= form.number_field :rating %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/library/app/views/movies/_movie.json.jbuilder b/library/app/views/movies/_movie.json.jbuilder new file mode 100644 index 0000000..f1c2834 --- /dev/null +++ b/library/app/views/movies/_movie.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! movie, :id, :director, :title, :rating, :created_at, :updated_at +json.url movie_url(movie, format: :json) diff --git a/library/app/views/movies/edit.html.erb b/library/app/views/movies/edit.html.erb new file mode 100644 index 0000000..c0c134b --- /dev/null +++ b/library/app/views/movies/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Movie

+ +<%= render 'form', movie: @movie %> + +<%= link_to 'Show', @movie %> | +<%= link_to 'Back', movies_path %> diff --git a/library/app/views/movies/index.html.erb b/library/app/views/movies/index.html.erb new file mode 100644 index 0000000..f02223b --- /dev/null +++ b/library/app/views/movies/index.html.erb @@ -0,0 +1,38 @@ +

<%= notice %>

+ +

Movies

+ + + + + + + + + + + + + <% @movies.each do |movie| %> + + + + + + + + + <% end %> + +
DirectorTitleRating
<%= movie.director %><%= movie.title %><%= movie.rating %><%= link_to 'Show', movie %><%= link_to 'Edit', edit_movie_path(movie) %><%= link_to 'Destroy', movie, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Movie', new_movie_path %> + + diff --git a/library/app/views/movies/index.json.jbuilder b/library/app/views/movies/index.json.jbuilder new file mode 100644 index 0000000..73306be --- /dev/null +++ b/library/app/views/movies/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @movies, partial: 'movies/movie', as: :movie diff --git a/library/app/views/movies/new.html.erb b/library/app/views/movies/new.html.erb new file mode 100644 index 0000000..eb60970 --- /dev/null +++ b/library/app/views/movies/new.html.erb @@ -0,0 +1,5 @@ +

New Movie

+ +<%= render 'form', movie: @movie %> + +<%= link_to 'Back', movies_path %> diff --git a/library/app/views/movies/show.html.erb b/library/app/views/movies/show.html.erb new file mode 100644 index 0000000..dba9c11 --- /dev/null +++ b/library/app/views/movies/show.html.erb @@ -0,0 +1,19 @@ +

<%= notice %>

+ +

+ Director: + <%= @movie.director %> +

+ +

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

+ +

+ Rating: + <%= @movie.rating %> +

+ +<%= link_to 'Edit', edit_movie_path(@movie) %> | +<%= link_to 'Back', movies_path %> diff --git a/library/app/views/movies/show.json.jbuilder b/library/app/views/movies/show.json.jbuilder new file mode 100644 index 0000000..cec988f --- /dev/null +++ b/library/app/views/movies/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "movies/movie", movie: @movie diff --git a/library/app/views/paintings/_form.html.erb b/library/app/views/paintings/_form.html.erb new file mode 100644 index 0000000..58887c0 --- /dev/null +++ b/library/app/views/paintings/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: painting, local: true) do |form| %> + <% if painting.errors.any? %> +
+

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

+ + +
+ <% end %> + +
+ <%= form.label :title %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :artist %> + <%= form.text_field :artist %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/library/app/views/paintings/_painting.json.jbuilder b/library/app/views/paintings/_painting.json.jbuilder new file mode 100644 index 0000000..aee1413 --- /dev/null +++ b/library/app/views/paintings/_painting.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! painting, :id, :title, :artist, :created_at, :updated_at +json.url painting_url(painting, format: :json) diff --git a/library/app/views/paintings/edit.html.erb b/library/app/views/paintings/edit.html.erb new file mode 100644 index 0000000..048e187 --- /dev/null +++ b/library/app/views/paintings/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Painting

+ +<%= render 'form', painting: @painting %> + +<%= link_to 'Show', @painting %> | +<%= link_to 'Back', paintings_path %> diff --git a/library/app/views/paintings/index.html.erb b/library/app/views/paintings/index.html.erb new file mode 100644 index 0000000..ab2ce35 --- /dev/null +++ b/library/app/views/paintings/index.html.erb @@ -0,0 +1,36 @@ +

<%= notice %>

+ +

Paintings

+ + + + + + + + + + + + <% @paintings.each do |painting| %> + + + + + + + + <% end %> + +
TitleArtist
<%= painting.title %><%= painting.artist %><%= link_to 'Show', painting %><%= link_to 'Edit', edit_painting_path(painting) %><%= link_to 'Destroy', painting, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Painting', new_painting_path %> + + diff --git a/library/app/views/paintings/index.json.jbuilder b/library/app/views/paintings/index.json.jbuilder new file mode 100644 index 0000000..bf67c58 --- /dev/null +++ b/library/app/views/paintings/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @paintings, partial: 'paintings/painting', as: :painting diff --git a/library/app/views/paintings/new.html.erb b/library/app/views/paintings/new.html.erb new file mode 100644 index 0000000..f0415bb --- /dev/null +++ b/library/app/views/paintings/new.html.erb @@ -0,0 +1,5 @@ +

New Painting

+ +<%= render 'form', painting: @painting %> + +<%= link_to 'Back', paintings_path %> diff --git a/library/app/views/paintings/show.html.erb b/library/app/views/paintings/show.html.erb new file mode 100644 index 0000000..5907763 --- /dev/null +++ b/library/app/views/paintings/show.html.erb @@ -0,0 +1,14 @@ +

<%= notice %>

+ +

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

+ +

+ Artist: + <%= @painting.artist %> +

+ +<%= link_to 'Edit', edit_painting_path(@painting) %> | +<%= link_to 'Back', paintings_path %> diff --git a/library/app/views/paintings/show.json.jbuilder b/library/app/views/paintings/show.json.jbuilder new file mode 100644 index 0000000..d06beba --- /dev/null +++ b/library/app/views/paintings/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "paintings/painting", painting: @painting diff --git a/library/bin/bundle b/library/bin/bundle new file mode 100755 index 0000000..f19acf5 --- /dev/null +++ b/library/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/library/bin/rails b/library/bin/rails new file mode 100755 index 0000000..5badb2f --- /dev/null +++ b/library/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/library/bin/rake b/library/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/library/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/library/bin/setup b/library/bin/setup new file mode 100755 index 0000000..94fd4d7 --- /dev/null +++ b/library/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/library/bin/spring b/library/bin/spring new file mode 100755 index 0000000..fb2ec2e --- /dev/null +++ b/library/bin/spring @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) + spring = lockfile.specs.detect { |spec| spec.name == "spring" } + if spring + Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path + gem 'spring', spring.version + require 'spring/binstub' + end +end diff --git a/library/bin/update b/library/bin/update new file mode 100755 index 0000000..58bfaed --- /dev/null +++ b/library/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/library/bin/yarn b/library/bin/yarn new file mode 100755 index 0000000..460dd56 --- /dev/null +++ b/library/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/library/config.ru b/library/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/library/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/library/config/application.rb b/library/config/application.rb new file mode 100644 index 0000000..493beb8 --- /dev/null +++ b/library/config/application.rb @@ -0,0 +1,19 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Library + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.2 + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + end +end diff --git a/library/config/boot.rb b/library/config/boot.rb new file mode 100644 index 0000000..b9e460c --- /dev/null +++ b/library/config/boot.rb @@ -0,0 +1,4 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/library/config/cable.yml b/library/config/cable.yml new file mode 100644 index 0000000..8e41465 --- /dev/null +++ b/library/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: library_production diff --git a/library/config/credentials.yml.enc b/library/config/credentials.yml.enc new file mode 100644 index 0000000..104c71a --- /dev/null +++ b/library/config/credentials.yml.enc @@ -0,0 +1 @@ +Rh6FjIasxlTZ+NYEtk44iencCAezz+Ev7A+UECf9cPMncHGjqI+0sMScqWCdvW8Q9wD8qIhSRftZzlBNP+L8Wek2GxZiK6YGfYEJHJ4CnHjFyun6fO/7Sz8HXFgnMDE6aqNloLuTieCWpWOwoyK2YbxEacYYGgF4/tgWroPwSpPA2PpnuJjjUIlc9AbQt6XGP+sl5TvhpbWn8mz321yB33nIwgWjG+iGFICt7DjdG4o+2zmc67V1Sw2TlxhH7dSYE7qobrVHKYawxyffTz8Ce00qp1CxCkHd7FQF4HdqeWK5O2MJsY4LH1YlfzELa7ZjG2cKebpFxPgb9W3sPIEiX2gAlLo22xFFswVpNUQXjeE60SJiBSw2tBMy5IXCvvhzZW/G5krdEJI6CPNTF3JpcLeMwIjGbvJlDxZc--yiwhJS6YqZNWZyWC--YTAhom8pQN5DLFhAkBbU8A== \ No newline at end of file diff --git a/library/config/database.yml b/library/config/database.yml new file mode 100644 index 0000000..0265599 --- /dev/null +++ b/library/config/database.yml @@ -0,0 +1,85 @@ +# PostgreSQL. Versions 9.1 and up are supported. +# +# Install the pg driver: +# gem install pg +# On OS X with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config +# On Windows: +# gem install pg +# Choose the win32 build. +# Install PostgreSQL and put its /bin directory on your path. +# +# Configure Using Gemfile +# gem 'pg' +# +default: &default + adapter: postgresql + encoding: unicode + # For details on connection pooling, see Rails configuration guide + # http://guides.rubyonrails.org/configuring.html#database-pooling + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + +development: + <<: *default + database: library_development + + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user that initialized the database. + #username: library + + # The password associated with the postgres role (username). + #password: + + # Connect on a TCP socket. Omitted by default since the client uses a + # domain socket that doesn't need configuration. Windows does not have + # domain sockets, so uncomment these lines. + #host: localhost + + # The TCP port the server listens on. Defaults to 5432. + # If your server runs on a different port number, change accordingly. + #port: 5432 + + # Schema search path. The server defaults to $user,public + #schema_search_path: myapp,sharedapp,public + + # Minimum log levels, in increasing order: + # debug5, debug4, debug3, debug2, debug1, + # log, notice, warning, error, fatal, and panic + # Defaults to warning. + #min_messages: notice + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: library_test + +# As with config/secrets.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# You can use this database configuration with: +# +# production: +# url: <%= ENV['DATABASE_URL'] %> +# +production: + <<: *default + database: library_production + username: library + password: <%= ENV['LIBRARY_DATABASE_PASSWORD'] %> diff --git a/library/config/environment.rb b/library/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/library/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/library/config/environments/development.rb b/library/config/environments/development.rb new file mode 100644 index 0000000..1311e3e --- /dev/null +++ b/library/config/environments/development.rb @@ -0,0 +1,61 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # 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 +end diff --git a/library/config/environments/production.rb b/library/config/environments/production.rb new file mode 100644 index 0000000..7dec21a --- /dev/null +++ b/library/config/environments/production.rb @@ -0,0 +1,94 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "library_#{Rails.env}" + + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/library/config/environments/test.rb b/library/config/environments/test.rb new file mode 100644 index 0000000..0a38fd3 --- /dev/null +++ b/library/config/environments/test.rb @@ -0,0 +1,46 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/library/config/initializers/application_controller_renderer.rb b/library/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/library/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/library/config/initializers/assets.rb b/library/config/initializers/assets.rb new file mode 100644 index 0000000..4b828e8 --- /dev/null +++ b/library/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/library/config/initializers/backtrace_silencers.rb b/library/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/library/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/library/config/initializers/content_security_policy.rb b/library/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /dev/null +++ b/library/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/library/config/initializers/cookies_serializer.rb b/library/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/library/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/library/config/initializers/filter_parameter_logging.rb b/library/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/library/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/library/config/initializers/inflections.rb b/library/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/library/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/library/config/initializers/mime_types.rb b/library/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/library/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/library/config/initializers/wrap_parameters.rb b/library/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/library/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/library/config/locales/en.yml b/library/config/locales/en.yml new file mode 100644 index 0000000..decc5a8 --- /dev/null +++ b/library/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/library/config/puma.rb b/library/config/puma.rb new file mode 100644 index 0000000..a5eccf8 --- /dev/null +++ b/library/config/puma.rb @@ -0,0 +1,34 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/library/config/routes.rb b/library/config/routes.rb new file mode 100644 index 0000000..411acc8 --- /dev/null +++ b/library/config/routes.rb @@ -0,0 +1,10 @@ +Rails.application.routes.draw do + resources :articles do + resources :comments +end + resources :paintings + resources :ingredients + resources :movies + resources :books + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/library/config/spring.rb b/library/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/library/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/library/config/storage.yml b/library/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/library/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/library/db/migrate/20190304065639_create_books.rb b/library/db/migrate/20190304065639_create_books.rb new file mode 100644 index 0000000..faac7cf --- /dev/null +++ b/library/db/migrate/20190304065639_create_books.rb @@ -0,0 +1,10 @@ +class CreateBooks < ActiveRecord::Migration[5.2] + def change + create_table :books do |t| + t.string :title + t.string :author + + t.timestamps + end + end +end diff --git a/library/db/migrate/20190304065743_create_movies.rb b/library/db/migrate/20190304065743_create_movies.rb new file mode 100644 index 0000000..8f937b9 --- /dev/null +++ b/library/db/migrate/20190304065743_create_movies.rb @@ -0,0 +1,11 @@ +class CreateMovies < ActiveRecord::Migration[5.2] + def change + create_table :movies do |t| + t.string :director + t.string :title + t.integer :rating + + t.timestamps + end + end +end diff --git a/library/db/migrate/20190304065813_create_ingredients.rb b/library/db/migrate/20190304065813_create_ingredients.rb new file mode 100644 index 0000000..eacccb1 --- /dev/null +++ b/library/db/migrate/20190304065813_create_ingredients.rb @@ -0,0 +1,13 @@ +class CreateIngredients < ActiveRecord::Migration[5.2] + def change + create_table :ingredients do |t| + t.string :name + t.string :unit + t.integer :amount + t.date :purchased_on + t.boolean :is_rotten + + t.timestamps + end + end +end diff --git a/library/db/migrate/20190304065849_create_paintings.rb b/library/db/migrate/20190304065849_create_paintings.rb new file mode 100644 index 0000000..727b520 --- /dev/null +++ b/library/db/migrate/20190304065849_create_paintings.rb @@ -0,0 +1,10 @@ +class CreatePaintings < ActiveRecord::Migration[5.2] + def change + create_table :paintings do |t| + t.string :title + t.string :artist + + t.timestamps + end + end +end diff --git a/library/db/migrate/20190304065905_create_articles.rb b/library/db/migrate/20190304065905_create_articles.rb new file mode 100644 index 0000000..b9c6306 --- /dev/null +++ b/library/db/migrate/20190304065905_create_articles.rb @@ -0,0 +1,10 @@ +class CreateArticles < ActiveRecord::Migration[5.2] + def change + create_table :articles do |t| + t.string :title + t.string :text + + t.timestamps + end + end +end diff --git a/library/db/migrate/20190304070058_create_comments.rb b/library/db/migrate/20190304070058_create_comments.rb new file mode 100644 index 0000000..09c4485 --- /dev/null +++ b/library/db/migrate/20190304070058_create_comments.rb @@ -0,0 +1,11 @@ +class CreateComments < ActiveRecord::Migration[5.2] + def change + create_table :comments do |t| + t.string :commenter + t.text :body + t.references :article, foreign_key: true + + t.timestamps + end + end +end diff --git a/library/db/schema.rb b/library/db/schema.rb new file mode 100644 index 0000000..651b0b6 --- /dev/null +++ b/library/db/schema.rb @@ -0,0 +1,67 @@ +# 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_04_070058) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "articles", force: :cascade do |t| + t.string "title" + t.string "text" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "books", force: :cascade do |t| + t.string "title" + t.string "author" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "comments", force: :cascade do |t| + t.string "commenter" + t.text "body" + t.bigint "article_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["article_id"], name: "index_comments_on_article_id" + end + + create_table "ingredients", force: :cascade do |t| + t.string "name" + t.string "unit" + t.integer "amount" + t.date "purchased_on" + t.boolean "is_rotten" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "movies", force: :cascade do |t| + t.string "director" + t.string "title" + t.integer "rating" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "paintings", force: :cascade do |t| + t.string "title" + t.string "artist" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_foreign_key "comments", "articles" +end diff --git a/library/db/seeds.rb b/library/db/seeds.rb new file mode 100644 index 0000000..1beea2a --- /dev/null +++ b/library/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/library/lib/assets/.keep b/library/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/lib/tasks/.keep b/library/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/log/.keep b/library/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/package.json b/library/package.json new file mode 100644 index 0000000..7562efd --- /dev/null +++ b/library/package.json @@ -0,0 +1,5 @@ +{ + "name": "library", + "private": true, + "dependencies": {} +} diff --git a/library/public/404.html b/library/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/library/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/library/public/422.html b/library/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/library/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/library/public/500.html b/library/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/library/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/library/public/apple-touch-icon-precomposed.png b/library/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/library/public/apple-touch-icon.png b/library/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/library/public/favicon.ico b/library/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/library/public/robots.txt b/library/public/robots.txt new file mode 100644 index 0000000..37b576a --- /dev/null +++ b/library/public/robots.txt @@ -0,0 +1 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/library/storage/.keep b/library/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/application_system_test_case.rb b/library/test/application_system_test_case.rb new file mode 100644 index 0000000..d19212a --- /dev/null +++ b/library/test/application_system_test_case.rb @@ -0,0 +1,5 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :chrome, screen_size: [1400, 1400] +end diff --git a/library/test/controllers/.keep b/library/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/controllers/articles_controller_test.rb b/library/test/controllers/articles_controller_test.rb new file mode 100644 index 0000000..c3c5ba1 --- /dev/null +++ b/library/test/controllers/articles_controller_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class ArticlesControllerTest < ActionDispatch::IntegrationTest + setup do + @article = articles(:one) + end + + test "should get index" do + get articles_url + assert_response :success + end + + test "should get new" do + get new_article_url + assert_response :success + end + + test "should create article" do + assert_difference('Article.count') do + post articles_url, params: { article: { text: @article.text, title: @article.title } } + end + + assert_redirected_to article_url(Article.last) + end + + test "should show article" do + get article_url(@article) + assert_response :success + end + + test "should get edit" do + get edit_article_url(@article) + assert_response :success + end + + test "should update article" do + patch article_url(@article), params: { article: { text: @article.text, title: @article.title } } + assert_redirected_to article_url(@article) + end + + test "should destroy article" do + assert_difference('Article.count', -1) do + delete article_url(@article) + end + + assert_redirected_to articles_url + end +end diff --git a/library/test/controllers/books_controller_test.rb b/library/test/controllers/books_controller_test.rb new file mode 100644 index 0000000..ea708d4 --- /dev/null +++ b/library/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, 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, 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/library/test/controllers/comments_controller_test.rb b/library/test/controllers/comments_controller_test.rb new file mode 100644 index 0000000..a812dda --- /dev/null +++ b/library/test/controllers/comments_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/library/test/controllers/ingredients_controller_test.rb b/library/test/controllers/ingredients_controller_test.rb new file mode 100644 index 0000000..87d3a9f --- /dev/null +++ b/library/test/controllers/ingredients_controller_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class IngredientsControllerTest < ActionDispatch::IntegrationTest + setup do + @ingredient = ingredients(:one) + end + + test "should get index" do + get ingredients_url + assert_response :success + end + + test "should get new" do + get new_ingredient_url + assert_response :success + end + + test "should create ingredient" do + assert_difference('Ingredient.count') do + post ingredients_url, params: { ingredient: { amount: @ingredient.amount, is_rotten: @ingredient.is_rotten, name: @ingredient.name, purchased_on: @ingredient.purchased_on, unit: @ingredient.unit } } + end + + assert_redirected_to ingredient_url(Ingredient.last) + end + + test "should show ingredient" do + get ingredient_url(@ingredient) + assert_response :success + end + + test "should get edit" do + get edit_ingredient_url(@ingredient) + assert_response :success + end + + test "should update ingredient" do + patch ingredient_url(@ingredient), params: { ingredient: { amount: @ingredient.amount, is_rotten: @ingredient.is_rotten, name: @ingredient.name, purchased_on: @ingredient.purchased_on, unit: @ingredient.unit } } + assert_redirected_to ingredient_url(@ingredient) + end + + test "should destroy ingredient" do + assert_difference('Ingredient.count', -1) do + delete ingredient_url(@ingredient) + end + + assert_redirected_to ingredients_url + end +end diff --git a/library/test/controllers/movies_controller_test.rb b/library/test/controllers/movies_controller_test.rb new file mode 100644 index 0000000..f2c6606 --- /dev/null +++ b/library/test/controllers/movies_controller_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class MoviesControllerTest < ActionDispatch::IntegrationTest + setup do + @movie = movies(:one) + end + + test "should get index" do + get movies_url + assert_response :success + end + + test "should get new" do + get new_movie_url + assert_response :success + end + + test "should create movie" do + assert_difference('Movie.count') do + post movies_url, params: { movie: { director: @movie.director, rating: @movie.rating, title: @movie.title } } + end + + assert_redirected_to movie_url(Movie.last) + end + + test "should show movie" do + get movie_url(@movie) + assert_response :success + end + + test "should get edit" do + get edit_movie_url(@movie) + assert_response :success + end + + test "should update movie" do + patch movie_url(@movie), params: { movie: { director: @movie.director, rating: @movie.rating, title: @movie.title } } + assert_redirected_to movie_url(@movie) + end + + test "should destroy movie" do + assert_difference('Movie.count', -1) do + delete movie_url(@movie) + end + + assert_redirected_to movies_url + end +end diff --git a/library/test/controllers/paintings_controller_test.rb b/library/test/controllers/paintings_controller_test.rb new file mode 100644 index 0000000..99dbbc4 --- /dev/null +++ b/library/test/controllers/paintings_controller_test.rb @@ -0,0 +1,48 @@ +require 'test_helper' + +class PaintingsControllerTest < ActionDispatch::IntegrationTest + setup do + @painting = paintings(:one) + end + + test "should get index" do + get paintings_url + assert_response :success + end + + test "should get new" do + get new_painting_url + assert_response :success + end + + test "should create painting" do + assert_difference('Painting.count') do + post paintings_url, params: { painting: { artist: @painting.artist, title: @painting.title } } + end + + assert_redirected_to painting_url(Painting.last) + end + + test "should show painting" do + get painting_url(@painting) + assert_response :success + end + + test "should get edit" do + get edit_painting_url(@painting) + assert_response :success + end + + test "should update painting" do + patch painting_url(@painting), params: { painting: { artist: @painting.artist, title: @painting.title } } + assert_redirected_to painting_url(@painting) + end + + test "should destroy painting" do + assert_difference('Painting.count', -1) do + delete painting_url(@painting) + end + + assert_redirected_to paintings_url + end +end diff --git a/library/test/fixtures/.keep b/library/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/fixtures/articles.yml b/library/test/fixtures/articles.yml new file mode 100644 index 0000000..d644cad --- /dev/null +++ b/library/test/fixtures/articles.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + text: MyString + +two: + title: MyString + text: MyString diff --git a/library/test/fixtures/books.yml b/library/test/fixtures/books.yml new file mode 100644 index 0000000..18ae164 --- /dev/null +++ b/library/test/fixtures/books.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + author: MyString + +two: + title: MyString + author: MyString diff --git a/library/test/fixtures/comments.yml b/library/test/fixtures/comments.yml new file mode 100644 index 0000000..9ee605c --- /dev/null +++ b/library/test/fixtures/comments.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + commenter: MyString + body: MyText + article: one + +two: + commenter: MyString + body: MyText + article: two diff --git a/library/test/fixtures/files/.keep b/library/test/fixtures/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/fixtures/ingredients.yml b/library/test/fixtures/ingredients.yml new file mode 100644 index 0000000..c5b2874 --- /dev/null +++ b/library/test/fixtures/ingredients.yml @@ -0,0 +1,15 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + unit: MyString + amount: 1 + purchased_on: 2019-03-04 + is_rotten: false + +two: + name: MyString + unit: MyString + amount: 1 + purchased_on: 2019-03-04 + is_rotten: false diff --git a/library/test/fixtures/movies.yml b/library/test/fixtures/movies.yml new file mode 100644 index 0000000..4d1437a --- /dev/null +++ b/library/test/fixtures/movies.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + director: MyString + title: MyString + rating: 1 + +two: + director: MyString + title: MyString + rating: 1 diff --git a/library/test/fixtures/paintings.yml b/library/test/fixtures/paintings.yml new file mode 100644 index 0000000..e2eeb2d --- /dev/null +++ b/library/test/fixtures/paintings.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + artist: MyString + +two: + title: MyString + artist: MyString diff --git a/library/test/helpers/.keep b/library/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/integration/.keep b/library/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/mailers/.keep b/library/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/models/.keep b/library/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/models/article_test.rb b/library/test/models/article_test.rb new file mode 100644 index 0000000..11c8abe --- /dev/null +++ b/library/test/models/article_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ArticleTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/models/book_test.rb b/library/test/models/book_test.rb new file mode 100644 index 0000000..e48079d --- /dev/null +++ b/library/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/library/test/models/comment_test.rb b/library/test/models/comment_test.rb new file mode 100644 index 0000000..b6d6131 --- /dev/null +++ b/library/test/models/comment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/models/ingredient_test.rb b/library/test/models/ingredient_test.rb new file mode 100644 index 0000000..511fcf8 --- /dev/null +++ b/library/test/models/ingredient_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class IngredientTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/models/movie_test.rb b/library/test/models/movie_test.rb new file mode 100644 index 0000000..22d7084 --- /dev/null +++ b/library/test/models/movie_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MovieTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/models/painting_test.rb b/library/test/models/painting_test.rb new file mode 100644 index 0000000..6f0053e --- /dev/null +++ b/library/test/models/painting_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PaintingTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/library/test/system/.keep b/library/test/system/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/test/system/articles_test.rb b/library/test/system/articles_test.rb new file mode 100644 index 0000000..80b6085 --- /dev/null +++ b/library/test/system/articles_test.rb @@ -0,0 +1,45 @@ +require "application_system_test_case" + +class ArticlesTest < ApplicationSystemTestCase + setup do + @article = articles(:one) + end + + test "visiting the index" do + visit articles_url + assert_selector "h1", text: "Articles" + end + + test "creating a Article" do + visit articles_url + click_on "New Article" + + fill_in "Text", with: @article.text + fill_in "Title", with: @article.title + click_on "Create Article" + + assert_text "Article was successfully created" + click_on "Back" + end + + test "updating a Article" do + visit articles_url + click_on "Edit", match: :first + + fill_in "Text", with: @article.text + fill_in "Title", with: @article.title + click_on "Update Article" + + assert_text "Article was successfully updated" + click_on "Back" + end + + test "destroying a Article" do + visit articles_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Article was successfully destroyed" + end +end diff --git a/library/test/system/books_test.rb b/library/test/system/books_test.rb new file mode 100644 index 0000000..930e9b8 --- /dev/null +++ b/library/test/system/books_test.rb @@ -0,0 +1,45 @@ +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 "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 "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 diff --git a/library/test/system/ingredients_test.rb b/library/test/system/ingredients_test.rb new file mode 100644 index 0000000..4d7ba7a --- /dev/null +++ b/library/test/system/ingredients_test.rb @@ -0,0 +1,51 @@ +require "application_system_test_case" + +class IngredientsTest < ApplicationSystemTestCase + setup do + @ingredient = ingredients(:one) + end + + test "visiting the index" do + visit ingredients_url + assert_selector "h1", text: "Ingredients" + end + + test "creating a Ingredient" do + visit ingredients_url + click_on "New Ingredient" + + fill_in "Amount", with: @ingredient.amount + fill_in "Is rotten", with: @ingredient.is_rotten + fill_in "Name", with: @ingredient.name + fill_in "Purchased on", with: @ingredient.purchased_on + fill_in "Unit", with: @ingredient.unit + click_on "Create Ingredient" + + assert_text "Ingredient was successfully created" + click_on "Back" + end + + test "updating a Ingredient" do + visit ingredients_url + click_on "Edit", match: :first + + fill_in "Amount", with: @ingredient.amount + fill_in "Is rotten", with: @ingredient.is_rotten + fill_in "Name", with: @ingredient.name + fill_in "Purchased on", with: @ingredient.purchased_on + fill_in "Unit", with: @ingredient.unit + click_on "Update Ingredient" + + assert_text "Ingredient was successfully updated" + click_on "Back" + end + + test "destroying a Ingredient" do + visit ingredients_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Ingredient was successfully destroyed" + end +end diff --git a/library/test/system/movies_test.rb b/library/test/system/movies_test.rb new file mode 100644 index 0000000..69a3719 --- /dev/null +++ b/library/test/system/movies_test.rb @@ -0,0 +1,47 @@ +require "application_system_test_case" + +class MoviesTest < ApplicationSystemTestCase + setup do + @movie = movies(:one) + end + + test "visiting the index" do + visit movies_url + assert_selector "h1", text: "Movies" + end + + test "creating a Movie" do + visit movies_url + click_on "New Movie" + + fill_in "Director", with: @movie.director + fill_in "Rating", with: @movie.rating + fill_in "Title", with: @movie.title + click_on "Create Movie" + + assert_text "Movie was successfully created" + click_on "Back" + end + + test "updating a Movie" do + visit movies_url + click_on "Edit", match: :first + + fill_in "Director", with: @movie.director + fill_in "Rating", with: @movie.rating + fill_in "Title", with: @movie.title + click_on "Update Movie" + + assert_text "Movie was successfully updated" + click_on "Back" + end + + test "destroying a Movie" do + visit movies_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Movie was successfully destroyed" + end +end diff --git a/library/test/system/paintings_test.rb b/library/test/system/paintings_test.rb new file mode 100644 index 0000000..28fb49d --- /dev/null +++ b/library/test/system/paintings_test.rb @@ -0,0 +1,45 @@ +require "application_system_test_case" + +class PaintingsTest < ApplicationSystemTestCase + setup do + @painting = paintings(:one) + end + + test "visiting the index" do + visit paintings_url + assert_selector "h1", text: "Paintings" + end + + test "creating a Painting" do + visit paintings_url + click_on "New Painting" + + fill_in "Artist", with: @painting.artist + fill_in "Title", with: @painting.title + click_on "Create Painting" + + assert_text "Painting was successfully created" + click_on "Back" + end + + test "updating a Painting" do + visit paintings_url + click_on "Edit", match: :first + + fill_in "Artist", with: @painting.artist + fill_in "Title", with: @painting.title + click_on "Update Painting" + + assert_text "Painting was successfully updated" + click_on "Back" + end + + test "destroying a Painting" do + visit paintings_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Painting was successfully destroyed" + end +end diff --git a/library/test/test_helper.rb b/library/test/test_helper.rb new file mode 100644 index 0000000..3ab84e3 --- /dev/null +++ b/library/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/library/tmp/.keep b/library/tmp/.keep new file mode 100644 index 0000000..e69de29 diff --git a/library/vendor/.keep b/library/vendor/.keep new file mode 100644 index 0000000..e69de29