1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00
This commit is contained in:
Daniel Barber 2021-07-03 21:29:14 -04:00 committed by GitHub
commit 1e2208e9c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 894 additions and 217 deletions

View File

@ -1,13 +1,645 @@
Documentation:
AllCops:
Exclude:
- db/schema.rb
Naming/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
Enabled: false
AllCops:
Include:
- '**/Rakefile'
- '**/config.ru'
Style/Alias:
Description: 'Use alias_method instead of alias.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
Enabled: false
Style/ArrayJoin:
Description: 'Use Array#join instead of Array#*.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
Enabled: false
Style/AsciiComments:
Description: 'Use only ascii symbols in comments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
Enabled: false
Naming/AsciiIdentifiers:
Description: 'Use only ascii symbols in identifiers.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
Enabled: false
Style/Attr:
Description: 'Checks for uses of Module#attr.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
Enabled: false
Metrics/BlockNesting:
Description: 'Avoid excessive block nesting'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
Enabled: false
Style/CaseEquality:
Description: 'Avoid explicit use of the case equality operator(===).'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
Enabled: false
Style/CharacterLiteral:
Description: 'Checks for uses of character literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
Enabled: false
Style/ClassAndModuleChildren:
Description: 'Checks style of children classes and modules.'
Enabled: true
EnforcedStyle: nested
Metrics/ClassLength:
Description: 'Avoid classes longer than 100 lines of code.'
Enabled: false
Metrics/ModuleLength:
Description: 'Avoid modules longer than 100 lines of code.'
Enabled: false
Style/ClassVars:
Description: 'Avoid the use of class variables.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
Enabled: false
Style/CollectionMethods:
Enabled: true
PreferredMethods:
find: detect
inject: reduce
collect: map
find_all: select
Style/ColonMethodCall:
Description: 'Do not use :: for method call.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
Enabled: false
Style/CommentAnnotation:
Description: >-
Checks formatting of special comments
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
Enabled: false
Metrics/AbcSize:
Description: >-
A calculated magnitude based on number of assignments,
branches, and conditions.
Enabled: false
Metrics/BlockLength:
CountComments: true # count full line comments?
Max: 25
ExcludedMethods: []
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'bin/**/*'
- !ruby/regexp /old_and_unused\.rb$/
- "spec/**/*"
Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: false
Rails/Delegate:
Description: 'Prefer delegate method for delegations.'
Enabled: false
Style/PreferredHashMethods:
Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
StyleGuide: '#hash-key'
Enabled: false
Style/Documentation:
Description: 'Document classes and non-namespace modules.'
Enabled: false
Style/DoubleNegation:
Description: 'Checks for uses of double negation (!!).'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
Enabled: false
Style/EachWithObject:
Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
Enabled: false
Style/EmptyLiteral:
Description: 'Prefer literals to Array.new/Hash.new/String.new.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
Enabled: false
# Checks whether the source file has a utf-8 encoding comment or not
# AutoCorrectEncodingComment must match the regex
# /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
Style/Encoding:
Enabled: false
Style/EvenOdd:
Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
Enabled: false
Naming/FileName:
Description: 'Use snake_case for source file names.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
Enabled: false
Style/FrozenStringLiteralComment:
Description: >-
Add the frozen_string_literal comment to the top of files
to help transition from Ruby 2.3.0 to Ruby 3.0.
Enabled: false
Style/FlipFlop:
Description: 'Checks for flip flops'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
Enabled: false
Style/FormatString:
Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
Enabled: false
Style/GlobalVars:
Description: 'Do not introduce global variables.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
Enabled: false
Style/GuardClause:
Description: 'Check for conditionals that can be replaced with guard clauses'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
Enabled: false
Style/IfUnlessModifier:
Description: >-
Favor modifier if/unless usage when you have a
single-line body.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
Enabled: false
Style/IfWithSemicolon:
Description: 'Do not use if x; .... Use the ternary operator instead.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
Enabled: false
Style/InlineComment:
Description: 'Avoid inline comments.'
Enabled: false
Style/Lambda:
Description: 'Use the new lambda literal syntax for single-line blocks.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
Enabled: false
Style/LambdaCall:
Description: 'Use lambda.call(...) instead of lambda.(...).'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
Enabled: false
Style/LineEndConcatenation:
Description: >-
Use \ instead of + or << to concatenate two string literals at
line end.
Enabled: false
Metrics/LineLength:
Description: 'Limit lines to 80 characters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
Max: 80
Metrics/MethodLength:
Description: 'Avoid methods longer than 10 lines of code.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
Enabled: false
Style/ModuleFunction:
Description: 'Checks for usage of `extend self` in modules.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
Enabled: false
Style/MultilineBlockChain:
Description: 'Avoid multi-line chains of blocks.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
Enabled: false
Style/NegatedIf:
Description: >-
Favor unless over if for negative conditions
(or control flow or).
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
Enabled: false
Style/NegatedWhile:
Description: 'Favor until over while for negative conditions.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
Enabled: false
Style/Next:
Description: 'Use `next` to skip iteration instead of a condition at the end.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
Enabled: false
Style/NilComparison:
Description: 'Prefer x.nil? to x == nil.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
Enabled: false
Style/Not:
Description: 'Use ! instead of not.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
Enabled: false
Style/NumericLiterals:
Description: >-
Add underscores to large numeric literals to improve their
readability.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
Enabled: false
Style/OneLineConditional:
Description: >-
Favor the ternary operator(?:) over
if/then/else/end constructs.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
Enabled: false
Naming/BinaryOperatorParameterName:
Description: 'When defining binary operators, name the argument other.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
Enabled: false
Metrics/ParameterLists:
Description: 'Avoid parameter lists longer than three or four parameters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
Enabled: false
Style/PercentLiteralDelimiters:
Description: 'Use `%`-literal delimiters consistently'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
Enabled: false
Style/PerlBackrefs:
Description: 'Avoid Perl-style regex back references.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
Enabled: false
Naming/PredicateName:
Description: 'Check the names of predicate methods.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
NamePrefixBlacklist:
- is_
Exclude:
- spec/**/*
Style/Proc:
Description: 'Use proc instead of Proc.new.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
Enabled: false
Style/RaiseArgs:
Description: 'Checks the arguments passed to raise/fail.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
Enabled: false
Style/RegexpLiteral:
Description: 'Use / or %r around regular expressions.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
Enabled: false
Style/SelfAssignment:
Description: >-
Checks for places where self-assignment shorthand should have
been used.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
Enabled: false
Style/SingleLineBlockParams:
Description: 'Enforces the names of some block params.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
Enabled: false
Style/SingleLineMethods:
Description: 'Avoid single-line methods.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
Enabled: false
Style/SignalException:
Description: 'Checks for proper usage of fail and raise.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
Enabled: false
Style/SpecialGlobalVars:
Description: 'Avoid Perl-style global variables.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
Enabled: false
Style/StringLiterals:
Description: 'Checks if uses of quotes match the configured preference.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
EnforcedStyle: double_quotes
Enabled: true
Style/TrailingCommaInArguments:
Description: 'Checks for trailing comma in argument lists.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
EnforcedStyleForMultiline: comma
SupportedStylesForMultiline:
- comma
- consistent_comma
- no_comma
Enabled: true
Style/TrailingCommaInLiteral:
Description: 'Checks for trailing comma in array and hash literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
EnforcedStyleForMultiline: comma
SupportedStylesForMultiline:
- comma
- consistent_comma
- no_comma
Enabled: true
Style/TrivialAccessors:
Description: 'Prefer attr_* methods to trivial readers/writers.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
Enabled: false
Style/VariableInterpolation:
Description: >-
Don't interpolate global, instance and class variables
directly in strings.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
Enabled: false
Style/WhenThen:
Description: 'Use when x then ... for one-line cases.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
Enabled: false
Style/WhileUntilModifier:
Description: >-
Favor modifier while/until usage when you have a
single-line body.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
Enabled: false
Style/WordArray:
Description: 'Use %w or %W for arrays of words.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
Enabled: false
Style/SymbolArray:
Description: 'Use %i or %I for arrays of symbols.'
StyleGuide: '#percent-i'
Enabled: false
# Layout
Layout/AlignParameters:
Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
Enabled: false
Layout/DotPosition:
Description: 'Checks the position of the dot in multi-line method calls.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
EnforcedStyle: leading
Layout/ExtraSpacing:
Description: 'Do not use unnecessary spacing.'
Enabled: true
Layout/MultilineOperationIndentation:
Description: >-
Checks indentation of binary operations that span more than
one line.
Enabled: true
EnforcedStyle: indented
Layout/MultilineMethodCallIndentation:
Description: >-
Checks indentation of method calls with the dot operator
that span more than one line.
Enabled: true
EnforcedStyle: indented
Layout/InitialIndentation:
Description: >-
Checks the indentation of the first non-blank non-comment line in a file.
Enabled: false
# Lint
Lint/AmbiguousOperator:
Description: >-
Checks for ambiguous operators in the first argument of a
method invocation without parentheses.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
Enabled: false
Lint/AmbiguousRegexpLiteral:
Description: >-
Checks for ambiguous regexp literals in the first argument of
a method invocation without parenthesis.
Enabled: false
Lint/AssignmentInCondition:
Description: "Don't use assignment in conditions."
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
Enabled: false
Lint/CircularArgumentReference:
Description: "Don't refer to the keyword argument in the default value."
Enabled: false
Lint/ConditionPosition:
Description: >-
Checks for condition placed in a confusing position relative to
the keyword.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
Enabled: false
Lint/DeprecatedClassMethods:
Description: 'Check for deprecated class method calls.'
Enabled: false
Lint/DuplicatedKey:
Description: 'Check for duplicate keys in hash literals.'
Enabled: false
Lint/EachWithObjectArgument:
Description: 'Check for immutable argument given to each_with_object.'
Enabled: false
Lint/ElseLayout:
Description: 'Check for odd code arrangement in an else block.'
Enabled: false
Lint/FormatParameterMismatch:
Description: 'The number of parameters to format/sprint must match the fields.'
Enabled: false
Lint/HandleExceptions:
Description: "Don't suppress exception."
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
Enabled: false
Lint/LiteralAsCondition:
Description: 'Checks of literals used in conditions.'
Enabled: false
Lint/LiteralInInterpolation:
Description: 'Checks for literals used in interpolation.'
Enabled: false
Lint/Loop:
Description: >-
Use Kernel#loop with break rather than begin/end/until or
begin/end/while for post-loop tests.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
Enabled: false
Lint/NestedMethodDefinition:
Description: 'Do not use nested method definitions.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
Enabled: false
Lint/NonLocalExitFromIterator:
Description: 'Do not use return in iterator to cause non-local exit.'
Enabled: false
Lint/ParenthesesAsGroupedExpression:
Description: >-
Checks for method calls with a space before the opening
parenthesis.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
Enabled: false
Lint/RequireParentheses:
Description: >-
Use parentheses in the method call to avoid confusion
about precedence.
Enabled: false
Lint/UnderscorePrefixedVariableName:
Description: 'Do not use prefix `_` for a variable that is used.'
Enabled: false
Lint/UnneededDisable:
Description: >-
Checks for rubocop:disable comments that can be removed.
Note: this cop is not disabled when disabling all cops.
It must be explicitly disabled.
Enabled: false
Lint/Void:
Description: 'Possible use of operator/literal/variable in void context.'
Enabled: false
# Performance
Performance/CaseWhenSplat:
Description: >-
Place `when` conditions that use splat at the end
of the list of `when` branches.
Enabled: false
Performance/Count:
Description: >-
Use `count` instead of `select...size`, `reject...size`,
`select...count`, `reject...count`, `select...length`,
and `reject...length`.
Enabled: false
Performance/Detect:
Description: >-
Use `detect` instead of `select.first`, `find_all.first`,
`select.last`, and `find_all.last`.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
Enabled: false
Performance/FlatMap:
Description: >-
Use `Enumerable#flat_map`
instead of `Enumerable#map...Array#flatten(1)`
or `Enumberable#collect..Array#flatten(1)`
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
Enabled: false
Performance/ReverseEach:
Description: 'Use `reverse_each` instead of `reverse.each`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
Enabled: false
Performance/Sample:
Description: >-
Use `sample` instead of `shuffle.first`,
`shuffle.last`, and `shuffle[Fixnum]`.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
Enabled: false
Performance/Size:
Description: >-
Use `size` instead of `count` for counting
the number of elements in `Array` and `Hash`.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
Enabled: false
Performance/StringReplacement:
Description: >-
Use `tr` instead of `gsub` when you are replacing the same
number of characters. Use `delete` instead of `gsub` when
you are deleting characters.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
Enabled: false
# Rails
Rails/ActionFilter:
Description: 'Enforces consistent use of action filter methods.'
Enabled: false
Rails/Date:
Description: >-
Checks the correct usage of date aware methods,
such as Date.today, Date.current etc.
Enabled: false
Rails/FindBy:
Description: 'Prefer find_by over where.first.'
Enabled: false
Rails/FindEach:
Description: 'Prefer all.find_each over all.find.'
Enabled: false
Rails/HasAndBelongsToMany:
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
Enabled: false
Rails/Output:
Description: 'Checks for calls to puts, print, etc.'
Enabled: false
Rails/ReadWriteAttribute:
Description: >-
Checks for read_attribute(:attr) and
write_attribute(:attr, val).
Enabled: false
Rails/ScopeArgs:
Description: 'Checks the arguments of ActiveRecord scopes.'
Enabled: false
Rails/TimeZone:
Description: 'Checks the correct usage of time zone aware methods.'
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
Enabled: false
Rails/Validation:
Description: 'Use validates :attribute, hash of validations.'
Enabled: false

