Skip to content

Commit

Permalink
Add rubocop autocorrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-strzalka committed Sep 16, 2022
1 parent 4c4a810 commit bd32442
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 98 deletions.
41 changes: 21 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.1.2"
ruby '3.1.2'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.3"
gem 'rails', '~> 7.0.3'

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
gem 'sprockets-rails'

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"
gem 'pg', '~> 1.1'

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"
gem 'puma', '~> 5.0'

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
gem 'importmap-rails'

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
gem 'turbo-rails'

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
gem 'stimulus-rails'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
gem 'jbuilder'

# Devise Auth
gem "devise", "~> 4.8.1"
gem 'devise', '~> 4.8.1'

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
gem 'bootsnap', require: false

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem 'debug', platforms: %i[mri mingw x64_mingw]
end

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
gem 'web-console'

# Static analyzers, linters and similar
gem "brakeman", "~> 5.3.1"
gem "rubocop", "~> 1.36.0"
gem "rubocop-rails", "~> 2.16.0"
gem "lefthook", "~> 1.1.1"
gem 'brakeman', '~> 5.3.1'
gem 'lefthook', '~> 1.1.1'
gem 'rubocop', '~> 1.36.0'
gem 'rubocop-rails', '~> 2.16.0'
end

4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# 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"
require_relative 'config/application'

Rails.application.load_tasks
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
def is_customer?
current_user && current_user.customer?
current_user&.customer?
end

def is_manager?
current_user && current_user.manager?
current_user&.manager?
end
end
12 changes: 6 additions & 6 deletions app/controllers/halls_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

class HallsController < ApplicationController
before_action :find_hall, only: %i[ show edit update destroy ]
before_action :find_hall, only: %i[show edit update destroy]

def index
@halls = Hall.all
end

def show
end
def show; end

def new
@hall = Hall.new
Expand All @@ -22,13 +23,12 @@ def create
end
end

def edit
end
def edit; end

def update
if @hall.update(hall_params)
redirect_to @hall
else
else
render :edit, status: :unprocessable_entity
end
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class MoviesController < ApplicationController
def index
@movies = Movie.all
Expand Down Expand Up @@ -30,7 +32,7 @@ def update

if @movie.update(movie_params)
redirect_to @movie
else
else
render :edit, status: :unprocessable_entity
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/helpers/cinema_halls_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module CinemaHallsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/movies_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module MoviesHelper
end
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
Expand Down
6 changes: 4 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: "[email protected]"
layout "mailer"
default from: '[email protected]'
layout 'mailer'
end
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
2 changes: 2 additions & 0 deletions app/models/hall.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Hall < ApplicationRecord
validates :name, uniqueness: true, length: { minimum: 1 }
validates :capacity, numericality: { only_integer: true, greater_than: 0 }
Expand Down
2 changes: 2 additions & 0 deletions app/models/movie.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Movie < ApplicationRecord
validates :title, length: { minimum: 1 }
validates :length_in_minutes, numericality: { in: 1..300 }
Expand Down
4 changes: 3 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable

enum :role, [:customer, :manager]
enum :role, %i[customer manager]
end
4 changes: 3 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
require_relative 'config/environment'

run Rails.application
Rails.application.load_server
130 changes: 66 additions & 64 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,79 +1,81 @@
# frozen_string_literal: true

Hall.destroy_all

Hall.create!([
{
name: "A1",
capacity: 20
},
{
name: "B1",
capacity: 50
},
{
name: "B2",
capacity: 50
},
{
name: "B3",
capacity: 50
},
{
name: "B4",
capacity: 50
},
{
name: "C1",
capacity: 100
},
{
name: "C2",
capacity: 100
},
{
name: "C3",
capacity: 100
},
{
name: "C4",
capacity: 100
},
{
name: "D1",
capacity: 200
}
])
{
name: 'A1',
capacity: 20
},
{
name: 'B1',
capacity: 50
},
{
name: 'B2',
capacity: 50
},
{
name: 'B3',
capacity: 50
},
{
name: 'B4',
capacity: 50
},
{
name: 'C1',
capacity: 100
},
{
name: 'C2',
capacity: 100
},
{
name: 'C3',
capacity: 100
},
{
name: 'C4',
capacity: 100
},
{
name: 'D1',
capacity: 200
}
])

p "Successfully created #{Hall.count} Halls"
Rails.logger.debug { "Successfully created #{Hall.count} Halls" }

Movie.destroy_all

Movie.create!([{
title: "Avatar",
length_in_minutes: 162
},
{
title: "Titanic",
length_in_minutes: 194
},
{
title: "Gladiator",
length_in_minutes: 155
}])
title: 'Avatar',
length_in_minutes: 162
},
{
title: 'Titanic',
length_in_minutes: 194
},
{
title: 'Gladiator',
length_in_minutes: 155
}])

p "Successfully created #{Movie.count} Movies"
Rails.logger.debug { "Successfully created #{Movie.count} Movies" }

if Rails.env == "development"
if Rails.env.development?
User.destroy_all

User.create!([{
email: "[email protected]",
password: "123456",
role: "customer"
}, {
email: "[email protected]",
password: "123456",
role: "manager"
}])
email: '[email protected]',
password: '123456',
role: 'customer'
}, {
email: '[email protected]',
password: '123456',
role: 'manager'
}])

p "Successfully created #{User.count} Users"
Rails.logger.debug { "Successfully created #{User.count} Users" }
end

0 comments on commit bd32442

Please sign in to comment.