diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ef41bee5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build + +on: + push: + branches: + - master + pull_request: + +jobs: + build: + runs-on: ubuntu-24.04 + strategy: + matrix: + ruby-version: + - 3.2.6 + fail-fast: false + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Ruby ${{ matrix.ruby-version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Install dependencies + run: | + bundle config set without 'development' + bundle config path vendor/bundle + bundle install --jobs=9 --retry=2 --quiet + + - name: Setup test database + run: | + cp config/config.yml.sample config/config.yml + cp config/database.yml.sample config/database.yml + bin/rails db:migrate RAILS_ENV=test + + - name: Rubocop + run: | + bundle exec rubocop + + - name: Run RSpec + run: | + bundle exec rake spec + + - name: Run Cucumber + run: | + bundle exec rake cucumber diff --git a/.rubocop.yml b/.rubocop.yml index 994cd4c0..c0f62e3f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,11 +6,12 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.2 NewCops: enable Exclude: - 'db/schema.rb' - 'bin/*' + - 'vendor/**/*' Style/Documentation: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ec0ccd09..a0d17a26 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,21 +1,34 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-12-11 09:21:43 UTC using RuboCop version 1.5.2. +# on 2023-03-21 13:21:19 UTC using RuboCop version 1.48.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/OrAssignmentToConstant: + Exclude: + - 'config/application.rb' + - 'config/initializers/blacklist.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/RedundantDirGlobSort: + Exclude: + - 'spec/spec_helper.rb' + # Offense count: 15 -# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 34 -# Offense count: 15 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. -# IgnoredMethods: refine +# Offense count: 1 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. +# AllowedMethods: refine Metrics/BlockLength: - Max: 117 + Max: 29 # Offense count: 2 # Configuration parameters: CountComments, CountAsOne. @@ -23,17 +36,17 @@ Metrics/ClassLength: Max: 187 # Offense count: 2 -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 16 # Offense count: 16 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 29 + Max: 30 # Offense count: 2 -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 13 @@ -47,22 +60,30 @@ Naming/PredicateName: Exclude: - 'app/models/project.rb' +# Offense count: 9 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/BeEq: + Exclude: + - 'spec/lib/blacklist_spec.rb' + # Offense count: 1 -# Configuration parameters: Prefixes. +# Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: - 'spec/controllers/projects_controller_spec.rb' # Offense count: 13 -# Configuration parameters: Max. +# Configuration parameters: CountAsOne. RSpec/ExampleLength: + Max: 16 + +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: Exclude: - - 'spec/controllers/projects_controller_spec.rb' - - 'spec/lib/blacklist_spec.rb' - - 'spec/models/deposit_spec.rb' - - 'spec/routing/projects_routing_spec.rb' - - 'spec/routing/users_routing_spec.rb' + - 'spec/features/assets.rb' # Offense count: 2 # Configuration parameters: AssignmentOnly. @@ -82,7 +103,8 @@ RSpec/MultipleExpectations: Max: 9 # Offense count: 26 -# Configuration parameters: IgnoreSharedExamples. +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/controllers/home_controller_spec.rb' @@ -91,9 +113,16 @@ RSpec/NamedSubject: - 'spec/models/wallet_spec.rb' # Offense count: 4 +# Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 5 +# Offense count: 22 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Inferences. +RSpec/Rails/InferredSpecType: + Enabled: false + # Offense count: 2 RSpec/RepeatedExampleGroupBody: Exclude: @@ -104,6 +133,26 @@ RSpec/StubbedMock: Exclude: - 'spec/controllers/projects_controller_spec.rb' +# Offense count: 8 +RSpec/SubjectDeclaration: + Exclude: + - 'spec/controllers/home_controller_spec.rb' + - 'spec/controllers/projects_controller_spec.rb' + - 'spec/controllers/users_controller_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/ActiveSupportOnLoad: + Exclude: + - 'config/initializers/demoji.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments +Rails/FilePath: + Exclude: + - 'spec/spec_helper.rb' + # Offense count: 6 # Configuration parameters: Include. # Include: app/models/**/*.rb @@ -119,6 +168,13 @@ Rails/OutputSafety: - 'app/helpers/application_helper.rb' - 'app/helpers/rates_helper.rb' +# Offense count: 1 +# Configuration parameters: Include. +# Include: db/**/*.rb +Rails/ReversibleMigration: + Exclude: + - 'db/migrate/20140823060921_make_default_branch_blank.rb' + # Offense count: 11 # Configuration parameters: ForbiddenMethods, AllowedMethods. # ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all @@ -136,9 +192,20 @@ Style/MissingRespondToMissing: Exclude: - 'lib/bitcoin_rpc.rb' +# Offense count: 1 +Style/OpenStructUse: + Exclude: + - 'features/support/to_ostruct.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SelectByRegexp: + Exclude: + - 'spec/routing/users_routing_spec.rb' + # Offense count: 25 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: Max: 234 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..a1e3a5ab --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.2.6 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8e4b01eb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: ruby - -sudo: false - -git: - depth: 10 - -rvm: - - 2.6.6 - -bundler_args: --without development --jobs=9 --retry=2 --quiet - -before_script: - - cp config/config.yml.sample config/config.yml - - cp config/database.yml.sample config/database.yml - -script: - - bundle exec rubocop - - bundle exec rake db:migrate - - bundle exec rake spec - - bundle exec rake cucumber diff --git a/Gemfile b/Gemfile index b7caddd2..63b9a325 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,7 @@ source 'https://rubygems.org' -ruby '2.6.6' - -gem 'rails', '5.2.4.4' +gem 'rails', '6.1.7.10' gem 'acts_as_paranoid' gem 'airbrake' @@ -32,15 +30,14 @@ gem 'octokit' gem 'omniauth' gem 'omniauth-github' gem 'omniauth-rails_csrf_protection', '~> 0.1' +gem 'puma' gem 'rails-i18n' gem 'render_csv' gem 'rest-client' gem 'sass-rails' gem 'sawyer' gem 'sdoc', group: :doc, require: false -gem 'sidekiq' gem 'sprockets' -gem 'therubyracer', platforms: :ruby gem 'turbolinks' gem 'twitter-bootstrap-rails' gem 'uglifier' @@ -59,11 +56,13 @@ end group :development, :test do gem 'factory_bot_rails' + gem 'pry' + gem 'pry-byebug' gem 'rspec-rails' gem 'rubocop' gem 'rubocop-rails' gem 'rubocop-rspec' - gem 'sqlite3' + gem 'sqlite3', '~> 1.4' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 60c53382..518d1539 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,68 +1,87 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.4.4) - actionpack (= 5.2.4.4) + actioncable (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.4.4) - actionpack (= 5.2.4.4) - actionview (= 5.2.4.4) - activejob (= 5.2.4.4) + actionmailbox (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + mail (>= 2.7.1) + actionmailer (6.1.7.10) + actionpack (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activesupport (= 6.1.7.10) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.4.4) - actionview (= 5.2.4.4) - activesupport (= 5.2.4.4) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.7.10) + actionview (= 6.1.7.10) + activesupport (= 6.1.7.10) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.4.4) - activesupport (= 5.2.4.4) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.7.10) + actionpack (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + nokogiri (>= 1.8.5) + actionview (6.1.7.10) + activesupport (= 6.1.7.10) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.4.4) - activesupport (= 5.2.4.4) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.7.10) + activesupport (= 6.1.7.10) globalid (>= 0.3.6) - activemodel (5.2.4.4) - activesupport (= 5.2.4.4) - activerecord (5.2.4.4) - activemodel (= 5.2.4.4) - activesupport (= 5.2.4.4) - arel (>= 9.0) - activestorage (5.2.4.4) - actionpack (= 5.2.4.4) - activerecord (= 5.2.4.4) - marcel (~> 0.3.1) - activesupport (5.2.4.4) + activemodel (6.1.7.10) + activesupport (= 6.1.7.10) + activerecord (6.1.7.10) + activemodel (= 6.1.7.10) + activesupport (= 6.1.7.10) + activestorage (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activesupport (= 6.1.7.10) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.10) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) acts_as_paranoid (0.7.0) activerecord (>= 5.2, < 7.0) activesupport (>= 5.2, < 7.0) - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) - airbrake (11.0.1) - airbrake-ruby (~> 5.1) - airbrake-ruby (5.2.0) - rbtree3 (~> 0.5) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + airbrake (13.0.4) + airbrake-ruby (~> 6.0) + airbrake-ruby (6.2.2) + rbtree3 (~> 0.6) airbrussh (1.4.0) sshkit (>= 1.6.1, != 1.7.0) - arel (9.0.0) - ast (2.4.1) - backports (3.18.2) + ast (2.4.2) + backports (3.25.0) bcrypt (3.1.16) bcrypt_pbkdf (1.0.1) - bech32 (1.0.5) + bech32 (1.4.2) + thor (>= 1.1.0) bootstrap_form (4.5.0) actionpack (>= 5.2) activemodel (>= 5.2) - builder (3.2.4) + builder (3.3.0) + byebug (11.1.3) cancancan (3.1.0) capistrano (3.14.1) airbrussh (>= 1.0.0) @@ -77,14 +96,16 @@ GEM capistrano-rvm (0.1.2) capistrano (~> 3.0) sshkit (~> 1.2) - capybara (3.34.0) + capybara (3.40.0) addressable + matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.5) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + coderay (1.1.3) coffee-rails (5.0.0) coffee-script (>= 2.2.0) railties (>= 5.2.0) @@ -93,8 +114,7 @@ GEM execjs coffee-script-source (1.12.2) commonjs (0.2.7) - concurrent-ruby (1.1.7) - connection_pool (2.2.3) + concurrent-ruby (1.3.4) crack (0.4.4) crass (1.0.6) cucumber (3.2.0) @@ -120,6 +140,7 @@ GEM cucumber-tag_expressions (1.1.1) cucumber-wire (0.0.1) database_cleaner (1.8.5) + date (3.4.1) demoji (0.0.7) devise (4.7.3) bcrypt (~> 3.0) @@ -129,8 +150,8 @@ GEM warden (~> 1.2.3) devise-i18n (1.9.2) devise (>= 4.7.1) - diff-lcs (1.4.4) - docile (1.3.2) + diff-lcs (1.5.1) + docile (1.4.1) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) dusen (0.6.1) @@ -140,8 +161,7 @@ GEM ed25519 (1.2.4) edge_rider (1.1.0) activerecord (>= 3.2) - erubi (1.10.0) - erubis (2.7.0) + erubi (1.13.0) execjs (2.7.0) factory_bot (6.1.0) activesupport (>= 5.0.0) @@ -151,31 +171,26 @@ GEM faraday (1.1.0) multipart-post (>= 1.2, < 3) ruby2_keywords - ffi (1.13.1) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86_64-linux-gnu) gherkin (5.1.0) - globalid (0.4.2) - activesupport (>= 4.2.0) + globalid (1.2.1) + activesupport (>= 6.1) haml (5.2.1) temple (>= 0.8.0) tilt - haml-rails (2.0.1) + haml-rails (2.1.0) actionpack (>= 5.1) activesupport (>= 5.1) - haml (>= 4.0.6, < 6.0) - html2haml (>= 1.0.1) + haml (>= 4.0.6) railties (>= 5.1) hashdiff (1.0.1) hashie (4.1.0) - html2haml (2.2.0) - erubis (~> 2.7.0) - haml (>= 4.0, < 6) - nokogiri (>= 1.6.0) - ruby_parser (~> 3.5) http-accept (1.7.0) http-cookie (1.0.3) domain_name (~> 0.5) http_accept_language (2.1.1) - i18n (1.8.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) i18n-js (3.8.0) i18n (>= 0.6.6) @@ -188,6 +203,7 @@ GEM jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks + json (2.6.3) jwt (2.2.2) kaminari (1.2.1) activesupport (>= 4.1.0) @@ -210,36 +226,50 @@ GEM actionpack (>= 4) less (~> 2.6.0) sprockets (>= 2) - libv8 (3.16.14.19) - loofah (2.8.0) + logger (1.6.1) + loofah (2.23.1) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (1.0.0) - mime-types (3.3.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) + method_source (1.1.0) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2020.1104) - mimemagic (0.3.5) - mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.14.2) - money-tree (0.10.0) - ffi + mime-types-data (3.2024.1001) + mini_mime (1.1.5) + minitest (5.25.1) + money-tree (0.11.2) + bech32 (~> 1.3) + openssl (~> 3.1) multi_json (1.15.0) - multi_test (0.1.2) + multi_test (1.1.0) multi_xml (0.6.0) multipart-post (2.1.1) - mysql2 (0.5.3) + mysql2 (0.5.5) + net-imap (0.4.20) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout net-scp (3.0.0) net-ssh (>= 2.6.5, < 7.0.0) + net-smtp (0.5.0) + net-protocol net-ssh (6.1.0) netrc (0.11.0) - nio4r (2.5.4) - nokogiri (1.10.10) - mini_portile2 (~> 2.4.0) + nio4r (2.7.4) + nokogiri (1.18.9-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.9-x86_64-linux-gnu) + racc (~> 1.4) oauth2 (1.4.4) faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) @@ -261,54 +291,69 @@ GEM omniauth-rails_csrf_protection (0.1.2) actionpack (>= 4.2) omniauth (>= 1.3.1) + openssl (3.2.0) orm_adapter (0.5.0) - parallel (1.20.1) - parser (2.7.2.0) + parallel (1.22.1) + parser (3.2.1.1) ast (~> 2.4.1) - public_suffix (4.0.6) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (5.2.4.4) - actioncable (= 5.2.4.4) - actionmailer (= 5.2.4.4) - actionpack (= 5.2.4.4) - actionview (= 5.2.4.4) - activejob (= 5.2.4.4) - activemodel (= 5.2.4.4) - activerecord (= 5.2.4.4) - activestorage (= 5.2.4.4) - activesupport (= 5.2.4.4) - bundler (>= 1.3.0) - railties (= 5.2.4.4) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.10.1) + byebug (~> 11.0) + pry (>= 0.13, < 0.15) + psych (5.1.2) + stringio + public_suffix (6.0.1) + puma (6.4.3) + nio4r (~> 2.0) + racc (1.8.1) + rack (2.2.14) + rack-test (2.1.0) + rack (>= 1.3) + rails (6.1.7.10) + actioncable (= 6.1.7.10) + actionmailbox (= 6.1.7.10) + actionmailer (= 6.1.7.10) + actionpack (= 6.1.7.10) + actiontext (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activemodel (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + bundler (>= 1.15.0) + railties (= 6.1.7.10) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) - loofah (~> 2.3) - rails-i18n (5.1.3) + rails-html-sanitizer (1.6.1) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + rails-i18n (7.0.6) i18n (>= 0.7, < 2) - railties (>= 5.0, < 6) - railties (5.2.4.4) - actionpack (= 5.2.4.4) - activesupport (= 5.2.4.4) + railties (>= 6.0.0, < 8) + railties (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) method_source - rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) - rake (13.0.1) - rbnacl (7.1.1) - ffi - rbtree3 (0.6.0) - rdoc (6.2.1) - redis (4.2.5) - ref (2.0.0) - regexp_parser (1.8.2) + rake (>= 12.2) + thor (~> 1.0) + rainbow (3.1.1) + rake (13.2.1) + rbnacl (7.1.2) + ffi (~> 1) + rbtree3 (0.7.1) + rdoc (6.6.3.1) + psych (>= 4.0.0) + regexp_parser (2.9.2) render_csv (2.0.0) rails (>= 3.0) responders (3.0.1) @@ -319,7 +364,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.4) + rexml (3.3.9) rspec-activemodel-mocks (1.1.0) activemodel (>= 3.0) activesupport (>= 3.0) @@ -341,28 +386,29 @@ GEM rspec-mocks (~> 3.9) rspec-support (~> 3.9) rspec-support (3.10.0) - rubocop (1.6.1) + rubocop (1.48.1) + json (~> 2.3) parallel (~> 1.10) - parser (>= 2.7.1.5) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.2.0, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.26.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.3.0) - parser (>= 2.7.1.5) - rubocop-rails (2.9.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.27.0) + parser (>= 3.2.1.0) + rubocop-capybara (2.17.1) + rubocop (~> 1.41) + rubocop-rails (2.18.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) - rubocop-rspec (2.0.1) - rubocop (~> 1.0) - rubocop-ast (>= 1.1.0) - ruby-progressbar (1.10.1) + rubocop (>= 1.33.0, < 2.0) + rubocop-rspec (2.19.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.2) - ruby_parser (3.15.0) - sexp_processor (~> 4.9) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) sassc (2.4.0) @@ -378,37 +424,31 @@ GEM faraday (> 0.8, < 2.0) sdoc (2.0.2) rdoc (>= 5.0) - sexp_processor (4.15.1) shoulda-matchers (4.4.1) activesupport (>= 4.2.0) - sidekiq (6.1.2) - connection_pool (>= 2.2.2) - rack (~> 2.0) - redis (>= 4.2.0) - simplecov (0.20.0) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.2) - sprockets (4.0.2) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + sprockets (4.2.0) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.4.2) + sqlite3 (1.7.3-arm64-darwin) + sqlite3 (1.7.3-x86_64-linux) sshkit (1.21.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) + stringio (3.1.0) temple (0.8.2) - therubyracer (0.12.3) - libv8 (~> 3.16.14.15) - ref - thor (1.0.1) - thread_safe (0.3.6) + thor (1.3.2) tilt (2.0.10) + timeout (0.4.3) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -417,14 +457,14 @@ GEM execjs (>= 2.2.2, >= 2.2) less-rails (>= 2.5.0) railties (>= 3.1) - tzinfo (1.2.8) - thread_safe (~> 0.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.7) - unicode-display_width (1.7.0) + unicode-display_width (2.4.2) vcr (6.0.0) warden (1.2.9) rack (>= 2.0.9) @@ -432,14 +472,17 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.7.3) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.7.1) PLATFORMS - ruby + arm64-darwin-22 + arm64-darwin-24 + x86_64-linux DEPENDENCIES acts_as_paranoid @@ -477,7 +520,10 @@ DEPENDENCIES omniauth omniauth-github omniauth-rails_csrf_protection (~> 0.1) - rails (= 5.2.4.4) + pry + pry-byebug + puma + rails (= 6.1.7.10) rails-controller-testing rails-i18n rbnacl @@ -492,19 +538,14 @@ DEPENDENCIES sawyer sdoc shoulda-matchers - sidekiq simplecov sprockets - sqlite3 - therubyracer + sqlite3 (~> 1.4) turbolinks twitter-bootstrap-rails uglifier vcr webmock -RUBY VERSION - ruby 2.6.6p146 - BUNDLED WITH - 2.1.4 + 2.4.8 diff --git a/LICENSE b/LICENSE index ba6c1a51..b3246315 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 tip4commit +Copyright (c) 2023 tip4commit Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 3bfda6b4..a3d8ae80 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Tip4commit ========== [![tip for next commit](https://tip4commit.com/projects/307.svg)](https://tip4commit.com/projects/307) -[![Build Status](https://travis-ci.org/tip4commit/tip4commit.svg?branch=master)](https://travis-ci.org/tip4commit/tip4commit) +[![Build Status](https://github.com/tip4commit/tip4commit/workflows/Build/badge.svg)](https://github.com/tip4commit/tip4commit/actions) Donate bitcoins to open source projects or receive tips for code contributions. diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index df127c1d..75ca81d6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,15 +4,15 @@ class UsersController < ApplicationController before_action :authenticate_user!, :load_user, :valid_user!, except: %i[login index] before_action :redirect_to_pretty_url, only: [:show] + def index + @users = User.order(withdrawn_amount: :desc, commits_count: :desc).where('commits_count > 0 AND withdrawn_amount > 0').page(params[:page]).per(30) + end + def show @user_tips = @user.tips @recent_tips = @user_tips.includes(:project).order(created_at: :desc).first(5) end - def index - @users = User.order(withdrawn_amount: :desc, commits_count: :desc).where('commits_count > 0 AND withdrawn_amount > 0').page(params[:page]).per(30) - end - def update if @user.update(users_params) redirect_to @user, notice: I18n.t('notices.user_updated') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 835a0fdd..e4474169 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -29,6 +29,6 @@ def list_friendly_text(a_list, conjunction) end def block_explorer_tx_url(txid) - "https://tradeblock.com/bitcoin/tx/#{txid}" + "https://mempool.space/tx/#{txid}" end end diff --git a/app/models/project.rb b/app/models/project.rb index a9b7fdcb..70d72905 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -138,8 +138,8 @@ def tip_for(commit) # create a tip tip = tips.create( - user: user, - amount: amount, + user:, + amount:, commit: commit.sha, commit_message: commit.commit.message ) @@ -236,7 +236,7 @@ def generate_bitcoin_address class << self def export_labels - Hash[pluck(:bitcoin_address, :full_name)].to_json + pluck(:bitcoin_address, :full_name).to_h.to_json end def find_by_service_and_repo(service, repo) diff --git a/app/models/user.rb b/app/models/user.rb index f4ed033c..563b468b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,7 +77,7 @@ def find_by_commit(commit) email = commit.commit.author.email nickname = commit.author.try(:login) - find_by(email: email) || (nickname.blank? ? nil : find_by(nickname: nickname)) + find_by(email:) || (nickname.blank? ? nil : find_by(nickname:)) end def find_by_nickname(nickname) @@ -94,7 +94,7 @@ def gravatar def set_login_token! loop do self.login_token = SecureRandom.urlsafe_base64 - break login_token unless User.exists?(login_token: login_token) + break login_token unless User.exists?(login_token:) end end end diff --git a/app/models/wallet.rb b/app/models/wallet.rb index 920f70b3..9b300cfa 100644 --- a/app/models/wallet.rb +++ b/app/models/wallet.rb @@ -4,7 +4,7 @@ class Wallet < ApplicationRecord validates :name, :xpub, presence: true def generate_address - address = hd_wallet.node_for_path("0/#{last_address_index}.pub").to_address + address = address_by_index(last_address_index) self.last_address_index += 1 save address diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 4cbba835..0dbbffa5 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -1,6 +1,6 @@ = bootstrap_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post, class: 'form-devise' }) do |f| %h2= t('.title') - = devise_error_messages! + = render "devise/shared/error_messages", resource: resource = f.email_field :email, :autofocus => true = f.submit t('.submit'), class: 'btn btn-primary' %p diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 024a7f6d..55309a98 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -1,6 +1,6 @@ = bootstrap_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, class: 'form-devise' }) do |f| %h2= t('.title') - = devise_error_messages! + = render "devise/shared/error_messages", resource: resource = f.hidden_field :reset_password_token = f.password_field :password, :autofocus => true, :autocomplete => "off" = f.password_field :password_confirmation, :autocomplete => "off" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index ff2947a9..5eff00b0 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -1,6 +1,6 @@ = bootstrap_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, class: 'form-devise', role: 'form' }) do |f| %h2= t('.title') - = devise_error_messages! + = render "devise/shared/error_messages", resource: resource = f.email_field :email, :autofocus => true = f.submit t('.submit'), class: 'btn btn-primary' %p diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index d3c87d07..932e66f4 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -1,6 +1,6 @@ %h2 Resend unlock instructions = form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| - = devise_error_messages! + = render "devise/shared/error_messages", resource: resource %div = f.label :email %br/ diff --git a/bin/rails b/bin/rails index 07396602..6fb4e405 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index 17240489..4fbf10b9 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index 94fd4d79..90700ac4 100755 --- a/bin/setup +++ b/bin/setup @@ -1,6 +1,5 @@ #!/usr/bin/env ruby -require 'fileutils' -include FileUtils +require "fileutils" # path to your application root. APP_ROOT = File.expand_path('..', __dir__) @@ -9,24 +8,25 @@ 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. +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. # 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') + # Install JavaScript dependencies + system! 'bin/yarn' # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') - # cp 'config/database.yml.sample', 'config/database.yml' + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system! 'bin/rails db:setup' + system! 'bin/rails db:prepare' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' diff --git a/bin/yarn b/bin/yarn index 460dd565..9fab2c35 100755 --- a/bin/yarn +++ b/bin/yarn @@ -1,9 +1,15 @@ #!/usr/bin/env ruby APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do - begin - exec "yarnpkg", *ARGV - rescue Errno::ENOENT + yarn = ENV["PATH"].split(File::PATH_SEPARATOR). + select { |dir| File.expand_path(dir) != __dir__ }. + product(["yarn", "yarn.cmd", "yarn.ps1"]). + map { |dir, file| File.expand_path(file, dir) }. + find { |file| File.executable?(file) } + + if yarn + exec yarn, *ARGV + else $stderr.puts "Yarn executable was not detected in the system." $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" exit 1 diff --git a/config.ru b/config.ru index 667e328d..afd13e21 100644 --- a/config.ru +++ b/config.ru @@ -2,5 +2,5 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('config/environment', __dir__) +require File.expand_path('config/environment', __dir__) run Rails.application diff --git a/config/application.rb b/config/application.rb index e2412382..fafdcf59 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,8 +28,6 @@ class Application < Rails::Application config.autoload_paths += %W[#{config.root}/lib] config.assets.initialize_on_precompile = true config.available_locales = %w[en es fr nl ru pl hr de ro ko id ja pt my cn hk] - config.active_job.queue_adapter = :sidekiq - config.active_record.sqlite3.represent_boolean_as_integer = true end end diff --git a/config/deploy.rb b/config/deploy.rb index 73aa10e3..8b639376 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -8,7 +8,7 @@ set :deploy_to, '/home/apps/t4c' set :rvm_type, :user -set :rvm_ruby_version, '2.6.6' +set :rvm_ruby_version, '3.2.6' set :rvm_custom_path, '~/.rvm' set :format, :pretty diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 13bcd143..714353d5 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -7,9 +7,9 @@ # Supports bulk-adding hosts to roles, the primary # server in each group is considered to be the first # unless any hosts have the primary property set. -role :app, %w[apps@50.116.2.58] -role :web, %w[apps@50.116.2.58] -role :db, %w[apps@50.116.2.58] +role :app, %w[apps@tip4commit] +role :web, %w[apps@tip4commit] +role :db, %w[apps@tip4commit] set :rails_env, 'production' set :migration_role, 'db' diff --git a/config/environments/production.rb b/config/environments/production.rb index d2103f50..034d4342 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -84,5 +84,5 @@ # config.autoflush_log = false # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + config.log_formatter = Logger::Formatter.new end diff --git a/config/locales/de.yml b/config/locales/de.yml index b2ea2e77..c8f0cef6 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -2,7 +2,7 @@ de: tip4commit: Tip4Commit meta: title: Tragen Sie zu Open-Source-Projekten bei - description: Spenden Sie bitcoins an Projekte die Sie interessieren oder fügen Sie commits hinzu um Trinkgelder zu erhalten + description: Spenden Sie Bitcoins an Projekte die Sie interessieren oder fügen Sie Commits hinzu um Trinkgelder zu erhalten menu: home: Home projects: Unterstützte Projekte diff --git a/config/locales/en.yml b/config/locales/en.yml index 969ae7ff..171a69a1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -233,6 +233,6 @@ en: general: or: or disclaimer: - line1: "Tip4Commit is not affiliated with most of the projects." + line1: "Tip4Commit is not affiliated with most of these projects." line2: "There is no guarantee that tips will be claimed by developers." line3: "By donating the funds you agree that they can be sent to the Free Software Foundation or elsewhere at Tip4Commit's discretion." diff --git a/config/routes.rb b/config/routes.rb index 03fe0cd4..c1f67992 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,9 +8,9 @@ get '/users/login' => 'users#login', :as => 'login_users' get '/users/:user_id/tips' => 'tips#index', :constraints => { user_id: /\d+/ }, :as => 'user_tips' - get '/users/:nickname/tips' => 'tips#index', :constraints => { nickname: /\w[\d\w\-]*/ }, :as => 'user_tips_pretty' + get '/users/:nickname/tips' => 'tips#index', :constraints => { nickname: /\w[\d\w-]*/ }, :as => 'user_tips_pretty' get '/users/:id' => 'users#show', :constraints => { id: /\d+/ }, :as => 'user' - get '/users/:nickname' => 'users#show', :constraints => { nickname: /\w[\d\w\-]*/ }, :as => 'user_pretty' + get '/users/:nickname' => 'users#show', :constraints => { nickname: /\w[\d\w-]*/ }, :as => 'user_pretty' get '/projects/:project_id/tips' => 'tips#index', :constraints => { project_id: /\d+/ }, :as => 'project_tips' get '/projects/:project_id/deposits' => 'deposits#index', :constraints => { project_id: /\d+/ }, :as => 'project_deposits' diff --git a/db/migrate/20151219081507_add_bitcoin_address2_to_projects.rb b/db/migrate/20151219081507_add_bitcoin_address2_to_projects.rb index 4ac4957d..1f4122d4 100644 --- a/db/migrate/20151219081507_add_bitcoin_address2_to_projects.rb +++ b/db/migrate/20151219081507_add_bitcoin_address2_to_projects.rb @@ -2,7 +2,8 @@ class AddBitcoinAddress2ToProjects < ActiveRecord::Migration[4.2] def change - add_column :projects, :bitcoin_address2, :string, index: true + add_column :projects, :bitcoin_address2, :string + add_index :projects, :bitcoin_address2 reversible do |dir| dir.up do Project.find_each(&:generate_address2) diff --git a/db/schema.rb b/db/schema.rb index dd94d3c1..4227cedf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,17 +2,17 @@ # 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). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 2017_03_08_163825) do - create_table "collaborators", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "collaborators", force: :cascade do |t| t.integer "project_id" t.string "login" t.datetime "created_at" @@ -20,18 +20,18 @@ t.index ["project_id"], name: "index_collaborators_on_project_id" end - create_table "deposits", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "deposits", force: :cascade do |t| t.integer "project_id" t.string "txid" t.integer "confirmations" t.datetime "created_at" t.datetime "updated_at" - t.bigint "amount" + t.integer "amount", limit: 8 t.float "fee_size" t.index ["project_id"], name: "index_deposits_on_project_id" end - create_table "projects", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "projects", force: :cascade do |t| t.string "url" t.string "bitcoin_address" t.datetime "created_at" @@ -59,7 +59,7 @@ t.index ["github_id"], name: "index_projects_on_github_id", unique: true end - create_table "sendmanies", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "sendmanies", force: :cascade do |t| t.string "txid" t.text "data" t.string "result" @@ -68,7 +68,7 @@ t.datetime "updated_at" end - create_table "tipping_policies_texts", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "tipping_policies_texts", force: :cascade do |t| t.integer "project_id" t.integer "user_id" t.text "text" @@ -78,9 +78,9 @@ t.index ["user_id"], name: "index_tipping_policies_texts_on_user_id" end - create_table "tips", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "tips", force: :cascade do |t| t.integer "user_id" - t.bigint "amount" + t.integer "amount", limit: 8 t.integer "sendmany_id" t.datetime "created_at" t.datetime "updated_at" @@ -94,7 +94,7 @@ t.index ["user_id"], name: "index_tips_on_user_id" end - create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" @@ -115,10 +115,10 @@ t.boolean "unsubscribed" t.datetime "notified_at" t.integer "commits_count", default: 0 - t.bigint "withdrawn_amount", default: 0 - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" + t.integer "withdrawn_amount", limit: 8, default: 0 t.string "confirmation_token" + t.datetime "confirmation_sent_at" + t.datetime "confirmed_at" t.string "unconfirmed_email" t.string "display_name" t.integer "denom", default: 0 @@ -126,10 +126,10 @@ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end - create_table "wallets", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + create_table "wallets", force: :cascade do |t| t.string "name" t.string "xpub" - t.integer "last_address_index", default: 1 + t.integer "last_address_index", limit: 4, default: 1 t.datetime "created_at", null: false t.datetime "updated_at", null: false end diff --git a/features/step_definitions/common.rb b/features/step_definitions/common.rb index 2a7f96a3..dc5307e3 100644 --- a/features/step_definitions/common.rb +++ b/features/step_definitions/common.rb @@ -89,17 +89,18 @@ def parse_path_from_page_string(page_string) path = "/users/#{name}/#{action}" if is_valid_path # TODO: nyi # implicit cases - else case page_string - when 'home' then path = root_path - when 'sign_up' then path = new_user_registration_path - when 'sign_in' then path = new_user_session_path - when 'users' then path = users_path - when 'projects' then path = projects_path - when 'search' then path = search_projects_path - when 'tips' then path = tips_path - when 'deposits' then path = deposits_path - when 'withdrawals' then path = withdrawals_path - end + else + case page_string + when 'home' then path = root_path + when 'sign_up' then path = new_user_registration_path + when 'sign_in' then path = new_user_session_path + when 'users' then path = users_path + when 'projects' then path = projects_path + when 'search' then path = search_projects_path + when 'tips' then path = tips_path + when 'deposits' then path = deposits_path + when 'withdrawals' then path = withdrawals_path + end end path || page_string diff --git a/features/step_definitions/users_steps.rb b/features/step_definitions/users_steps.rb index 7984b949..9dffcff0 100644 --- a/features/step_definitions/users_steps.rb +++ b/features/step_definitions/users_steps.rb @@ -17,9 +17,9 @@ def create_user(nickname, has_bitcoiin_address) end Then(/^a developer named "(.*?)" does not exist$/) do |nickname| - User.where(nickname: nickname).first.should be_nil + User.where(nickname:).first.should be_nil end Then(/^a developer named "(.*?)" exists$/) do |nickname| - User.where(nickname: nickname).first.should_not be_nil + User.where(nickname:).first.should_not be_nil end diff --git a/features/support/ostruct_slice.rb b/features/support/ostruct_slice.rb index 95e6ac4d..3267fe82 100644 --- a/features/support/ostruct_slice.rb +++ b/features/support/ostruct_slice.rb @@ -3,7 +3,7 @@ require 'ostruct' class OpenStruct - def slice(*args, &block) - marshal_dump.slice(*args, &block) + def slice(...) + marshal_dump.slice(...) end end diff --git a/lib/bitcoin_address_validator.rb b/lib/bitcoin_address_validator.rb index 577a0f59..069f390b 100644 --- a/lib/bitcoin_address_validator.rb +++ b/lib/bitcoin_address_validator.rb @@ -4,7 +4,9 @@ class BitcoinAddressValidator < ActiveModel::EachValidator def validate_each(record, field, value) - record.errors[field] << 'Bitcoin address is invalid' unless value.blank? || valid_bitcoin_address?(value) + return if value.blank? || valid_bitcoin_address?(value) + + record.errors.add(field, :invalid, message: 'Bitcoin address is invalid') end private @@ -83,7 +85,7 @@ def b58_decode(value, length) result = long_value.chr + result - result = 0.chr * (length - result.length) + result if result.length < length + result = (0.chr * (length - result.length)) + result if result.length < length result end diff --git a/lib/bitcoin_tipper.rb b/lib/bitcoin_tipper.rb index 10506a6c..1cdde599 100644 --- a/lib/bitcoin_tipper.rb +++ b/lib/bitcoin_tipper.rb @@ -31,8 +31,8 @@ def check_and_withdrawal_funds # self.create_sendmany # end - Rails.logger.info 'Traversing sendmanies...' - Sendmany.where(txid: nil).each(&:send_transaction) + # Rails.logger.info 'Traversing sendmanies...' + # Sendmany.where(txid: nil).each(&:send_transaction) end def auto_decide_older_tips @@ -76,13 +76,13 @@ def create_sendmany Rails.logger.info 'Creating sendmany' ActiveRecord::Base.transaction do sendmany = Sendmany.create - outs = calculate_outputs + outs = calculate_outputs(sendmany) sendmany.update_attribute :data, outs.to_json Rails.logger.info " #{sendmany.inspect}" end end - def calculate_outputs + def calculate_outputs(sendmany) outputs = {} User.find_each do |user| next unless user.ready_for_withdrawal? diff --git a/lib/blacklist.rb b/lib/blacklist.rb index d30d5a75..2fa2733b 100644 --- a/lib/blacklist.rb +++ b/lib/blacklist.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'set' - class Blacklist def initialize(urls) urls = urls.map { |u| normalize_url(u) } diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake index e279deb6..18999e06 100644 --- a/lib/tasks/cucumber.rake +++ b/lib/tasks/cucumber.rake @@ -38,8 +38,8 @@ unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gem task statsetup: :environment do require 'rails/code_statistics' - ::STATS_DIRECTORIES << %w[Cucumber\ features features] if File.exist?('features') - ::CodeStatistics::TEST_TYPES << 'Cucumber features' if File.exist?('features') + STATS_DIRECTORIES << ['Cucumber features', 'features'] if File.exist?('features') + CodeStatistics::TEST_TYPES << 'Cucumber features' if File.exist?('features') end end desc 'Alias for cucumber:ok' diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index c166f257..743fc801 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -69,7 +69,7 @@ # end shared_context 'accessing_project' do |verb, action| - let(:a_project) { create :project, host: 'github', full_name: 'test/test' } + let(:a_project) { create(:project, host: 'github', full_name: 'test/test') } context 'with existsing project' do it 'via project id returns 302 status code' do diff --git a/spec/factories/wallets.rb b/spec/factories/wallets.rb index 9c2f74d9..61c3a212 100644 --- a/spec/factories/wallets.rb +++ b/spec/factories/wallets.rb @@ -5,7 +5,7 @@ name { 'test wallet' } xpub do 'xpub661MyMwAqRbcFepxYZyGLKMTkTPDvbfLaoYDbw4d4iQT5SycGiJQREuraJ2N6Uh' \ - 'LGPcjXDhnARdtcUhgqN3a2dgQ3Dx8u1chtk8Rx16LrWg' + 'LGPcjXDhnARdtcUhgqN3a2dgQ3Dx8u1chtk8Rx16LrWg' end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9231f65f..27a1ad36 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -40,7 +40,7 @@ # config.mock_with :rr # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = "#{Rails.root}/spec/fixtures" # 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.