86
Gemfile
View File

@ -1,63 +1,63 @@
source 'http://rubygems.org'
ruby '2.4.2'
source "http://rubygems.org"
ruby "2.4.2"
gem 'dotenv-rails', :groups => [:development, :test]
gem "dotenv-rails", groups: %i[development test]
gem 'rails', '~> 5.1'
gem "rails", "~> 5.1"
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# gem "rails", :git => "git://github.com/rails/rails.git"
gem 'administrate'
gem 'administrate-field-image'
gem 'aws-sdk'
gem 'bourbon'
gem 'coffee-rails'
gem 'dragonfly'
gem 'dragonfly-s3_data_store'
gem 'jquery-rails'
gem 'kaminari'
gem 'kramdown'
gem 'mime-types'
gem 'nokogiri'
gem 'oath'
gem 'oath-generators'
gem 'pg'
gem 'sass-rails'
gem 'simple_form'
gem 'slugtastic'
gem 'uglifier'
gem 'unf'
gem "administrate"
gem "administrate-field-image"
gem "aws-sdk"
gem "bourbon"
gem "coffee-rails"
gem "dragonfly"
gem "dragonfly-s3_data_store"
gem "jquery-rails"
gem "kaminari"
gem "kramdown"
gem "mime-types"
gem "nokogiri"
gem "oath"
gem "oath-generators"
gem "pg"
gem "sass-rails"
gem "simple_form"
gem "slugtastic"
gem "uglifier"
gem "unf"
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development do
gem 'ruby_parser'
gem 'powder'
gem 'better_errors'
gem 'binding_of_caller'
gem 'letter_opener'
gem "better_errors"
gem "binding_of_caller"
gem "letter_opener"
gem "powder"
gem "ruby_parser"
end
group :test, :development do
gem 'rspec-rails'
gem 'rails-controller-testing'
gem 'rubocop'
gem 'pry'
gem "pry"
gem "rails-controller-testing"
gem "rspec-rails"
gem "rubocop"
end
group :test do
gem 'factory_bot_rails'
gem 'shoulda'
gem 'poltergeist'
gem 'database_cleaner'
gem 'fivemat'
gem 'capybara-screenshot'
gem 'simplecov'
gem "capybara-screenshot"
gem "database_cleaner"
gem "factory_bot_rails"
gem "fivemat"
gem "poltergeist"
gem "shoulda"
gem "simplecov"
end
group :production do
gem 'puma'
gem 'rails_12factor'
gem "puma"
gem "rails_12factor"
end

View File

@ -1,7 +1,8 @@
#!/usr/bin/env rake
# 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.
# for example lib/tasks/capistrano.rake, and they will automatically be
# available to Rake.
require File.expand_path('../config/application', __FILE__)
require File.expand_path("../config/application", __FILE__)
DanBarberPhoto::Application.load_tasks

View File

@ -9,21 +9,11 @@ class CategoriesController < ApplicationController
@page_title = "Portfolio"
@num_blank = 4 - @categories.length
respond_to do |format|
format.html # index.html.erb
format.xml { render xml: @categories }
end
end
# GET /categories/1
# GET /categories/1.xml
def show
@category = Category.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render xml: @category }
end
end
end

View File

@ -6,6 +6,7 @@ class ContactsController < ApplicationController
def create
@contact = Contact.new(params[:contact])
if @contact.valid?
Notifier.contact_notification(@contact).deliver
redirect_to(:new_contact, notice: t("contact.thanks"))

View File

@ -7,24 +7,25 @@ class PhotosController < ApplicationController
end
@num_blank = 11 - @photos.length
respond_to do |format|
format.html
end
end
private
def for_category(category_id)
@category = Category.find_by_id(category_id)
@photos = @category.photos.enabled.order(taken_at: :desc)
.page(params[:page])
@photos = @category.photos.enabled
.order(taken_at: :desc)
.page(params[:page])
@page_title = @category.name
end
def all
@photos = Photo.enabled.order(taken_at: :desc)
.page(params[:page])
@photos = Photo.enabled
.order(taken_at: :desc)
.page(params[:page])
@page_title = "All Photos"
end
end

View File

@ -18,6 +18,7 @@ class SessionsController < ApplicationController
def destroy
sign_out
redirect_to root_path
end

View File

@ -1,6 +1,7 @@
class ViewsController < ApplicationController
def create
photo = Photo.find_by_id(params[:photo_id])
if photo.present?
photo.log_view
head :ok

View File

@ -3,7 +3,7 @@ module ApplicationHelper
if title.present?
"#{title} - #{APP_CONFIG['page_title']}"
else
APP_CONFIG['page_title']
APP_CONFIG["page_title"]
end
end
end

View File

@ -1,5 +1,11 @@
module PhotosHelper
def link_to_photo(photo)
link_to '', photo.image.url, rel: 'photos', class: 'fancy', data: { id: photo.id }
link_to(
"",
photo.image.url,
rel: "photos",
class: "fancy",
data: { id: photo.id },
)
end
end

View File

@ -1,8 +1,12 @@
class Notifier < ActionMailer::Base
default from: 'enquiries@danbarberphoto.com'
default from: "enquiries@danbarberphoto.com"
def contact_notification(sender)
@sender = sender
mail(to: 'enquiries@danbarberphoto.com', from: sender.email, subject: sender.subject)
mail(
to: "enquiries@danbarberphoto.com",
from: sender.email,
subject: sender.subject,
)
end
end

View File

@ -1,7 +1,8 @@
class Category < ActiveRecord::Base
has_and_belongs_to_many :photos
validates_presence_of :name, :slug
validates_uniqueness_of :name, :slug
validates :name, presence: true, uniqueness: true
validates :slug, presence: true, uniqueness: true
slug :slug, from: :name

View File

@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path("../config/environment", __FILE__)
run DanBarberPhoto::Application

View File

@ -1,36 +1,44 @@
require File.expand_path('../boot', __FILE__)
require File.expand_path("../boot", __FILE__)
require 'rails/all'
require "rails/all"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
Bundler.require *Rails.groups(assets: %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module DanBarberPhoto
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Settings in config/environments/* take precedence over those specified
# here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# Only load the plugins named here, in the order given
# (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# config.active_record.observers = :cacher, :garbage_collector,
# :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# Set Time.zone default to the specified zone and make Active Record
# auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
# Default is UTC.
# config.time_zone = "Central Time (US & Canada)"
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# The default locale is :en and all translations from
# config/locales/*.rb,yml are auto loaded.
config.i18n.load_path += Dir[
Rails.root.join("my", "locales", "*.{rb,yml}").to_s
]
config.i18n.enforce_available_locales = true
config.i18n.default_locale = :en
@ -43,10 +51,12 @@ module DanBarberPhoto
# Enable the asset pipeline
config.assets.enabled = true
config.assets.precompile += %w(favicon.ico fancybox/sprite.png fancybox/loading.gif fancybox/blank.gif fancybox/overlay.png)
config.assets.precompile += %w(favicon.ico fancybox/sprite.png
fancybox/loading.gif fancybox/blank.gif
fancybox/overlay.png)
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
config.assets.version = "1.0"
# Prefer SASS syntax for stylesheets
config.sass.preferred_syntax = :sass
@ -54,7 +64,7 @@ module DanBarberPhoto
# Configure factories
config.generators do |g|
g.test_framework :rspec, fixture: true
g.fixture_replacement :factory_girl, dir: 'spec/factories'
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
end
end

View File

@ -1,6 +1,6 @@
require 'rubygems'
require "rubygems"
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require "bundler/setup" if File.exists?(ENV["BUNDLE_GEMFILE"])

View File

@ -1,5 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
require File.expand_path("../application", __FILE__)
# Initialize the rails application
DanBarberPhoto::Application.initialize!

View File

@ -33,6 +33,6 @@ DanBarberPhoto::Application.configure do
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.default_url_options = { :host => "danbarberphoto.dev" }
config.action_mailer.default_url_options = { host: "danbarberphoto.dev" }
end

View File

@ -1,5 +1,6 @@
DanBarberPhoto::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in
# config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
@ -33,7 +34,8 @@ DanBarberPhoto::Application.configure do
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# Force all access to the app over SSL, use Strict-Transport-Security, and
# use secure cookies.
# config.force_ssl = true
# See everything in the log (default is :info)
@ -48,7 +50,8 @@ DanBarberPhoto::Application.configure do
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# Precompile additional assets (application.js, application.css, and
# all non-JS/CSS are already added)
config.assets.precompile += %w(administrate/overrides.css)
# Disable delivery errors, bad email addresses will be ignored
@ -66,15 +69,14 @@ DanBarberPhoto::Application.configure do
# Settings for Sendgrid Free on Heroku
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com'
address: "smtp.sendgrid.net",
port: "587",
authentication: :plain,
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"],
domain: "heroku.com",
}
ActionMailer::Base.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "danbarberphoto.com" }
config.action_mailer.default_url_options = { host: "danbarberphoto.com" }
end

View File

@ -1,7 +1,7 @@
# 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'
Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path

View File

@ -1,4 +1,4 @@
require 'dragonfly'
require "dragonfly"
# Configure
Dragonfly.app.configure do
@ -11,33 +11,61 @@ Dragonfly.app.configure do
if Rails.env.in?(%w(development production))
datastore :s3,
bucket_name: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_KEY'],
secret_access_key: ENV['AWS_SECRET'],
region: 'eu-west-1'
bucket_name: ENV["AWS_BUCKET"],
access_key_id: ENV["AWS_KEY"],
secret_access_key: ENV["AWS_SECRET"],
region: "eu-west-1"
else
datastore :file,
root_path: Rails.root.join('public/system/dragonfly', Rails.env),
server_root: Rails.root.join('public')
root_path: Rails.root.join("public/system/dragonfly", Rails.env),
server_root: Rails.root.join("public")
end
processor :preview do |content| content.process! :thumb, '600x600' end
processor :preview do |content|
content.process! :thumb, "600x600"
end
processor :admin do |content| content.process! :thumb, '140x140#' end
processor :admin do |content|
content.process! :thumb, "140x140#"
end
processor :size17 do |content| content.process! :thumb, '476x476#' end
processor :size11 do |content| content.process! :thumb, '308x308#' end
processor :size8 do |content| content.process! :thumb, '224x224#' end
processor :size5 do |content| content.process! :thumb, '140x140#' end
processor :size3 do |content| content.process! :thumb, '84x84#' end
processor :size2 do |content| content.process! :thumb, '56x56#' end
processor :size17 do |content|
content.process! :thumb, "476x476#"
end
processor :size11 do |content|
content.process! :thumb, "308x308#"
end
processor :size8 do |content|
content.process! :thumb, "224x224#"
end
processor :size5 do |content|
content.process! :thumb, "140x140#"
end
processor :size3 do |content|
content.process! :thumb, "84x84#"
end
processor :size2 do |content|
content.process! :thumb, "56x56#"
end
processor :size17x2 do |content| content.process! :thumb, '952x952#' end
processor :size11x2 do |content| content.process! :thumb, '616x616#' end
processor :size8x2 do |content| content.process! :thumb, '448x448#' end
processor :size5x2 do |content| content.process! :thumb, '280x280#' end
processor :size3x2 do |content| content.process! :thumb, '168x168#' end
processor :size2x2 do |content| content.process! :thumb, '112x112#' end
processor :size17x2 do |content|
content.process! :thumb, "952x952#"
end
processor :size11x2 do |content|
content.process! :thumb, "616x616#"
end
processor :size8x2 do |content|
content.process! :thumb, "448x448#"
end
processor :size5x2 do |content|
content.process! :thumb, "280x280#"
end
processor :size3x2 do |content|
content.process! :thumb, "168x168#"
end
processor :size2x2 do |content|
content.process! :thumb, "112x112#"
end
end
# Logger

View File

@ -3,8 +3,8 @@
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.plural /^(ox)$/i, "\1en"
# inflect.singular /^(ox)en/i, "\1"
# inflect.irregular "person", "people"
# inflect.uncountable %w( fish sheep )
# end

View File

@ -1,6 +1,7 @@
# Be sure to restart your server when you modify this file.
DanBarberPhoto::Application.config.session_store :cookie_store, key: '_danbarberphoto_session'
DanBarberPhoto::Application.config.session_store :cookie_store,
key: "_danbarberphoto_session"
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information

View File

@ -55,7 +55,7 @@ SimpleForm.setup do |config|
config.boolean_style = :nested
# Default class for buttons
config.button_class = 'btn'
config.button_class = "btn"
# Method used to tidy up errors. Specify any Rails Array method.
# :first lists the first message for each field.
@ -66,7 +66,7 @@ SimpleForm.setup do |config|
config.error_notification_tag = :div
# CSS class to add for error notification helper.
config.error_notification_class = 'alert alert-error'
config.error_notification_class = "alert alert-error"
# ID to add for error notification helper.
# config.error_notification_id = nil
@ -95,7 +95,7 @@ SimpleForm.setup do |config|
# config.label_text = lambda { |label, required| "#{required} #{label}" }
# You can define the class to use on all labels. Default is nil.
config.label_class = 'control-label'
config.label_class = "control-label"
# You can define the class to use on all forms. Default is simple_form.
# config.form_class = :simple_form

View File

@ -1,18 +1,18 @@
workers Integer(ENV['PUMA_WORKERS'] || 3)
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
workers Integer(ENV["PUMA_WORKERS"] || 3)
threads Integer(ENV["MIN_THREADS"] || 1), Integer(ENV["MAX_THREADS"] || 16)
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
port ENV["PORT"] || 3000
environment ENV["RACK_ENV"] || "development"
on_worker_boot do
# worker specific setup
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['MAX_THREADS'] || 16
config["pool"] = ENV["MAX_THREADS"] || 16
ActiveRecord::Base.establish_connection(config)
end
end

View File

@ -2,9 +2,9 @@ class CreatePhotos < ActiveRecord::Migration
def self.up
create_table :photos do |t|
t.integer :category_id
t.string :flickr_url
t.string :photo_file_name
t.string :photo_content_type
t.integer :photo_file_size

View File

@ -1,9 +1,9 @@
class AddPhotoToCategory < ActiveRecord::Migration
def self.up
add_column :categories, :photo_id, :integer
add_column :categories, :photo_id, :integer
end
def self.down
remove_column :categories, :photo_id
remove_column :categories, :photo_id
end
end

View File

@ -1,11 +1,11 @@
class AddDetailsToPhoto < ActiveRecord::Migration
def self.up
add_column :photos, :title, :string
add_column :photos, :description, :text
add_column :photos, :title, :string
add_column :photos, :description, :text
end
def self.down
remove_column :photos, :title
remove_column :photos, :description
remove_column :photos, :title
remove_column :photos, :description
end
end

View File

@ -5,7 +5,7 @@ class AddSortOrders < ActiveRecord::Migration
end
def self.down
remove_column :photos, :sort
remove_column :categories, :sort
remove_column :photos, :sort
remove_column :categories, :sort
end
end

View File

@ -1,7 +1,7 @@
class MoveToManyToMany < ActiveRecord::Migration
def self.up
remove_column :photos, :category_id
create_table :categories_photos, :id => false do |t|
create_table :categories_photos, id: false do |t|
t.integer :category_id
t.integer :photo_id
end

View File

@ -1,15 +1,14 @@
class CreateAdminUsers < ActiveRecord::Migration
def self.up
create_table :admin_users do |t|
t.string :first_name, :default => "", :null => false
t.string :last_name, :default => "", :null => false
t.string :role, :null => false
t.string :email, :null => false
t.boolean :status, :default => false
t.string :token, :null => false
t.string :salt, :null => false
t.string :crypted_password, :null => false
t.string :first_name, default: "", null: false
t.string :last_name, default: "", null: false
t.string :role, null: false
t.string :email, null: false
t.boolean :status, default: false
t.string :token, null: false
t.string :salt, null: false
t.string :crypted_password, null: false
t.string :preferences
t.timestamps
end
@ -18,5 +17,4 @@ class CreateAdminUsers < ActiveRecord::Migration
def self.down
drop_table :admin_users
end
end

View File

@ -1,9 +1,9 @@
class PhotoShowcase < ActiveRecord::Migration
def self.up
add_column :photos, :featured, :boolean, :default => false
add_column :photos, :featured, :boolean, default: false
end
def self.down
remove_column :photos, :featured
remove_column :photos, :featured
end
end

View File

@ -1,6 +1,6 @@
class AddEnabledToPhotos < ActiveRecord::Migration
def self.up
add_column :photos, :enabled, :boolean, :default => true
add_column :photos, :enabled, :boolean, default: true
end
def self.down

View File

@ -1,6 +1,6 @@
class AddTakenDateToPhoto < ActiveRecord::Migration
def self.up
add_column :photos, :taken_at, :datetime
add_column :photos, :taken_at, :datetime
end
def self.down

View File

@ -1,6 +1,6 @@
class AddViewCountToPhotos < ActiveRecord::Migration
def self.up
add_column :photos, :views, :integer, :default => 0
add_column :photos, :views, :integer, default: 0
end
def self.down

View File

@ -1,7 +1,7 @@
class AddSessionsTable < ActiveRecord::Migration
def up
create_table :sessions do |t|
t.string :session_id, :null => false
t.string :session_id, null: false
t.text :data
t.timestamps
end

View File

@ -5,14 +5,14 @@ class RemoveAdminUsers < ActiveRecord::Migration
def self.down
create_table :admin_users do |t|
t.string :first_name, :default => "", :null => false
t.string :last_name, :default => "", :null => false
t.string :role, :null => false
t.string :email, :null => false
t.boolean :status, :default => false
t.string :token, :null => false
t.string :salt, :null => false
t.string :crypted_password, :null => false
t.string :first_name, default: "", null: false
t.string :last_name, default: "", null: false
t.string :role, null: false
t.string :email, null: false
t.boolean :status, default: false
t.string :token, null: false
t.string :salt, null: false
t.string :crypted_password, null: false
t.string :preferences
t.timestamps
end

View File

@ -2,8 +2,8 @@ class CreateDeviseAdminUsers < ActiveRecord::Migration
def up
create_table(:admin_users) do |t|
# Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
# Recoverable
t.string :reset_password_token
@ -13,7 +13,7 @@ class CreateDeviseAdminUsers < ActiveRecord::Migration
t.datetime :remember_created_at
# Trackable
t.integer :sign_in_count, :default => 0
t.integer :sign_in_count, default: 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
@ -23,21 +23,21 @@ class CreateDeviseAdminUsers < ActiveRecord::Migration
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email # Only if using reconfirmable
t.string :unconfirmed_email
# Lockable
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.integer :failed_attempts, default: 0
t.string :unlock_token
t.datetime :locked_at
t.timestamps
end
add_index :admin_users, :email, :unique => true
add_index :admin_users, :reset_password_token, :unique => true
add_index :admin_users, :confirmation_token, :unique => true
add_index :admin_users, :unlock_token, :unique => true
# add_index :admin_users, :authentication_token, :unique => true
add_index :admin_users, :email, unique: true
add_index :admin_users, :reset_password_token, unique: true
add_index :admin_users, :confirmation_token, unique: true
add_index :admin_users, :unlock_token, unique: true
# add_index :admin_users, :authentication_token, unique: true
end
def down

View File

@ -1,5 +1,5 @@
class AddIndexToCategoriesPhotos < ActiveRecord::Migration
def change
add_index :categories_photos, [:category_id, :photo_id], unique: true
add_index :categories_photos, %i[category_id photo_id], unique: true
end
end

View File

@ -6,8 +6,8 @@ class RemoveDeviseAdminUsers < ActiveRecord::Migration
def down
create_table(:admin_users) do |t|
# Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
# Recoverable
t.string :reset_password_token
@ -17,7 +17,7 @@ class RemoveDeviseAdminUsers < ActiveRecord::Migration
t.datetime :remember_created_at
# Trackable
t.integer :sign_in_count, :default => 0
t.integer :sign_in_count, default: 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
@ -27,19 +27,19 @@ class RemoveDeviseAdminUsers < ActiveRecord::Migration
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email # Only if using reconfirmable
t.string :unconfirmed_email
# Lockable
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.integer :failed_attempts, default: 0
t.string :unlock_token
t.datetime :locked_at
t.timestamps
end
add_index :admin_users, :email, :unique => true
add_index :admin_users, :reset_password_token, :unique => true
add_index :admin_users, :confirmation_token, :unique => true
add_index :admin_users, :unlock_token, :unique => true
add_index :admin_users, :email, unique: true
add_index :admin_users, :reset_password_token, unique: true
add_index :admin_users, :confirmation_token, unique: true
add_index :admin_users, :unlock_token, unique: true
end
end

View File

@ -3,5 +3,5 @@
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
# cities = City.create([{ name: "Chicago" }, { name: "Copenhagen" }])
# Mayor.create(name: "Daley", city: cities.first)

View File

@ -5,8 +5,8 @@ describe Contact do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:message) }
it { is_expected.to allow_value('test@test.com').for(:email) }
it { is_expected.not_to allow_value('test@test').for(:email) }
it { is_expected.to allow_value("test@test.com").for(:email) }
it { is_expected.not_to allow_value("test@test").for(:email) }
let(:contact) { build(:contact) }
end

View File

@ -1,12 +1,12 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'capybara/poltergeist'
# This file is copied to spec/ when you run "rails generate rspec:install"
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../config/environment", __FILE__)
require "rspec/rails"
require "capybara/rspec"
require "capybara/poltergeist"
# For code coverage
require 'simplecov'
require "simplecov"
SimpleCov.start
# Use Poltergeist
@ -14,7 +14,7 @@ Capybara.javascript_driver = :poltergeist
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
# ## Mock Framework
@ -29,10 +29,10 @@ RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
config.include Ajax, type: :feature
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# Remove this line if you"re not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# If you"re not using ActiveRecord, or you"d prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
@ -46,7 +46,7 @@ RSpec.configure do |config|
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
config.order = "random"
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)

View File

@ -2,7 +2,7 @@ module Ajax
def wait_for_ajax
Timeout.timeout(Capybara.default_max_wait_time) do
loop do
active = page.evaluate_script('jQuery.active')
active = page.evaluate_script("jQuery.active")
break if active == 0
end
end