From 6bba8921d96561c347bd5c3c48a99d8e061ecded Mon Sep 17 00:00:00 2001 From: marsz Date: Sat, 8 Jun 2019 11:46:09 +0800 Subject: [PATCH 1/9] fix: github hook force create --- app/contexts/github/bind_context.rb | 14 +++++++++----- app/contexts/github/unbind_context.rb | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/contexts/github/bind_context.rb b/app/contexts/github/bind_context.rb index dbfecf48..09da482c 100644 --- a/app/contexts/github/bind_context.rb +++ b/app/contexts/github/bind_context.rb @@ -26,11 +26,15 @@ def generate_webhook_token end def bind_github - @webhook = ::GithubService.new(@owner.full_access_token.value).create_hook(@params[:repo_fullname], @github.webhook_url) - if @webhook - @github.hook_id = @webhook.attrs[:id] - else - false + begin + @webhook = ::GithubService.new(@owner.full_access_token.value).create_hook(@params[:repo_fullname], @github.webhook_url) + if @webhook + @github.hook_id = @webhook.attrs[:id] + else + false + end + rescue Octokit::NotFound => _e + true end end diff --git a/app/contexts/github/unbind_context.rb b/app/contexts/github/unbind_context.rb index 04a4a8a3..bd870aa2 100644 --- a/app/contexts/github/unbind_context.rb +++ b/app/contexts/github/unbind_context.rb @@ -11,7 +11,7 @@ def perform github_client = GithubService.new(token) return false unless token && github_client.permission_scopes.include?('admin:repo_hook') - github_client.delete_hook(@github.repo_fullname, @github.hook_id) + github_client.delete_hook(@github.repo_fullname, @github.hook_id) if @github.hook_id.present? @github.destroy end end From 93a0f9d1196ea90c8efc878f52da0b3ebb3ef8e1 Mon Sep 17 00:00:00 2001 From: marsz Date: Sat, 8 Jun 2019 12:04:23 +0800 Subject: [PATCH 2/9] rubocop fix --- app/contexts/github/bind_context.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/contexts/github/bind_context.rb b/app/contexts/github/bind_context.rb index 09da482c..1e65e987 100644 --- a/app/contexts/github/bind_context.rb +++ b/app/contexts/github/bind_context.rb @@ -26,16 +26,14 @@ def generate_webhook_token end def bind_github - begin - @webhook = ::GithubService.new(@owner.full_access_token.value).create_hook(@params[:repo_fullname], @github.webhook_url) - if @webhook - @github.hook_id = @webhook.attrs[:id] - else - false - end - rescue Octokit::NotFound => _e - true + @webhook = ::GithubService.new(@owner.full_access_token.value).create_hook(@params[:repo_fullname], @github.webhook_url) + if @webhook + @github.hook_id = @webhook.attrs[:id] + else + false end + rescue Octokit::NotFound => _e + true end def save_github From ba37a2223fea157ab909c98e458eda1078af0bdb Mon Sep 17 00:00:00 2001 From: marsz Date: Tue, 5 May 2020 11:15:39 +0800 Subject: [PATCH 3/9] feat: records order --- app/controllers/records_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/records_controller.rb b/app/controllers/records_controller.rb index 8bf0a4fa..51fadb7f 100644 --- a/app/controllers/records_controller.rb +++ b/app/controllers/records_controller.rb @@ -10,7 +10,7 @@ class RecordsController < BaseController # GET /projects/:project_id/records # GET /records def index - @q = Search::Record.all.merge(@scoped.order('id DESC')).ransack(params[:q]) + @q = Search::Record.all.merge(@scoped.order(created_at: :desc)).ransack(params[:q]) @records = @q.result.page(params[:page]).per(30) @total_time = @q.result.total_time end From 45634a130cd302fb5906478aaa2a719e4a7cda30 Mon Sep 17 00:00:00 2001 From: marsz Date: Tue, 5 May 2020 11:50:20 +0800 Subject: [PATCH 4/9] fix: remove id records --- app/models/search/record.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/search/record.rb b/app/models/search/record.rb index e6b0ee44..97897550 100644 --- a/app/models/search/record.rb +++ b/app/models/search/record.rb @@ -62,9 +62,9 @@ def group_collection def to_csv(opts = {}) CSV.generate(opts) do |csv| - csv << ['ID', 'User', 'Type', 'minutes', 'note', 'time'] + csv << ['User', 'Type', 'minutes', 'note', 'time'] all.find_each do |o| # reset pagination - csv << [o.id, o.user.try(:name), record_type_name(o.record_type), o.minutes, o.note, o.created_at] + csv << [o.user.try(:name), record_type_name(o.record_type), o.minutes, o.note, o.created_at] end end end From 3ff6342e2120ed6421b79813faa0fe2b4e069feb Mon Sep 17 00:00:00 2001 From: marsz Date: Fri, 1 Oct 2021 10:10:10 +0800 Subject: [PATCH 5/9] feat: big upgrade --- .rubocop.yml | 19 +- .ruby-version | 2 +- Gemfile | 42 +- Gemfile.lock | 743 +++++++++--------- app/assets/config/manifest.js | 3 + app/assets/javascripts/cable.js | 1 - app/assets/stylesheets/_basics.scss | 4 +- app/assets/stylesheets/_layouts.scss | 3 +- app/assets/stylesheets/application.css.scss | 6 +- .../github/receive_callbacks_context.rb | 19 +- app/contexts/user/get_settlement_context.rb | 2 +- app/models/authorization.rb | 2 +- app/models/project.rb | 2 +- app/models/record.rb | 2 +- app/views/application/_favicon.html.slim | 4 +- app/views/devise/sessions/new.html.slim | 2 +- app/views/layouts/_header.html.slim | 2 +- .../projects_hours_limit_check_worker.rb | 6 - app/workers/todos_auto_publish_worker.rb | 6 - config/deploy/production.rb | 2 +- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- config/environments/staging.rb | 2 +- config/initializers/assets.rb | 2 + config/initializers/omniauth.rb | 3 + config/initializers/paper_trail.rb | 2 +- config/initializers/sidetiq.rb | 17 - config/routes.rb | 1 - db/migrate/20141117070551_enable_hstore.rb | 2 +- db/migrate/20141117070654_enabled_postgis.rb | 2 +- .../20141117072407_devise_create_users.rb | 2 +- ...20150201093154_add_column_admin_to_user.rb | 2 +- ...150919073404_add_column_avatar_to_users.rb | 2 +- ...on_migration.acts_as_taggable_on_engine.rb | 4 +- ...ique_indices.acts_as_taggable_on_engine.rb | 2 +- ...ache_to_tags.acts_as_taggable_on_engine.rb | 2 +- ...ggable_index.acts_as_taggable_on_engine.rb | 2 +- ...or_tag_names.acts_as_taggable_on_engine.rb | 2 +- .../20151106075744_create_categories.rb | 2 +- ...220_add_column_deleted_at_to_categories.rb | 2 +- db/migrate/20151106081428_create_versions.rb | 2 +- ...06081429_add_object_changes_to_versions.rb | 2 +- ...109063212_add_column_sort_to_categories.rb | 2 +- .../20151218091334_create_authorizations.rb | 2 +- ...20151223075436_add_column_data_to_users.rb | 2 +- db/migrate/20151223083152_create_projects.rb | 2 +- .../20151223084814_create_project_users.rb | 2 +- db/migrate/20151223085717_create_records.rb | 2 +- db/migrate/20151223090403_create_comments.rb | 2 +- ...20151225070214_refactor_index_to_models.rb | 2 +- .../20151230081125_add_data_to_projects.rb | 2 +- ...0151230101922_add_data_column_to_models.rb | 2 +- ...0113173816_change_column_of_record_type.rb | 2 +- .../20160130083518_create_slack_channels.rb | 2 +- ...053118_add_column_sort_to_project_users.rb | 2 +- ...15538_add_column_hstore_to_project_uers.rb | 2 +- db/migrate/20160217070207_create_todos.rb | 2 +- ...217082804_add_column_todo_id_to_records.rb | 2 +- ...0023636_change_column_todo_date_to_date.rb | 2 +- .../20160220075305_remove_column_todo_ids.rb | 2 +- ...20160229041039_add_column_done_to_todos.rb | 2 +- ...042422_rename_and_add_columns_for_todos.rb | 2 +- ...20160305071327_add_column_sort_to_todos.rb | 2 +- ...0816_add_column_todo_published_to_users.rb | 2 +- db/migrate/20160405123606_create_githubs.rb | 2 +- ...1713_change_column_of_todo_done_default.rb | 2 +- .../20160909054022_add_status_to_todos.rb | 2 +- .../20161110021810_remove_column_todo_done.rb | 2 +- ...613063720_add_archived_to_project_users.rb | 2 +- ...70915212733_add_wage_to_project_members.rb | 2 +- ..._on_taggings.acts_as_taggable_on_engine.rb | 8 +- db/schema.rb | 266 +++---- lib/capistrano/deploy_messaging.rb | 3 - lib/tasks/auto_annotate_models.rake | 2 +- lib/tasks/dev.rake | 2 +- .../common/project_add_user_context_spec.rb | 9 +- .../notify/generate_message_context_spec.rb | 3 +- .../notify/send_to_slack_context_spec.rb | 10 +- .../notify/send_to_user_context_spec.rb | 8 +- spec/contexts/notify/trigger_context_spec.rb | 15 +- .../project/hours_limit_check_context_spec.rb | 11 +- .../update_project_users_context_spec.rb | 7 +- spec/contexts/project_delete_context_spec.rb | 13 +- spec/contexts/project_invite_context_spec.rb | 12 +- .../project_remove_user_context_spec.rb | 11 +- spec/contexts/project_update_context_spec.rb | 19 +- spec/contexts/record_create_context_spec.rb | 14 +- spec/contexts/record_delete_context_spec.rb | 14 +- spec/contexts/record_update_context_spec.rb | 15 +- .../slack_channel_create_context_spec.rb | 10 +- .../slack_channel_delete_context_spec.rb | 11 +- .../slack_channel_update_context_spec.rb | 12 +- spec/contexts/todo_calculate_context_spec.rb | 17 +- .../todo_change_status_context_spec.rb | 30 +- .../todo_create_by_record_context_spec.rb | 6 +- spec/contexts/todo_create_context_spec.rb | 6 +- spec/contexts/todo_delete_context_spec.rb | 9 +- spec/contexts/todo_publish_context_spec.rb | 23 +- spec/contexts/todo_update_context_spec.rb | 14 +- spec/contexts/user_auth_context_spec.rb | 30 +- .../user_create_project_context_spec.rb | 8 +- .../controllers/admin/base_controller_spec.rb | 12 +- .../admin/categories_controller_spec.rb | 31 +- .../admin/users_controller_spec.rb | 28 +- .../authorizations_controller_spec.rb | 14 +- spec/controllers/base_controller_spec.rb | 4 +- .../collaborators_controller_spec.rb | 16 +- spec/controllers/comments_controller_spec.rb | 22 +- .../project_users_controller_spec.rb | 8 +- spec/controllers/projects_controller_spec.rb | 56 +- spec/controllers/records_controller_spec.rb | 127 +-- .../slack_channels_controller_spec.rb | 56 +- spec/controllers/todos_controller_spec.rb | 84 +- .../users/passwords_controller_spec.rb | 1 + .../users/registrations_controller.spec.rb | 1 + spec/factories/authorizations.rb | 4 +- spec/factories/categories.rb | 6 +- spec/factories/comments.rb | 10 +- spec/factories/githubs.rb | 2 +- spec/factories/project_users.rb | 14 +- spec/factories/projects.rb | 26 +- spec/factories/records.rb | 22 +- spec/factories/slack_channels.rb | 24 +- spec/factories/tags.rb | 2 +- spec/factories/todos.rb | 20 +- spec/factories/users.rb | 20 +- spec/mailers/base_notifier_spec.rb | 2 +- spec/models/authorization_spec.rb | 4 +- spec/models/category_spec.rb | 12 +- spec/models/comment_spec.rb | 4 +- spec/models/project_spec.rb | 25 +- spec/models/project_user_spec.rb | 4 +- spec/models/record_spec.rb | 4 +- spec/models/slack_channel_spec.rb | 10 +- spec/models/todo_spec.rb | 52 +- spec/models/user_spec.rb | 12 +- spec/rails_helper.rb | 2 +- spec/services/datetime_service_spec.rb | 1 + spec/services/github_service_spec.rb | 2 +- spec/services/timecop_spec.rb | 4 +- spec/support/html_matchers.rb | 2 +- spec/support/request_client.rb | 2 +- .../projects_hours_limit_check_worker_spec.rb | 3 +- .../workers/todos_auto_publish_worker_spec.rb | 7 +- 144 files changed, 1260 insertions(+), 1109 deletions(-) create mode 100644 app/assets/config/manifest.js delete mode 100644 config/initializers/sidetiq.rb diff --git a/.rubocop.yml b/.rubocop.yml index 5cecceb0..5dd5a762 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,9 @@ +inherit_from: .rubocop_todo.yml + +require: + - rubocop-rails + - rubocop-rspec + AllCops: Exclude: - bin/**/* @@ -63,16 +69,9 @@ Style/WordArray: Metrics/CyclomaticComplexity: Enabled: false -Metrics/LineLength: +Layout/LineLength: Enabled: false -Metrics/MethodLength: - CountComments: false # count full line comments? - Max: 20 - -Metrics/AbcSize: - Max: 30 - Rails/HasAndBelongsToMany: Enabled: false @@ -101,7 +100,7 @@ Lint/NestedMethodDefinition: Enabled: false Metrics/AbcSize: - Max: 50 + Max: 300 Metrics/PerceivedComplexity: Max: 30 @@ -163,6 +162,6 @@ Rails/UnknownEnv: Rails/InverseOf: Enabled: false -Naming/UncommunicativeMethodParamName: +Naming/MethodParameterName: Enabled: false diff --git a/.ruby-version b/.ruby-version index 0bee604d..338a5b5d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.3 +2.6.6 diff --git a/Gemfile b/Gemfile index b44a3430..b8c5ea63 100644 --- a/Gemfile +++ b/Gemfile @@ -27,8 +27,9 @@ gem 'slim' # assets gem 'asset_sync' -gem 'coffee-rails', '~> 4.2' -gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails' +gem 'sassc-rails' +gem 'uglifier' # JS plugin gem 'jquery-rails' @@ -37,7 +38,6 @@ gem 'select2-rails', '~> 3' # background jobs gem 'sidekiq' gem 'sidekiq-limit_fetch' -gem 'sidetiq' gem 'sinatra', '~> 2.0.0.beta2' # file upload @@ -51,7 +51,7 @@ gem 'paranoia' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' group :staging, :production do - gem 'newrelic_rpm' + # gem 'newrelic_rpm' end group :development do @@ -65,26 +65,31 @@ group :development do gem 'slackistrano' gem 'annotate' - gem 'awesome_print' - gem 'better_errors' - gem 'binding_of_caller' - gem 'guard' - gem 'guard-annotate' + # gem 'awesome_print' + # gem 'better_errors' + # gem 'binding_of_caller' + # gem 'guard' + # gem 'guard-annotate' gem 'http_logger' - gem 'pry' - gem 'pry-rails' - gem 'pry-remote' - gem 'spring' - gem 'web-console', '~> 3.0' - gem 'xray-rails' + # gem 'pry' + # gem 'pry-rails' + # gem 'pry-remote' + # gem 'spring' + # gem 'web-console', '~> 3.0' + # gem 'xray-rails' + gem 'listen' + gem 'rails_real_favicon' + gem 'rubocop' + gem 'rubocop-rails' + gem 'rubocop-rspec' end group :development, :test do gem 'byebug' - gem 'factory_girl_rails' + # gem 'factory_girl_rails' + gem 'factory_bot_rails' gem 'rspec' gem 'rspec-rails' - gem 'rubocop', require: false end group :test do @@ -134,7 +139,8 @@ gem 'ransack' # omniauth gem 'omniauth' gem 'omniauth-github' - +gem 'omniauth-oauth2' +gem 'omniauth-rails_csrf_protection' # third-party api gem 'octokit' diff --git a/Gemfile.lock b/Gemfile.lock index c3bb7b5f..187ee6bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,181 +2,196 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.3.6) - aasm (5.0.1) + aasm (5.2.0) concurrent-ruby (~> 1.0) - actioncable (5.2.2) - actionpack (= 5.2.2) + actioncable (5.2.6) + actionpack (= 5.2.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.2) - actionpack (= 5.2.2) - actionview (= 5.2.2) - activejob (= 5.2.2) + actionmailer (5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.2) - actionview (= 5.2.2) - activesupport (= 5.2.2) - rack (~> 2.0) + actionpack (5.2.6) + actionview (= 5.2.6) + activesupport (= 5.2.6) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.2) - activesupport (= 5.2.2) + actionview (5.2.6) + activesupport (= 5.2.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.2) - activesupport (= 5.2.2) + activejob (5.2.6) + activesupport (= 5.2.6) globalid (>= 0.3.6) - activemodel (5.2.2) - activesupport (= 5.2.2) - activerecord (5.2.2) - activemodel (= 5.2.2) - activesupport (= 5.2.2) + activemodel (5.2.6) + activesupport (= 5.2.6) + activerecord (5.2.6) + activemodel (= 5.2.6) + activesupport (= 5.2.6) arel (>= 9.0) - activerecord-postgis-adapter (5.2.2) + activerecord-postgis-adapter (5.2.3) activerecord (~> 5.1) rgeo-activerecord (~> 6.0) - activestorage (5.2.2) - actionpack (= 5.2.2) - activerecord (= 5.2.2) - marcel (~> 0.3.1) - activesupport (5.2.2) + activestorage (5.2.6) + actionpack (= 5.2.6) + activerecord (= 5.2.6) + marcel (~> 1.0.0) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - acts-as-taggable-on (6.0.0) - activerecord (~> 5.0) - acts_as_list (0.9.17) - activerecord (>= 3.0) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - airbrussh (1.3.1) + acts-as-taggable-on (8.1.0) + activerecord (>= 5.0, < 6.2) + acts_as_list (1.0.4) + activerecord (>= 4.2) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + airbrussh (1.4.0) sshkit (>= 1.6.1, != 1.7.0) - annotate (2.7.4) - activerecord (>= 3.2, < 6.0) - rake (>= 10.4, < 13.0) + aliyun-sdk (0.8.0) + nokogiri (~> 1.6) + rest-client (~> 2.0) + annotate (3.1.1) + activerecord (>= 3.2, < 7.0) + rake (>= 10.4, < 14.0) arel (9.0.0) - asset_sync (2.6.0) + asset_sync (2.15.0) activemodel (>= 4.1.0) fog-core mime-types (>= 2.99) unf - ast (2.4.0) - autoprefixer-rails (9.4.3) - execjs - awesome_print (1.8.0) - aws-eventstream (1.0.1) - aws-partitions (1.127.0) - aws-sdk-core (3.44.1) - aws-eventstream (~> 1.0) - aws-partitions (~> 1.0) - aws-sigv4 (~> 1.0) + ast (2.4.2) + autoprefixer-rails (10.3.3.0) + execjs (~> 2) + aws-eventstream (1.2.0) + aws-partitions (1.509.0) + aws-record (2.6.1) + aws-sdk-dynamodb (~> 1.18) + aws-sdk-core (3.121.1) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) + aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-rails (2.0.1) + aws-sdk-dynamodb (1.63.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-rails (3.6.1) + aws-record (~> 2) aws-sdk-ses (~> 1) - railties (>= 3) - aws-sdk-ses (1.14.0) - aws-sdk-core (~> 3, >= 3.39.0) - aws-sigv4 (~> 1.0) - aws-sigv4 (1.0.3) - bcrypt (3.1.12) - better_errors (2.5.0) - coderay (>= 1.0.0) - erubi (>= 1.0.0) - rack (>= 0.9.0) - bindex (0.5.0) - binding_of_caller (0.8.0) - debug_inspector (>= 0.0.1) - bootstrap-sass (3.4.0) + aws-sdk-sqs (~> 1) + aws-sessionstore-dynamodb (~> 2) + concurrent-ruby (~> 1) + railties (>= 5.2.0) + aws-sdk-ses (1.41.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sdk-sqs (1.44.0) + aws-sdk-core (~> 3, >= 3.120.0) + aws-sigv4 (~> 1.1) + aws-sessionstore-dynamodb (2.0.1) + aws-sdk-dynamodb (~> 1) + rack (~> 2) + aws-sigv4 (1.4.0) + aws-eventstream (~> 1, >= 1.0.2) + bcrypt (3.1.16) + bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) - builder (3.2.3) - byebug (10.0.2) - capistrano (3.11.0) + builder (3.2.4) + byebug (11.1.3) + capistrano (3.16.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-bundler (1.5.0) + capistrano-bundler (2.0.1) capistrano (~> 3.1) - capistrano-rails (1.4.0) + capistrano-rails (1.6.1) capistrano (~> 3.1) - capistrano-bundler (~> 1.1) - capistrano-rbenv (2.1.4) + capistrano-bundler (>= 1.1, < 3) + capistrano-rbenv (2.2.0) capistrano (~> 3.1) sshkit (~> 1.3) - capistrano-sidekiq (1.0.2) + capistrano-sidekiq (1.0.3) capistrano (>= 3.9.0) - sidekiq (>= 3.4) + sidekiq (>= 3.4, < 6.0) capistrano3-unicorn (0.2.1) capistrano (~> 3.1, >= 3.1.0) - carrierwave (1.3.1) - activemodel (>= 4.0.0) - activesupport (>= 4.0.0) - mime-types (>= 1.16) - celluloid (0.17.4) - celluloid-essentials - celluloid-extras - celluloid-fsm - celluloid-pool - celluloid-supervision - timers (>= 4.1.1) - celluloid-essentials (0.20.5) - timers (>= 4.1.1) - celluloid-extras (0.20.5) - timers (>= 4.1.1) - celluloid-fsm (0.20.5) - timers (>= 4.1.1) - celluloid-pool (0.20.5) - timers (>= 4.1.1) - celluloid-supervision (0.20.6) - timers (>= 4.1.1) - coderay (1.1.2) - coffee-rails (4.2.2) + carrierwave (2.2.2) + activemodel (>= 5.0.0) + activesupport (>= 5.0.0) + addressable (~> 2.6) + image_processing (~> 1.1) + marcel (~> 1.0.0) + mini_mime (>= 0.1.3) + ssrf_filter (~> 1.0) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.4) - connection_pool (2.2.2) - crack (0.4.3) - safe_yaml (~> 1.0.0) - crass (1.0.4) + concurrent-ruby (1.1.9) + connection_pool (2.2.5) + crack (0.4.5) + rexml + crass (1.0.6) crummy (1.8.0) - dalli (2.7.9) - debug_inspector (0.0.3) - devise (4.5.0) + dalli (2.7.11) + devise (4.8.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 6.0) + railties (>= 4.1.0) responders warden (~> 1.2.3) devise-async (1.0.0) activejob (>= 5.0) devise (>= 4.0) - diff-lcs (1.3) - dotenv (2.5.0) - dotenv-rails (2.5.0) - dotenv (= 2.5.0) - railties (>= 3.2, < 6.0) - dry-inflector (0.1.2) - erubi (1.8.0) - excon (0.62.0) - execjs (2.7.0) - factory_girl (4.9.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.9.0) - factory_girl (~> 4.9.0) - railties (>= 3.0.0) - faraday (0.15.4) + diff-lcs (1.4.4) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.6) + dotenv-rails (2.7.6) + dotenv (= 2.7.6) + railties (>= 3.2) + dry-inflector (0.2.1) + erubi (1.10.0) + excon (0.85.0) + execjs (2.8.1) + factory_bot (6.2.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.2.0) + factory_bot (~> 6.2.0) + railties (>= 5.0.0) + faraday (1.8.0) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) multipart-post (>= 1.2, < 3) - ffi (1.9.25) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + ffi (1.15.4) fission (0.5.0) CFPropertyList (~> 2.2) fog (1.41.0) @@ -213,7 +228,8 @@ GEM fog-xml (~> 0.1.1) ipaddress (~> 0.5) json (>= 1.8, < 2.0) - fog-aliyun (0.3.2) + fog-aliyun (0.3.19) + aliyun-sdk (~> 0.8.0) fog-core fog-json ipaddress (~> 0.8) @@ -259,7 +275,7 @@ GEM fog-core fog-json fog-xml - fog-internet-archive (0.0.1) + fog-internet-archive (0.0.2) fog-core fog-json fog-xml @@ -269,9 +285,9 @@ GEM fog-json (1.2.0) fog-core multi_json (~> 1.10) - fog-local (0.6.0) + fog-local (0.7.0) fog-core (>= 1.27, < 3.0) - fog-openstack (0.3.9) + fog-openstack (0.3.10) fog-core (>= 1.45, <= 2.1.0) fog-json (>= 1.0) ipaddress (>= 0.8) @@ -316,9 +332,9 @@ GEM fog-voxel (0.1.0) fog-core fog-xml - fog-vsphere (2.5.0) + fog-vsphere (3.5.0) fog-core - rbvmomi (~> 1.9) + rbvmomi (>= 1.9, < 3) fog-xenserver (1.0.0) fog-core fog-xml @@ -326,329 +342,314 @@ GEM fog-xml (0.1.3) fog-core nokogiri (>= 1.5.11, < 2.0.0) - formatador (0.2.5) - globalid (0.4.1) - activesupport (>= 4.2.0) - guard (2.15.0) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-annotate (2.3) - annotate (~> 2.4, >= 2.4.0) - guard-compat (~> 1.2, >= 1.2.1) - guard-compat (1.2.1) - hashdiff (0.3.8) - hashie (3.6.0) - http_logger (0.5.1) - i18n (1.3.0) + formatador (0.3.0) + globalid (0.5.2) + activesupport (>= 5.0) + hashdiff (1.0.1) + hashie (4.1.0) + http-accept (1.7.0) + http-cookie (1.0.4) + domain_name (~> 0.5) + http_logger (0.6.0) + i18n (1.8.10) concurrent-ruby (~> 1.0) - ice_cube (0.14.0) + image_processing (1.12.1) + mini_magick (>= 4.9.5, < 5) + ruby-vips (>= 2.0.17, < 3) ipaddress (0.8.3) - jaro_winkler (1.5.1) - jbuilder (2.8.0) - activesupport (>= 4.2.0) - multi_json (>= 1.2) + jbuilder (2.11.2) + activesupport (>= 5.0.0) jmespath (1.4.0) - jquery-rails (4.3.3) + jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) json (1.8.6) - jwt (2.1.0) - kaminari (1.1.1) + jwt (2.2.3) + kaminari (1.2.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) - kgio (2.11.2) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - lograge (0.10.0) + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) + kgio (2.11.4) + listen (3.7.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + lograge (0.11.2) actionpack (>= 4) activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.2.3) + loofah (2.12.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) - lumberjack (1.0.13) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - meta-tags (2.11.0) - actionpack (>= 3.2.0, < 5.3) - method_source (0.9.2) - mime-types (3.2.2) + marcel (1.0.2) + meta-tags (2.16.0) + actionpack (>= 3.2.0, < 7.1) + method_source (1.0.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2018.0812) - mimemagic (0.3.3) - mini_magick (4.9.2) - mini_mime (1.0.1) - mini_portile2 (2.4.0) - minitest (5.11.3) - multi_json (1.13.1) + mime-types-data (3.2021.0901) + mini_magick (4.11.0) + mini_mime (1.1.1) + mini_portile2 (2.6.1) + minitest (5.14.4) + multi_json (1.15.0) multi_xml (0.6.0) - multipart-post (2.0.0) - mustermann (1.0.3) - nenv (0.3.0) + multipart-post (2.1.1) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) nested_form (0.3.2) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (5.1.0) - newrelic_rpm (5.6.0.349) - nio4r (2.3.1) - nokogiri (1.9.1) - mini_portile2 (~> 2.4.0) - notiffany (0.1.1) - nenv (~> 0.1) - shellany (~> 0.0) - oauth2 (1.4.1) - faraday (>= 0.8, < 0.16.0) + net-scp (3.0.0) + net-ssh (>= 2.6.5, < 7.0.0) + net-ssh (6.1.0) + netrc (0.11.0) + nio4r (2.5.8) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) + racc (~> 1.4) + oauth2 (1.4.7) + faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - octokit (4.13.0) + octokit (4.21.0) + faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) - omniauth (1.9.0) - hashie (>= 3.4.6, < 3.7.0) + omniauth (2.0.4) + hashie (>= 3.4.6) rack (>= 1.6.2, < 3) - omniauth-github (1.3.0) - omniauth (~> 1.5) - omniauth-oauth2 (>= 1.4.0, < 2.0) - omniauth-oauth2 (1.6.0) - oauth2 (~> 1.1) - omniauth (~> 1.9) + rack-protection + omniauth-github (2.0.0) + omniauth (~> 2.0) + omniauth-oauth2 (~> 1.7.1) + omniauth-oauth2 (1.7.1) + oauth2 (~> 1.4) + omniauth (>= 1.9, < 3) + omniauth-rails_csrf_protection (1.0.0) + actionpack (>= 4.2) + omniauth (~> 2.0) + optimist (3.0.1) orm_adapter (0.5.0) - paper_trail (10.1.0) - activerecord (>= 4.2, < 6.0) + paper_trail (12.1.0) + activerecord (>= 5.2) request_store (~> 1.1) - parallel (1.12.1) - paranoia (2.4.1) - activerecord (>= 4.0, < 5.3) - parser (2.5.3.0) - ast (~> 2.4.0) - pg (1.1.3) - powerpack (0.1.2) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-rails (0.3.9) - pry (>= 0.10.4) - pry-remote (0.1.8) - pry (~> 0.9) - slop (~> 3.0) - public_suffix (3.0.3) - rack (2.0.6) - rack-protection (2.0.5) + parallel (1.21.0) + paranoia (2.4.3) + activerecord (>= 4.0, < 6.2) + parser (3.0.2.0) + ast (~> 2.4.1) + pg (1.2.3) + public_suffix (4.0.6) + racc (1.5.2) + rack (2.2.3) + rack-protection (2.0.8.1) rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.2) - actioncable (= 5.2.2) - actionmailer (= 5.2.2) - actionpack (= 5.2.2) - actionview (= 5.2.2) - activejob (= 5.2.2) - activemodel (= 5.2.2) - activerecord (= 5.2.2) - activestorage (= 5.2.2) - activesupport (= 5.2.2) + rails (5.2.6) + actioncable (= 5.2.6) + actionmailer (= 5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + activemodel (= 5.2.6) + activerecord (= 5.2.6) + activestorage (= 5.2.6) + activesupport (= 5.2.6) bundler (>= 1.3.0) - railties (= 5.2.2) + railties (= 5.2.6) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) + rails-html-sanitizer (1.4.2) + loofah (~> 2.3) rails_autolink (1.1.6) rails (> 3.1) - railties (5.2.2) - actionpack (= 5.2.2) - activesupport (= 5.2.2) + rails_real_favicon (0.1.1) + json (>= 1.7, < 3) + rails + rubyzip (~> 2) + railties (5.2.6) + actionpack (= 5.2.6) + activesupport (= 5.2.6) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - raindrops (0.19.0) - rake (12.3.2) - ransack (2.1.1) - actionpack (>= 5.0) - activerecord (>= 5.0) - activesupport (>= 5.0) + raindrops (0.19.2) + rake (13.0.6) + ransack (2.4.2) + activerecord (>= 5.2.4) + activesupport (>= 5.2.4) i18n - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rb-fsevent (0.11.0) + rb-inotify (0.10.1) ffi (~> 1.0) - rbvmomi (1.13.0) + rbvmomi (2.4.1) builder (~> 3.0) json (>= 1.8) nokogiri (~> 1.5) - trollop (~> 2.1) + optimist (~> 3.0) rdoc (4.3.0) redis (3.3.5) redis-objects (1.3.1) redis (~> 3.3) - request_store (1.4.1) + regexp_parser (2.1.1) + request_store (1.5.0) rack (>= 1.4) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) - rgeo (2.0.0) - rgeo-activerecord (6.1.0) - activerecord (~> 5.0) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rexml (3.2.5) + rgeo (2.3.0) + rgeo-activerecord (6.2.2) + activerecord (>= 5.0) rgeo (>= 1.0.0) - rollbar (2.18.2) - multi_json - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) + rollbar (3.2.0) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - rubocop (0.61.1) - jaro_winkler (~> 1.5.1) + rspec-support (~> 3.10.0) + rspec-rails (5.0.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.10.2) + rubocop (1.22.0) parallel (~> 1.10) - parser (>= 2.5, != 2.5.1.1) - powerpack (~> 0.1) + parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.12.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.4.0) - ruby-progressbar (1.10.0) - ruby_dep (1.5.0) - safe_yaml (1.0.4) - sass (3.7.2) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - sassc (2.0.0) - ffi (~> 1.9.6) - rake - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.12.0) + parser (>= 3.0.1.1) + rubocop-rails (2.12.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.7.0, < 2.0) + rubocop-rspec (2.5.0) + rubocop (~> 1.19) + ruby-progressbar (1.11.0) + ruby-vips (2.1.3) + ffi (~> 1.12) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) sdoc (0.4.2) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - select2-rails (3.5.10) - thor (~> 0.14) + select2-rails (3.5.11) settingslogic (2.0.9) - shellany (0.0.1) - sidekiq (5.2.3) + sidekiq (5.2.9) connection_pool (~> 2.2, >= 2.2.2) + rack (~> 2.0) rack-protection (>= 1.5.0) - redis (>= 3.3.5, < 5) + redis (>= 3.3.5, < 4.2) sidekiq-limit_fetch (3.4.0) sidekiq (>= 4) - sidetiq (0.7.2) - celluloid (>= 0.17.3) - ice_cube (~> 0.14.0) - sidekiq (>= 4.1.0) - simple_form (4.1.0) - actionpack (>= 5.0) - activemodel (>= 5.0) - sinatra (2.0.5) + simple_form (5.1.0) + actionpack (>= 5.2) + activemodel (>= 5.2) + sinatra (2.0.8.1) mustermann (~> 1.0) rack (~> 2.0) - rack-protection (= 2.0.5) + rack-protection (= 2.0.8.1) tilt (~> 2.0) - sitemap_generator (6.0.1) + sitemap_generator (6.1.2) builder (~> 3.0) - slack-notifier (2.3.2) - slackistrano (3.8.3) + slack-notifier (2.4.0) + slackistrano (4.0.1) capistrano (>= 3.8.1) - slim (4.0.1) + slim (4.1.0) temple (>= 0.7.6, < 0.9) tilt (>= 2.0.6, < 2.1) - slop (3.6.0) - spring (2.0.2) - activesupport (>= 4.2) - sprockets (3.7.2) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.18.0) + sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - temple (0.8.0) - thor (0.20.3) + ssrf_filter (1.0.7) + temple (0.8.2) + thor (1.1.0) thread_safe (0.3.6) - tilt (2.0.9) - timecop (0.9.1) - timers (4.2.0) - trollop (2.9.9) - tzinfo (1.2.5) + tilt (2.0.10) + timecop (0.9.4) + tzinfo (1.2.9) thread_safe (~> 0.1) - uglifier (4.1.20) + uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.5) - unicode-display_width (1.4.1) - unicorn (5.4.1) + unf_ext (0.0.8) + unicode-display_width (2.1.0) + unicorn (6.0.0) kgio (~> 2.6) raindrops (~> 0.7) - warden (1.2.8) - rack (>= 2.0.6) - web-console (3.7.0) - actionview (>= 5.0) - activemodel (>= 5.0) - bindex (>= 0.4.0) - railties (>= 5.0) - webmock (3.5.1) - addressable (>= 2.3.6) + warden (1.2.9) + rack (>= 2.0.9) + webmock (3.14.0) + addressable (>= 2.8.0) crack (>= 0.3.2) - hashdiff - websocket-driver (0.7.0) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.7.0) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) - xml-simple (1.1.5) - xmlrpc (0.3.0) - xray-rails (0.3.1) - rails (>= 3.1.0) + websocket-extensions (0.1.5) + xml-simple (1.1.9) + rexml + xmlrpc (0.3.2) + webrick PLATFORMS ruby @@ -660,10 +661,7 @@ DEPENDENCIES acts_as_list annotate asset_sync - awesome_print aws-sdk-rails - better_errors - binding_of_caller bootstrap-sass byebug capistrano-rails @@ -671,38 +669,36 @@ DEPENDENCIES capistrano-sidekiq capistrano3-unicorn carrierwave - coffee-rails (~> 4.2) + coffee-rails connection_pool crummy dalli devise devise-async dotenv-rails - factory_girl_rails + factory_bot_rails fog - guard - guard-annotate http_logger jbuilder (~> 2.0) jquery-rails jquery-ui-rails kaminari + listen lograge meta-tags mini_magick nested_form - newrelic_rpm octokit omniauth omniauth-github + omniauth-oauth2 + omniauth-rails_csrf_protection paper_trail paranoia pg (~> 1.0) - pry - pry-rails - pry-remote rails (~> 5.2) rails_autolink + rails_real_favicon ransack redis (~> 3.3) redis-objects @@ -710,26 +706,25 @@ DEPENDENCIES rspec rspec-rails rubocop + rubocop-rails + rubocop-rspec sass-rails + sassc-rails sdoc (~> 0.4.0) select2-rails (~> 3) settingslogic sidekiq sidekiq-limit_fetch - sidetiq simple_form sinatra (~> 2.0.0.beta2) sitemap_generator slack-notifier slackistrano slim - spring timecop - uglifier (>= 1.3.0) + uglifier unicorn - web-console (~> 3.0) webmock - xray-rails BUNDLED WITH - 1.16.1 + 1.17.3 diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 00000000..b16e53d6 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 739aa5f0..793cec48 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -3,7 +3,6 @@ // //= require action_cable //= require_self -//= require_tree ./channels (function() { this.App || (this.App = {}); diff --git a/app/assets/stylesheets/_basics.scss b/app/assets/stylesheets/_basics.scss index 838d7013..5c51f062 100644 --- a/app/assets/stylesheets/_basics.scss +++ b/app/assets/stylesheets/_basics.scss @@ -1,8 +1,8 @@ // ----------------------- // Basics // ----------------------- -@import "basics/typography"; -@import "basics/form"; +@import "basics/_typography"; +@import "basics/_form"; body { color: #555; diff --git a/app/assets/stylesheets/_layouts.scss b/app/assets/stylesheets/_layouts.scss index 86b73872..09f27f1c 100644 --- a/app/assets/stylesheets/_layouts.scss +++ b/app/assets/stylesheets/_layouts.scss @@ -1,7 +1,8 @@ // ----------------------- // Layouts // ----------------------- -@import "layouts/header"; +@import "_variables"; +@import "layouts/_header"; .page-wrapper { margin-top: 51px; diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 8f5a49a3..8bfc6e14 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -8,9 +8,9 @@ @import "bootstrap-sprockets"; @import "bootstrap"; -@import "variables"; -@import "basics"; -@import "layouts"; +@import "_variables"; +@import "_basics"; +@import "_layouts"; // projects/edit .project_user { diff --git a/app/contexts/github/receive_callbacks_context.rb b/app/contexts/github/receive_callbacks_context.rb index 25424c0b..9bbd257d 100644 --- a/app/contexts/github/receive_callbacks_context.rb +++ b/app/contexts/github/receive_callbacks_context.rb @@ -58,22 +58,23 @@ def find_sender def find_target @target = {} - if @action_type == 'comment' + case @action_type + when 'comment' @target[:summary] = strip_body(@params[:comment][:body]) @target[:body] = @params[:comment][:body] @target[:url] = @params[:comment][:html_url] @target[:message] = "你有新的回應: #{@target[:summary]}" - elsif @action_type == 'submitted_pull_request_review' + when 'submitted_pull_request_review' @target[:summary] = strip_body(@params[:review][:body]) @target[:body] = @params[:review][:body] @target[:url] = @params[:review][:html_url] @target[:message] = "你有新的 code review: #{@target[:summary]}" - elsif @action_type == 'opened_issue' + when 'opened_issue' @target[:summary] = strip_body(@params[:issue][:title]) @target[:body] = @params[:issue][:body] @target[:url] = @params[:issue][:html_url] @target[:message] = "你在新的票被提及: #{@target[:summary]}" - elsif @action_type == 'opened_pull_request' + when 'opened_pull_request' @target[:summary] = strip_body(@params[:pull_request][:title]) @target[:body] = @params[:pull_request][:body] @target[:url] = @params[:pull_request][:html_url] @@ -93,7 +94,7 @@ def find_mentions @mentions = [] if @target[:body].present? mapping.each do |github_user, slack_user| - @mentions << slack_user if @target[:body].index('@' + github_user) + @mentions << slack_user if @target[:body].index("@#{github_user}") end end end @@ -117,10 +118,10 @@ def generate_github_slack_user_mapping def project_json_mapping mapping = begin - JSON.parse(@project.github_slack_users_mapping_json) - rescue - nil - end + JSON.parse(@project.github_slack_users_mapping_json) + rescue + nil + end return {} unless mapping.is_a?(Array) mapping.inject({}) { |a, e| a.merge(e.first => e.last) } diff --git a/app/contexts/user/get_settlement_context.rb b/app/contexts/user/get_settlement_context.rb index 16ee802c..69229935 100644 --- a/app/contexts/user/get_settlement_context.rb +++ b/app/contexts/user/get_settlement_context.rb @@ -80,7 +80,7 @@ def get_total_settelment(settlements_list) end def users_map - @users_map ||= User.where(id: each_user.keys).all.each_with_object({}) { |o, h| h[o.id] = o } + @users_map ||= User.where(id: each_user.keys).all.index_by(&:id) end def get_array_max_count_value(array) diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 05ba5e4a..0e46a9d9 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -14,7 +14,7 @@ # class Authorization < ApplicationRecord - enum provider: [:github, :google_oauth2, :facebook] + enum provider: { github: 0, google_oauth2: 1, facebook: 2 } validates :provider, :uid, :auth, presence: true validates :provider, uniqueness: { scope: :uid } diff --git a/app/models/project.rb b/app/models/project.rb index 8fb57448..db95695c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -12,7 +12,7 @@ # class Project < ApplicationRecord - belongs_to :owner, class_name: 'User', foreign_key: 'owner_id' + belongs_to :owner, class_name: 'User' has_many :project_users, dependent: :destroy accepts_nested_attributes_for :project_users has_many :users, through: :project_users, dependent: :nullify diff --git a/app/models/record.rb b/app/models/record.rb index de03ec64..c6cd0699 100644 --- a/app/models/record.rb +++ b/app/models/record.rb @@ -14,7 +14,7 @@ # class Record < ApplicationRecord - enum record_type: [:coding, :meeting, :discuss, :plan, :research, :documentation, :etc] + enum record_type: { coding: 0, meeting: 1, discuss: 2, plan: 3, research: 4, documentation: 5, etc: 6 } belongs_to :project belongs_to :user diff --git a/app/views/application/_favicon.html.slim b/app/views/application/_favicon.html.slim index 21d4653b..6387136e 100644 --- a/app/views/application/_favicon.html.slim +++ b/app/views/application/_favicon.html.slim @@ -3,11 +3,11 @@ link href=("#{asset_path "favicon/apple-touch-icon-#{size}x#{size}-precomposed.png"}") rel="apple-touch-icon-precomposed" sizes="#{size}x#{size}" / link href=("#{asset_path 'favicon/favicon-32x32.png'}") rel="icon" sizes="32x32" type="image/png" / link href=("#{asset_path 'favicon/favicon-16x16.png'}") rel="icon" sizes="16x16" type="image/png" / -link href=("#{asset_path 'favicon/manifest.json'}") rel="manifest" / +/link href=("#{asset_path 'favicon/manifest.json'}") rel="manifest" / link color="#3a2b84" href=("#{asset_path 'favicon/safari-pinned-tab.svg'}") rel="mask-icon" / link href=("#{asset_path 'favicon/favicon.ico'}") rel=("shortcut icon") / meta content="#{ENV['APP_NAME']}" name="apple-mobile-web-app-title" / meta content="#{ENV['APP_NAME']}" name="application-name" / meta content="#ffffff" name="msapplication-TileColor" / -meta content=("#{asset_path 'favicon/browserconfig.xml'}") name="msapplication-config" / +/meta content=("#{asset_path 'favicon/browserconfig.xml'}") name="msapplication-config" / meta content="#ffffff" name="theme-color" / diff --git a/app/views/devise/sessions/new.html.slim b/app/views/devise/sessions/new.html.slim index 35eca9dc..2a9d3151 100644 --- a/app/views/devise/sessions/new.html.slim +++ b/app/views/devise/sessions/new.html.slim @@ -1 +1 @@ -div = link_to "GitHub login", auth_github_path, class: "btn-primary btn-lg" +div = link_to "GitHub login", auth_github_path, class: "btn-primary btn-lg", method: :post diff --git a/app/views/layouts/_header.html.slim b/app/views/layouts/_header.html.slim index 81b33324..5f7d768c 100644 --- a/app/views/layouts/_header.html.slim +++ b/app/views/layouts/_header.html.slim @@ -20,4 +20,4 @@ nav.navbar.navbar-inverse.navbar-fixed-top - else ul.nav.navbar-nav.nvabar-right - li= link_to "GitHub login", auth_github_path + li= link_to "GitHub login", auth_github_path, method: :post diff --git a/app/workers/projects_hours_limit_check_worker.rb b/app/workers/projects_hours_limit_check_worker.rb index 22cbc171..d131ec26 100644 --- a/app/workers/projects_hours_limit_check_worker.rb +++ b/app/workers/projects_hours_limit_check_worker.rb @@ -1,11 +1,5 @@ class ProjectsHoursLimitCheckWorker include Sidekiq::Worker - include Sidetiq::Schedulable - - recurrence backfill: true do - # TODO: fix time zone - daily.hour_of_day(9) - end def perform Project.find_each do |project| diff --git a/app/workers/todos_auto_publish_worker.rb b/app/workers/todos_auto_publish_worker.rb index 65f229e4..ceccb6ed 100644 --- a/app/workers/todos_auto_publish_worker.rb +++ b/app/workers/todos_auto_publish_worker.rb @@ -1,11 +1,5 @@ class TodosAutoPublishWorker include Sidekiq::Worker - include Sidetiq::Schedulable - - recurrence backfill: true do - # TODO: fix time zone, should 23:50 - daily.hour_of_day(15).minute_of_hour(50) - end def perform User.find_each do |user| diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 1e47e89c..c3a48dec 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -1,6 +1,6 @@ set :rails_env, 'production' -servers = ['jupiter.5fpro.com'] +servers = ['52.192.164.37'] shadow_server = 'jupiter-shadow.5fpro.com' role :app, servers diff --git a/config/environments/development.rb b/config/environments/development.rb index 523d1c0b..95951f06 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -49,7 +49,7 @@ config.file_watcher = ActiveSupport::EventedFileUpdateChecker # config.action_view.raise_on_missing_translations = true - config.cache_store = :dalli_store, *(Setting.dalli.servers + [ Setting.dalli.options.symbolize_keys ]) + config.cache_store = :mem_cache_store, *(Setting.dalli.servers + [ Setting.dalli.options.symbolize_keys ]) config.action_controller.asset_host = ->(source){ Setting.assets_host } end diff --git a/config/environments/production.rb b/config/environments/production.rb index 58edaaea..f775ef2a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -47,7 +47,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - config.cache_store = :dalli_store, *(Setting.dalli.servers + [ Setting.dalli.options.symbolize_keys ]) + config.cache_store = :mem_cache_store, *(Setting.dalli.servers + [ Setting.dalli.options.symbolize_keys ]) # Enable serving of images, stylesheets, and JavaScripts from an asset server. config.action_controller.asset_host = ->(source){ "//#{Setting.assets_host}" } diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 58edaaea..f775ef2a 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -47,7 +47,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - config.cache_store = :dalli_store, *(Setting.dalli.servers + [ Setting.dalli.options.symbolize_keys ]) + config.cache_store = :mem_cache_store, *(Setting.dalli.servers + [ Setting.dalli.options.symbolize_keys ]) # Enable serving of images, stylesheets, and JavaScripts from an asset server. config.action_controller.asset_host = ->(source){ "//#{Setting.assets_host}" } diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 4322c78e..294cd7c6 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -8,3 +8,5 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. Rails.application.config.assets.precompile += %w( admin.css admin.js ) +Rails.application.config.assets.precompile += %w( application.css application.js ) +Rails.application.config.assets.precompile += Dir[Rails.root.join('app/assets/images/**/*')] diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 608baede..872c7a25 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,3 +1,6 @@ +require 'omniauth/rails_csrf_protection/token_verifier' +OmniAuth.config.request_validation_phase = ::OmniAuth::RailsCsrfProtection::TokenVerifier.new + Rails.application.config.middleware.use OmniAuth::Builder do Setting.omniauth.providers.each do |provider, data| data = data.deep_symbolize_keys diff --git a/config/initializers/paper_trail.rb b/config/initializers/paper_trail.rb index 39a66791..abb61a57 100644 --- a/config/initializers/paper_trail.rb +++ b/config/initializers/paper_trail.rb @@ -1 +1 @@ -PaperTrail.config.track_associations = false +# PaperTrail.config.track_associations = false diff --git a/config/initializers/sidetiq.rb b/config/initializers/sidetiq.rb deleted file mode 100644 index a7b6a6f3..00000000 --- a/config/initializers/sidetiq.rb +++ /dev/null @@ -1,17 +0,0 @@ -Sidetiq.configure do |config| - # Clock resolution in seconds (default: 1). - # config.resolution = 0.5 - - # Clock locking key expiration in ms (default: 1000). - # config.lock_expire = 100 - - # When `true` uses UTC instead of local times (default: false). - config.utc = true - - # Scheduling handler pool size (default: number of CPUs as - # determined by Celluloid). - # config.handler_pool_size = 5 - - # History stored for each worker (default: 50). - # config.worker_history = 50 -end diff --git a/config/routes.rb b/config/routes.rb index 0185a69c..c9fcc417 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ require 'sidekiq/web' -require 'sidetiq/web' Rails.application.routes.draw do mount Sidekiq::Web => '/sidekiq' diff --git a/db/migrate/20141117070551_enable_hstore.rb b/db/migrate/20141117070551_enable_hstore.rb index 84f6a5bd..868cf713 100644 --- a/db/migrate/20141117070551_enable_hstore.rb +++ b/db/migrate/20141117070551_enable_hstore.rb @@ -1,4 +1,4 @@ -class EnableHstore < ActiveRecord::Migration +class EnableHstore < ActiveRecord::Migration[5.2] def up execute 'CREATE EXTENSION hstore' end diff --git a/db/migrate/20141117070654_enabled_postgis.rb b/db/migrate/20141117070654_enabled_postgis.rb index a7f5f0e6..acc75d1f 100644 --- a/db/migrate/20141117070654_enabled_postgis.rb +++ b/db/migrate/20141117070654_enabled_postgis.rb @@ -1,4 +1,4 @@ -class EnabledPostgis < ActiveRecord::Migration +class EnabledPostgis < ActiveRecord::Migration[5.2] def change execute ' DROP EXTENSION IF EXISTS postgis CASCADE; diff --git a/db/migrate/20141117072407_devise_create_users.rb b/db/migrate/20141117072407_devise_create_users.rb index 97c537aa..72f701f6 100644 --- a/db/migrate/20141117072407_devise_create_users.rb +++ b/db/migrate/20141117072407_devise_create_users.rb @@ -1,4 +1,4 @@ -class DeviseCreateUsers < ActiveRecord::Migration +class DeviseCreateUsers < ActiveRecord::Migration[5.2] def change create_table(:users) do |t| ## Database authenticatable diff --git a/db/migrate/20150201093154_add_column_admin_to_user.rb b/db/migrate/20150201093154_add_column_admin_to_user.rb index 42f75c65..b6acf264 100644 --- a/db/migrate/20150201093154_add_column_admin_to_user.rb +++ b/db/migrate/20150201093154_add_column_admin_to_user.rb @@ -1,4 +1,4 @@ -class AddColumnAdminToUser < ActiveRecord::Migration +class AddColumnAdminToUser < ActiveRecord::Migration[5.2] def change add_column :users, :admin, :boolean, default: false add_index :users, :admin diff --git a/db/migrate/20150919073404_add_column_avatar_to_users.rb b/db/migrate/20150919073404_add_column_avatar_to_users.rb index 1c8bce60..0113c68b 100644 --- a/db/migrate/20150919073404_add_column_avatar_to_users.rb +++ b/db/migrate/20150919073404_add_column_avatar_to_users.rb @@ -1,4 +1,4 @@ -class AddColumnAvatarToUsers < ActiveRecord::Migration +class AddColumnAvatarToUsers < ActiveRecord::Migration[5.2] def change add_column :users, :avatar, :string end diff --git a/db/migrate/20151025154533_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/db/migrate/20151025154533_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb index 6bbd5594..b33e14f8 100644 --- a/db/migrate/20151025154533_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +++ b/db/migrate/20151025154533_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 1) -class ActsAsTaggableOnMigration < ActiveRecord::Migration +class ActsAsTaggableOnMigration < ActiveRecord::Migration[5.2] def self.up create_table :tags do |t| t.string :name @@ -20,7 +20,7 @@ def self.up t.datetime :created_at end - add_index :taggings, :tag_id + # add_index :taggings, :tag_id add_index :taggings, [:taggable_id, :taggable_type, :context] end diff --git a/db/migrate/20151025154534_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20151025154534_add_missing_unique_indices.acts_as_taggable_on_engine.rb index 4ca676f6..ecad123c 100644 --- a/db/migrate/20151025154534_add_missing_unique_indices.acts_as_taggable_on_engine.rb +++ b/db/migrate/20151025154534_add_missing_unique_indices.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 2) -class AddMissingUniqueIndices < ActiveRecord::Migration +class AddMissingUniqueIndices < ActiveRecord::Migration[5.2] def self.up add_index :tags, :name, unique: true diff --git a/db/migrate/20151025154535_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20151025154535_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb index 8edb5080..0d67426c 100644 --- a/db/migrate/20151025154535_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +++ b/db/migrate/20151025154535_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 3) -class AddTaggingsCounterCacheToTags < ActiveRecord::Migration +class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[5.2] def self.up add_column :tags, :taggings_count, :integer, default: 0 diff --git a/db/migrate/20151025154536_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/db/migrate/20151025154536_add_missing_taggable_index.acts_as_taggable_on_engine.rb index 71f2d7f4..421cfd20 100644 --- a/db/migrate/20151025154536_add_missing_taggable_index.acts_as_taggable_on_engine.rb +++ b/db/migrate/20151025154536_add_missing_taggable_index.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 4) -class AddMissingTaggableIndex < ActiveRecord::Migration +class AddMissingTaggableIndex < ActiveRecord::Migration[5.2] def self.up add_index :taggings, [:taggable_id, :taggable_type, :context] end diff --git a/db/migrate/20151025154537_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20151025154537_change_collation_for_tag_names.acts_as_taggable_on_engine.rb index bfb06bc7..ac841efe 100644 --- a/db/migrate/20151025154537_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +++ b/db/migrate/20151025154537_change_collation_for_tag_names.acts_as_taggable_on_engine.rb @@ -1,7 +1,7 @@ # This migration comes from acts_as_taggable_on_engine (originally 5) # This migration is added to circumvent issue #623 and have special characters # work properly -class ChangeCollationForTagNames < ActiveRecord::Migration +class ChangeCollationForTagNames < ActiveRecord::Migration[5.2] def up if ActsAsTaggableOn::Utils.using_mysql? execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") diff --git a/db/migrate/20151106075744_create_categories.rb b/db/migrate/20151106075744_create_categories.rb index 5681cf99..4ab8c363 100644 --- a/db/migrate/20151106075744_create_categories.rb +++ b/db/migrate/20151106075744_create_categories.rb @@ -1,4 +1,4 @@ -class CreateCategories < ActiveRecord::Migration +class CreateCategories < ActiveRecord::Migration[5.2] def change create_table :categories do |t| t.string :name diff --git a/db/migrate/20151106080220_add_column_deleted_at_to_categories.rb b/db/migrate/20151106080220_add_column_deleted_at_to_categories.rb index 659e927b..47140f69 100644 --- a/db/migrate/20151106080220_add_column_deleted_at_to_categories.rb +++ b/db/migrate/20151106080220_add_column_deleted_at_to_categories.rb @@ -1,4 +1,4 @@ -class AddColumnDeletedAtToCategories < ActiveRecord::Migration +class AddColumnDeletedAtToCategories < ActiveRecord::Migration[5.2] def change add_column :categories, :deleted_at, :datetime end diff --git a/db/migrate/20151106081428_create_versions.rb b/db/migrate/20151106081428_create_versions.rb index 3876dfc5..a744adc0 100644 --- a/db/migrate/20151106081428_create_versions.rb +++ b/db/migrate/20151106081428_create_versions.rb @@ -1,4 +1,4 @@ -class CreateVersions < ActiveRecord::Migration +class CreateVersions < ActiveRecord::Migration[5.2] # The largest text column available in all supported RDBMS is # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size diff --git a/db/migrate/20151106081429_add_object_changes_to_versions.rb b/db/migrate/20151106081429_add_object_changes_to_versions.rb index 84d0aab2..2e3aab96 100644 --- a/db/migrate/20151106081429_add_object_changes_to_versions.rb +++ b/db/migrate/20151106081429_add_object_changes_to_versions.rb @@ -1,4 +1,4 @@ -class AddObjectChangesToVersions < ActiveRecord::Migration +class AddObjectChangesToVersions < ActiveRecord::Migration[5.2] # The largest text column available in all supported RDBMS. # See `create_versions.rb` for details. diff --git a/db/migrate/20151109063212_add_column_sort_to_categories.rb b/db/migrate/20151109063212_add_column_sort_to_categories.rb index 990da299..baa821a1 100644 --- a/db/migrate/20151109063212_add_column_sort_to_categories.rb +++ b/db/migrate/20151109063212_add_column_sort_to_categories.rb @@ -1,4 +1,4 @@ -class AddColumnSortToCategories < ActiveRecord::Migration +class AddColumnSortToCategories < ActiveRecord::Migration[5.2] def change add_column :categories, :sort, :integer add_index :categories, :sort diff --git a/db/migrate/20151218091334_create_authorizations.rb b/db/migrate/20151218091334_create_authorizations.rb index bbfe63ac..21e61cd9 100644 --- a/db/migrate/20151218091334_create_authorizations.rb +++ b/db/migrate/20151218091334_create_authorizations.rb @@ -1,4 +1,4 @@ -class CreateAuthorizations < ActiveRecord::Migration +class CreateAuthorizations < ActiveRecord::Migration[5.2] def change create_table :authorizations do |t| t.integer :provider diff --git a/db/migrate/20151223075436_add_column_data_to_users.rb b/db/migrate/20151223075436_add_column_data_to_users.rb index 58713591..285edc1c 100644 --- a/db/migrate/20151223075436_add_column_data_to_users.rb +++ b/db/migrate/20151223075436_add_column_data_to_users.rb @@ -1,4 +1,4 @@ -class AddColumnDataToUsers < ActiveRecord::Migration +class AddColumnDataToUsers < ActiveRecord::Migration[5.2] def change add_column :users, :data, :hstore end diff --git a/db/migrate/20151223083152_create_projects.rb b/db/migrate/20151223083152_create_projects.rb index cca6cf33..bccc924e 100644 --- a/db/migrate/20151223083152_create_projects.rb +++ b/db/migrate/20151223083152_create_projects.rb @@ -1,4 +1,4 @@ -class CreateProjects < ActiveRecord::Migration +class CreateProjects < ActiveRecord::Migration[5.2] def change create_table :projects do |t| t.integer :price_of_hour diff --git a/db/migrate/20151223084814_create_project_users.rb b/db/migrate/20151223084814_create_project_users.rb index 458cf615..8027c138 100644 --- a/db/migrate/20151223084814_create_project_users.rb +++ b/db/migrate/20151223084814_create_project_users.rb @@ -1,4 +1,4 @@ -class CreateProjectUsers < ActiveRecord::Migration +class CreateProjectUsers < ActiveRecord::Migration[5.2] def change create_table :project_users do |t| t.integer :project_id diff --git a/db/migrate/20151223085717_create_records.rb b/db/migrate/20151223085717_create_records.rb index 7ba9eb33..d860be31 100644 --- a/db/migrate/20151223085717_create_records.rb +++ b/db/migrate/20151223085717_create_records.rb @@ -1,4 +1,4 @@ -class CreateRecords < ActiveRecord::Migration +class CreateRecords < ActiveRecord::Migration[5.2] def change create_table :records do |t| t.integer :user_id diff --git a/db/migrate/20151223090403_create_comments.rb b/db/migrate/20151223090403_create_comments.rb index b4f64611..d8abb889 100644 --- a/db/migrate/20151223090403_create_comments.rb +++ b/db/migrate/20151223090403_create_comments.rb @@ -1,4 +1,4 @@ -class CreateComments < ActiveRecord::Migration +class CreateComments < ActiveRecord::Migration[5.2] def change create_table :comments do |t| t.integer :user_id diff --git a/db/migrate/20151225070214_refactor_index_to_models.rb b/db/migrate/20151225070214_refactor_index_to_models.rb index 94856b0b..641f405e 100644 --- a/db/migrate/20151225070214_refactor_index_to_models.rb +++ b/db/migrate/20151225070214_refactor_index_to_models.rb @@ -1,4 +1,4 @@ -class RefactorIndexToModels < ActiveRecord::Migration +class RefactorIndexToModels < ActiveRecord::Migration[5.2] def change add_index :records, [:user_id, :project_id] remove_index :projects, :name diff --git a/db/migrate/20151230081125_add_data_to_projects.rb b/db/migrate/20151230081125_add_data_to_projects.rb index c8319ea6..095dfac3 100644 --- a/db/migrate/20151230081125_add_data_to_projects.rb +++ b/db/migrate/20151230081125_add_data_to_projects.rb @@ -1,4 +1,4 @@ -class AddDataToProjects < ActiveRecord::Migration +class AddDataToProjects < ActiveRecord::Migration[5.2] def change add_column :projects, :data, :hstore end diff --git a/db/migrate/20151230101922_add_data_column_to_models.rb b/db/migrate/20151230101922_add_data_column_to_models.rb index cbfe943a..a304d310 100644 --- a/db/migrate/20151230101922_add_data_column_to_models.rb +++ b/db/migrate/20151230101922_add_data_column_to_models.rb @@ -1,4 +1,4 @@ -class AddDataColumnToModels < ActiveRecord::Migration +class AddDataColumnToModels < ActiveRecord::Migration[5.2] def change add_column :comments, :data, :hstore add_column :records, :data, :hstore diff --git a/db/migrate/20160113173816_change_column_of_record_type.rb b/db/migrate/20160113173816_change_column_of_record_type.rb index 82a1053e..81371f7a 100644 --- a/db/migrate/20160113173816_change_column_of_record_type.rb +++ b/db/migrate/20160113173816_change_column_of_record_type.rb @@ -1,4 +1,4 @@ -class ChangeColumnOfRecordType < ActiveRecord::Migration +class ChangeColumnOfRecordType < ActiveRecord::Migration[5.2] def change remove_index :records, :record_type remove_column :records, :record_type diff --git a/db/migrate/20160130083518_create_slack_channels.rb b/db/migrate/20160130083518_create_slack_channels.rb index a394222f..34551f0b 100644 --- a/db/migrate/20160130083518_create_slack_channels.rb +++ b/db/migrate/20160130083518_create_slack_channels.rb @@ -1,4 +1,4 @@ -class CreateSlackChannels < ActiveRecord::Migration +class CreateSlackChannels < ActiveRecord::Migration[5.2] def change create_table :slack_channels do |t| t.integer :project_id diff --git a/db/migrate/20160202053118_add_column_sort_to_project_users.rb b/db/migrate/20160202053118_add_column_sort_to_project_users.rb index 7f5bb95a..9f014d1c 100644 --- a/db/migrate/20160202053118_add_column_sort_to_project_users.rb +++ b/db/migrate/20160202053118_add_column_sort_to_project_users.rb @@ -1,4 +1,4 @@ -class AddColumnSortToProjectUsers < ActiveRecord::Migration +class AddColumnSortToProjectUsers < ActiveRecord::Migration[5.2] def change add_column :project_users, :sort, :integer add_index :project_users, [:user_id, :sort] diff --git a/db/migrate/20160211115538_add_column_hstore_to_project_uers.rb b/db/migrate/20160211115538_add_column_hstore_to_project_uers.rb index d2bda47d..3140f9fb 100644 --- a/db/migrate/20160211115538_add_column_hstore_to_project_uers.rb +++ b/db/migrate/20160211115538_add_column_hstore_to_project_uers.rb @@ -1,4 +1,4 @@ -class AddColumnHstoreToProjectUers < ActiveRecord::Migration +class AddColumnHstoreToProjectUers < ActiveRecord::Migration[5.2] def change add_column :project_users, :data, :hstore end diff --git a/db/migrate/20160217070207_create_todos.rb b/db/migrate/20160217070207_create_todos.rb index 93ef7c99..c8b5e046 100644 --- a/db/migrate/20160217070207_create_todos.rb +++ b/db/migrate/20160217070207_create_todos.rb @@ -1,4 +1,4 @@ -class CreateTodos < ActiveRecord::Migration +class CreateTodos < ActiveRecord::Migration[5.2] def change create_table :todos do |t| t.integer :user_id diff --git a/db/migrate/20160217082804_add_column_todo_id_to_records.rb b/db/migrate/20160217082804_add_column_todo_id_to_records.rb index cfe6c7a3..2264a389 100644 --- a/db/migrate/20160217082804_add_column_todo_id_to_records.rb +++ b/db/migrate/20160217082804_add_column_todo_id_to_records.rb @@ -1,4 +1,4 @@ -class AddColumnTodoIdToRecords < ActiveRecord::Migration +class AddColumnTodoIdToRecords < ActiveRecord::Migration[5.2] def change add_column :records, :todo_id, :integer add_index :records, :todo_id diff --git a/db/migrate/20160220023636_change_column_todo_date_to_date.rb b/db/migrate/20160220023636_change_column_todo_date_to_date.rb index 21a25aca..9720853e 100644 --- a/db/migrate/20160220023636_change_column_todo_date_to_date.rb +++ b/db/migrate/20160220023636_change_column_todo_date_to_date.rb @@ -1,4 +1,4 @@ -class ChangeColumnTodoDateToDate < ActiveRecord::Migration +class ChangeColumnTodoDateToDate < ActiveRecord::Migration[5.2] def change change_column :todos, :date, :date end diff --git a/db/migrate/20160220075305_remove_column_todo_ids.rb b/db/migrate/20160220075305_remove_column_todo_ids.rb index 0cc12129..577af3d9 100644 --- a/db/migrate/20160220075305_remove_column_todo_ids.rb +++ b/db/migrate/20160220075305_remove_column_todo_ids.rb @@ -1,4 +1,4 @@ -class RemoveColumnTodoIds < ActiveRecord::Migration +class RemoveColumnTodoIds < ActiveRecord::Migration[5.2] def change remove_column :todos, :record_ids end diff --git a/db/migrate/20160229041039_add_column_done_to_todos.rb b/db/migrate/20160229041039_add_column_done_to_todos.rb index f58af37a..e3840647 100644 --- a/db/migrate/20160229041039_add_column_done_to_todos.rb +++ b/db/migrate/20160229041039_add_column_done_to_todos.rb @@ -1,4 +1,4 @@ -class AddColumnDoneToTodos < ActiveRecord::Migration +class AddColumnDoneToTodos < ActiveRecord::Migration[5.2] def change add_column :todos, :done, :boolean, default: false add_index :todos, :done diff --git a/db/migrate/20160229042422_rename_and_add_columns_for_todos.rb b/db/migrate/20160229042422_rename_and_add_columns_for_todos.rb index b606b552..b217e840 100644 --- a/db/migrate/20160229042422_rename_and_add_columns_for_todos.rb +++ b/db/migrate/20160229042422_rename_and_add_columns_for_todos.rb @@ -1,4 +1,4 @@ -class RenameAndAddColumnsForTodos < ActiveRecord::Migration +class RenameAndAddColumnsForTodos < ActiveRecord::Migration[5.2] def change remove_index :todos, :date rename_column :todos, :date, :last_recorded_on diff --git a/db/migrate/20160305071327_add_column_sort_to_todos.rb b/db/migrate/20160305071327_add_column_sort_to_todos.rb index d872e020..3463c11a 100644 --- a/db/migrate/20160305071327_add_column_sort_to_todos.rb +++ b/db/migrate/20160305071327_add_column_sort_to_todos.rb @@ -1,4 +1,4 @@ -class AddColumnSortToTodos < ActiveRecord::Migration +class AddColumnSortToTodos < ActiveRecord::Migration[5.2] def change add_column :todos, :sort, :integer add_index :todos, [:user_id, :done, :sort] diff --git a/db/migrate/20160330140816_add_column_todo_published_to_users.rb b/db/migrate/20160330140816_add_column_todo_published_to_users.rb index 652d4b0d..e8f2ce26 100644 --- a/db/migrate/20160330140816_add_column_todo_published_to_users.rb +++ b/db/migrate/20160330140816_add_column_todo_published_to_users.rb @@ -1,4 +1,4 @@ -class AddColumnTodoPublishedToUsers < ActiveRecord::Migration +class AddColumnTodoPublishedToUsers < ActiveRecord::Migration[5.2] def change add_column :users, :todos_published, :boolean, default: false add_index :users, :todos_published diff --git a/db/migrate/20160405123606_create_githubs.rb b/db/migrate/20160405123606_create_githubs.rb index 7780463e..f965ff10 100644 --- a/db/migrate/20160405123606_create_githubs.rb +++ b/db/migrate/20160405123606_create_githubs.rb @@ -1,4 +1,4 @@ -class CreateGithubs < ActiveRecord::Migration +class CreateGithubs < ActiveRecord::Migration[5.2] def change create_table :githubs do |t| t.integer :project_id diff --git a/db/migrate/20160815071713_change_column_of_todo_done_default.rb b/db/migrate/20160815071713_change_column_of_todo_done_default.rb index 9e6e5b4f..d511a4a0 100644 --- a/db/migrate/20160815071713_change_column_of_todo_done_default.rb +++ b/db/migrate/20160815071713_change_column_of_todo_done_default.rb @@ -1,4 +1,4 @@ -class ChangeColumnOfTodoDoneDefault < ActiveRecord::Migration +class ChangeColumnOfTodoDoneDefault < ActiveRecord::Migration[5.2] def up change_column :todos, :done, :boolean, default: nil end diff --git a/db/migrate/20160909054022_add_status_to_todos.rb b/db/migrate/20160909054022_add_status_to_todos.rb index c828fee9..7da9cef3 100644 --- a/db/migrate/20160909054022_add_status_to_todos.rb +++ b/db/migrate/20160909054022_add_status_to_todos.rb @@ -1,4 +1,4 @@ -class AddStatusToTodos < ActiveRecord::Migration +class AddStatusToTodos < ActiveRecord::Migration[5.2] def change add_column :todos, :status, :integer add_index :todos, :status diff --git a/db/migrate/20161110021810_remove_column_todo_done.rb b/db/migrate/20161110021810_remove_column_todo_done.rb index a92b7893..a6f6ed87 100644 --- a/db/migrate/20161110021810_remove_column_todo_done.rb +++ b/db/migrate/20161110021810_remove_column_todo_done.rb @@ -1,4 +1,4 @@ -class RemoveColumnTodoDone < ActiveRecord::Migration +class RemoveColumnTodoDone < ActiveRecord::Migration[5.2] def change remove_column :todos, :done end diff --git a/db/migrate/20170613063720_add_archived_to_project_users.rb b/db/migrate/20170613063720_add_archived_to_project_users.rb index 5ecbf131..358d767e 100644 --- a/db/migrate/20170613063720_add_archived_to_project_users.rb +++ b/db/migrate/20170613063720_add_archived_to_project_users.rb @@ -1,4 +1,4 @@ -class AddArchivedToProjectUsers < ActiveRecord::Migration +class AddArchivedToProjectUsers < ActiveRecord::Migration[5.2] def change add_column :project_users, :archived, :boolean, default: false end diff --git a/db/migrate/20170915212733_add_wage_to_project_members.rb b/db/migrate/20170915212733_add_wage_to_project_members.rb index 18fae7ff..7aa90c61 100644 --- a/db/migrate/20170915212733_add_wage_to_project_members.rb +++ b/db/migrate/20170915212733_add_wage_to_project_members.rb @@ -1,4 +1,4 @@ -class AddWageToProjectMembers < ActiveRecord::Migration +class AddWageToProjectMembers < ActiveRecord::Migration[5.2] def change add_column :project_users, :wage, :integer end diff --git a/db/migrate/20170916185816_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb b/db/migrate/20170916185816_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb index 94e1f2e4..3d103a2e 100644 --- a/db/migrate/20170916185816_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb +++ b/db/migrate/20170916185816_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb @@ -1,10 +1,4 @@ -# This migration comes from acts_as_taggable_on_engine (originally 6) -if ActiveRecord.gem_version >= Gem::Version.new('5.0') - class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end -else - class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end -end -AddMissingIndexesOnTaggings.class_eval do +class AddMissingIndexesOnTaggings < ActiveRecord::Migration[5.2] def change add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id diff --git a/db/schema.rb b/db/schema.rb index 61c27291..998afb55 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -11,203 +10,192 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170916185816) do +ActiveRecord::Schema.define(version: 2017_09_16_185816) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" enable_extension "hstore" + enable_extension "plpgsql" enable_extension "postgis" create_table "authorizations", force: :cascade do |t| - t.integer "provider" - t.string "uid" - t.string "auth_type" - t.integer "auth_id" - t.text "auth_data" - t.hstore "data" + t.integer "provider" + t.string "uid" + t.string "auth_type" + t.integer "auth_id" + t.text "auth_data" + t.hstore "data" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["auth_type", "auth_id", "provider"], name: "index_authorizations_on_auth_type_and_auth_id_and_provider" + t.index ["auth_type", "auth_id"], name: "index_authorizations_on_auth_type_and_auth_id" + t.index ["provider", "uid"], name: "index_authorizations_on_provider_and_uid" end - add_index "authorizations", ["auth_type", "auth_id", "provider"], name: "index_authorizations_on_auth_type_and_auth_id_and_provider", using: :btree - add_index "authorizations", ["auth_type", "auth_id"], name: "index_authorizations_on_auth_type_and_auth_id", using: :btree - add_index "authorizations", ["provider", "uid"], name: "index_authorizations_on_provider_and_uid", using: :btree - create_table "categories", force: :cascade do |t| - t.string "name" + t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.datetime "deleted_at" - t.integer "sort" + t.integer "sort" + t.index ["name"], name: "index_categories_on_name" + t.index ["sort"], name: "index_categories_on_sort" end - add_index "categories", ["name"], name: "index_categories_on_name", using: :btree - add_index "categories", ["sort"], name: "index_categories_on_sort", using: :btree - create_table "comments", force: :cascade do |t| - t.integer "user_id" - t.integer "item_id" - t.string "item_type" + t.integer "user_id" + t.integer "item_id" + t.string "item_type" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.hstore "data" + t.hstore "data" + t.index ["item_id", "item_type"], name: "index_comments_on_item_id_and_item_type" + t.index ["user_id"], name: "index_comments_on_user_id" end - add_index "comments", ["item_id", "item_type"], name: "index_comments_on_item_id_and_item_type", using: :btree - add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree - create_table "githubs", force: :cascade do |t| - t.integer "project_id" - t.string "webhook_token" - t.hstore "data" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "project_id" + t.string "webhook_token" + t.hstore "data" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["webhook_token"], name: "index_githubs_on_webhook_token" end - add_index "githubs", ["webhook_token"], name: "index_githubs_on_webhook_token", using: :btree - create_table "project_users", force: :cascade do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "sort" - t.hstore "data" - t.boolean "archived", default: false - t.integer "wage" + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "sort" + t.hstore "data" + t.boolean "archived", default: false + t.integer "wage" + t.index ["project_id", "user_id"], name: "index_project_users_on_project_id_and_user_id" + t.index ["project_id"], name: "index_project_users_on_project_id" + t.index ["user_id", "sort"], name: "index_project_users_on_user_id_and_sort" + t.index ["user_id"], name: "index_project_users_on_user_id" end - add_index "project_users", ["project_id", "user_id"], name: "index_project_users_on_project_id_and_user_id", using: :btree - add_index "project_users", ["project_id"], name: "index_project_users_on_project_id", using: :btree - add_index "project_users", ["user_id", "sort"], name: "index_project_users_on_user_id_and_sort", using: :btree - add_index "project_users", ["user_id"], name: "index_project_users_on_user_id", using: :btree - create_table "projects", force: :cascade do |t| - t.integer "price_of_hour" - t.string "name" - t.integer "owner_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.hstore "data" + t.integer "price_of_hour" + t.string "name" + t.integer "owner_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.hstore "data" + t.index ["owner_id"], name: "index_projects_on_owner_id" end - add_index "projects", ["owner_id"], name: "index_projects_on_owner_id", using: :btree - create_table "records", force: :cascade do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "minutes" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.hstore "data" - t.integer "record_type" - t.integer "todo_id" + t.integer "user_id" + t.integer "project_id" + t.integer "minutes" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.hstore "data" + t.integer "record_type" + t.integer "todo_id" + t.index ["project_id", "record_type"], name: "index_records_on_project_id_and_record_type" + t.index ["project_id"], name: "index_records_on_project_id" + t.index ["todo_id"], name: "index_records_on_todo_id" + t.index ["user_id", "project_id"], name: "index_records_on_user_id_and_project_id" + t.index ["user_id"], name: "index_records_on_user_id" end - add_index "records", ["project_id", "record_type"], name: "index_records_on_project_id_and_record_type", using: :btree - add_index "records", ["project_id"], name: "index_records_on_project_id", using: :btree - add_index "records", ["todo_id"], name: "index_records_on_todo_id", using: :btree - add_index "records", ["user_id", "project_id"], name: "index_records_on_user_id_and_project_id", using: :btree - add_index "records", ["user_id"], name: "index_records_on_user_id", using: :btree - create_table "slack_channels", force: :cascade do |t| - t.integer "project_id" - t.boolean "disabled", default: false - t.hstore "data" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "project_id" + t.boolean "disabled", default: false + t.hstore "data" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["project_id"], name: "index_slack_channels_on_project_id" end - add_index "slack_channels", ["project_id"], name: "index_slack_channels_on_project_id", using: :btree - create_table "taggings", force: :cascade do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", limit: 128 + t.bigint "tag_id" + t.string "taggable_type" + t.bigint "taggable_id" + t.string "tagger_type" + t.bigint "tagger_id" + t.string "context", limit: 128 t.datetime "created_at" + t.index ["context"], name: "index_taggings_on_context" + t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true + t.index ["tag_id"], name: "index_taggings_on_tag_id" + t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" + t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy" + t.index ["taggable_id"], name: "index_taggings_on_taggable_id" + t.index ["taggable_type", "taggable_id"], name: "index_taggings_on_taggable_type_and_taggable_id" + t.index ["taggable_type"], name: "index_taggings_on_taggable_type" + t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type" + t.index ["tagger_id"], name: "index_taggings_on_tagger_id" + t.index ["tagger_type", "tagger_id"], name: "index_taggings_on_tagger_type_and_tagger_id" end - add_index "taggings", ["context"], name: "index_taggings_on_context", using: :btree - add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree - add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree - add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - add_index "taggings", ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy", using: :btree - add_index "taggings", ["taggable_id"], name: "index_taggings_on_taggable_id", using: :btree - add_index "taggings", ["taggable_type"], name: "index_taggings_on_taggable_type", using: :btree - add_index "taggings", ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type", using: :btree - add_index "taggings", ["tagger_id"], name: "index_taggings_on_tagger_id", using: :btree - create_table "tags", force: :cascade do |t| - t.string "name" + t.string "name" t.integer "taggings_count", default: 0 + t.index ["name"], name: "index_tags_on_name", unique: true end - add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree - create_table "todos", force: :cascade do |t| - t.integer "user_id" - t.integer "project_id" - t.text "desc" - t.date "last_recorded_on" - t.hstore "data" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "user_id" + t.integer "project_id" + t.text "desc" + t.date "last_recorded_on" + t.hstore "data" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.datetime "last_recorded_at" - t.integer "sort" - t.integer "status" + t.integer "sort" + t.integer "status" + t.index ["last_recorded_on"], name: "index_todos_on_last_recorded_on" + t.index ["project_id", "last_recorded_on"], name: "index_todos_on_project_id_and_last_recorded_on" + t.index ["project_id"], name: "index_todos_on_project_id" + t.index ["status"], name: "index_todos_on_status" + t.index ["user_id", "last_recorded_on"], name: "index_todos_on_user_id_and_last_recorded_on" + t.index ["user_id", "project_id"], name: "index_todos_on_user_id_and_project_id" + t.index ["user_id"], name: "index_todos_on_user_id" end - add_index "todos", ["last_recorded_on"], name: "index_todos_on_last_recorded_on", using: :btree - add_index "todos", ["project_id", "last_recorded_on"], name: "index_todos_on_project_id_and_last_recorded_on", using: :btree - add_index "todos", ["project_id"], name: "index_todos_on_project_id", using: :btree - add_index "todos", ["status"], name: "index_todos_on_status", using: :btree - add_index "todos", ["user_id", "last_recorded_on"], name: "index_todos_on_user_id_and_last_recorded_on", using: :btree - add_index "todos", ["user_id", "project_id"], name: "index_todos_on_user_id_and_project_id", using: :btree - add_index "todos", ["user_id"], name: "index_todos_on_user_id", using: :btree - create_table "users", force: :cascade do |t| - t.string "name" - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" + t.string "name" + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.datetime "created_at" - t.datetime "updated_at" - t.boolean "admin", default: false - t.string "avatar" - t.hstore "data" - t.boolean "todos_published", default: false + t.string "unconfirmed_email" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "admin", default: false + t.string "avatar" + t.hstore "data" + t.boolean "todos_published", default: false + t.index ["admin"], name: "index_users_on_admin" + t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + t.index ["todos_published"], name: "index_users_on_todos_published" end - add_index "users", ["admin"], name: "index_users_on_admin", using: :btree - add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree - add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree - add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree - add_index "users", ["todos_published"], name: "index_users_on_todos_published", using: :btree - create_table "versions", force: :cascade do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false - t.string "whodunnit" - t.text "object" + t.string "item_type", null: false + t.integer "item_id", null: false + t.string "event", null: false + t.string "whodunnit" + t.text "object" t.datetime "created_at" - t.text "object_changes" + t.text "object_changes" + t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" end - add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree - end diff --git a/lib/capistrano/deploy_messaging.rb b/lib/capistrano/deploy_messaging.rb index 8819b290..1b175d6c 100644 --- a/lib/capistrano/deploy_messaging.rb +++ b/lib/capistrano/deploy_messaging.rb @@ -1,7 +1,4 @@ class Capistrano::DeployMessaging < Slackistrano::Messaging::Base - def channels_for(action) - super - end def payload_for_updating create_payload( diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index 29f03dfc..dd47173f 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -2,7 +2,7 @@ # NOTE: are sensitive to local FS writes, and besides -- it's just not proper # NOTE: to have a dev-mode tool do its thing in production. if Rails.env.development? - task :set_annotation_options do + task set_annotation_options: :environment do # You can override any of these by setting an environment variable of the # same name. Annotate.set_defaults( diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 53dc7d6f..4f2f243f 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -9,7 +9,7 @@ namespace :dev do desc 'generate fake data for development' task fake: :environment do email = 'admin@5fpro.com' - User.find_by(email: email) || FactoryGirl.create(:user, email: email, password: '12341234', admin: true) + User.find_by(email: email) || FactoryBot.create(:user, email: email, password: '12341234', admin: true) end end diff --git a/spec/contexts/common/project_add_user_context_spec.rb b/spec/contexts/common/project_add_user_context_spec.rb index c840e979..3aca13f9 100644 --- a/spec/contexts/common/project_add_user_context_spec.rb +++ b/spec/contexts/common/project_add_user_context_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' describe Common::ProjectAddUserContext do - let(:user) { FactoryGirl.create :user } - let(:project) { FactoryGirl.create :project } - subject { described_class.new(project, user).perform } + let(:user) { FactoryBot.create :user } + let(:project) { FactoryBot.create :project } + it 'success' do expect { subject @@ -18,7 +18,7 @@ }.to change { project.reload.users_count }.by(1) end - context '#validates_user_not_in_project!' do + describe '#validates_user_not_in_project!' do before { subject } it 'users_count' do @@ -26,6 +26,7 @@ described_class.new(project, user).perform }.not_to change { project.reload.users_count } end + it 'project_users.count' do expect { described_class.new(project, user).perform diff --git a/spec/contexts/notify/generate_message_context_spec.rb b/spec/contexts/notify/generate_message_context_spec.rb index 786d40e6..a4d2913b 100644 --- a/spec/contexts/notify/generate_message_context_spec.rb +++ b/spec/contexts/notify/generate_message_context_spec.rb @@ -2,9 +2,10 @@ describe Notify::GenerateMessageContext do context 'event = record_created' do - let(:record) { FactoryGirl.create :record } subject { described_class.new(:record_created, record: record) } + let(:record) { FactoryBot.create :record } + it { expect(subject.perform).to be_present } it { expect(subject.perform).not_to match('translation missing') } end diff --git a/spec/contexts/notify/send_to_slack_context_spec.rb b/spec/contexts/notify/send_to_slack_context_spec.rb index bcce14e4..efe8852a 100644 --- a/spec/contexts/notify/send_to_slack_context_spec.rb +++ b/spec/contexts/notify/send_to_slack_context_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' describe Notify::SendToSlackContext do - let(:slack_channel) { FactoryGirl.create :slack_channel } - subject { described_class.new('haha', slack_channel) } + let(:slack_channel) { FactoryBot.create :slack_channel } + it do expect { subject.perform @@ -18,9 +18,10 @@ end context 'webhook null' do - let(:slack_channel) { FactoryGirl.create :slack_channel, webhook: nil } + let(:slack_channel) { FactoryBot.create :slack_channel, webhook: nil } it { expect(subject.perform).to eq false } + it do expect { subject.perform @@ -29,9 +30,10 @@ end context 'room null' do - let(:slack_channel) { FactoryGirl.create :slack_channel, room: nil } + let(:slack_channel) { FactoryBot.create :slack_channel, room: nil } it { expect(subject.perform).to eq false } + it do expect { subject.perform diff --git a/spec/contexts/notify/send_to_user_context_spec.rb b/spec/contexts/notify/send_to_user_context_spec.rb index 70acd9ad..019ee704 100644 --- a/spec/contexts/notify/send_to_user_context_spec.rb +++ b/spec/contexts/notify/send_to_user_context_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' describe Notify::SendToUserContext do - let!(:project) { FactoryGirl.create :project_for_slack_notify } - let!(:user) { project.owner } - subject { described_class.new(project, user, 'haha') } + let!(:project) { FactoryBot.create :project_for_slack_notify } + let!(:user) { project.owner } + it do expect { subject.perform @@ -23,7 +23,7 @@ end context 'user not in project' do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } it do expect { diff --git a/spec/contexts/notify/trigger_context_spec.rb b/spec/contexts/notify/trigger_context_spec.rb index 404e940a..1caf88e7 100644 --- a/spec/contexts/notify/trigger_context_spec.rb +++ b/spec/contexts/notify/trigger_context_spec.rb @@ -1,14 +1,15 @@ require 'rails_helper' describe Notify::TriggerContext do - let!(:project) { FactoryGirl.create :project_has_records } + subject { described_class.new(project, :record_created) } + + let!(:project) { FactoryBot.create :project_has_records } let!(:user) { project.owner } let!(:record) { project.records.last } - subject { described_class.new(project, :record_created) } - context 'one slack channel' do - before { FactoryGirl.create :slack_channel, :record_created, project: project } + before { FactoryBot.create :slack_channel, :record_created, project: project } + before { project.reload } it do @@ -18,7 +19,8 @@ end context 'two slack channel' do - before { FactoryGirl.create :slack_channel, :record_created, project: project } + before { FactoryBot.create :slack_channel, :record_created, project: project } + before { project.reload } it do @@ -29,7 +31,8 @@ end context 'slack channel without events' do - before { FactoryGirl.create :slack_channel, project: project, events: [''] } + before { FactoryBot.create :slack_channel, project: project, events: [''] } + before { project.reload } it do diff --git a/spec/contexts/project/hours_limit_check_context_spec.rb b/spec/contexts/project/hours_limit_check_context_spec.rb index daa55507..01e498f3 100644 --- a/spec/contexts/project/hours_limit_check_context_spec.rb +++ b/spec/contexts/project/hours_limit_check_context_spec.rb @@ -1,17 +1,19 @@ require 'rails_helper' describe Project::HoursLimitCheckContext, type: :context do - let!(:project) { FactoryGirl.create :project, :with_project_user } subject { described_class.new(project) } + let!(:project) { FactoryBot.create :project, :with_project_user } + context 'success' do before { project.update_attribute :hours_limit, 1 } - let!(:record) { FactoryGirl.create :record, project: project, minutes: 100 } + + let!(:record) { FactoryBot.create :record, project: project, minutes: 100 } it { expect { subject.perform }.to change { project.reload.approached_hours_limit }.to(true) } context 'slack notify' do - before { FactoryGirl.create :slack_channel, :approach_hours_limit, project: project } + before { FactoryBot.create :slack_channel, :approach_hours_limit, project: project } it do expect { @@ -38,7 +40,8 @@ context 'not approach' do before { project.update_attribute :hours_limit, 1 } - let!(:record) { FactoryGirl.create :record, project: project, minutes: 30 } + + let!(:record) { FactoryBot.create :record, project: project, minutes: 30 } it { expect(subject.perform).to eq false } it { expect { subject.perform }.not_to change { project.reload.approached_hours_limit } } diff --git a/spec/contexts/project/update_project_users_context_spec.rb b/spec/contexts/project/update_project_users_context_spec.rb index 1c27e968..dddcaa62 100644 --- a/spec/contexts/project/update_project_users_context_spec.rb +++ b/spec/contexts/project/update_project_users_context_spec.rb @@ -1,16 +1,17 @@ require 'rails_helper' describe Project::UpdateProjectUsersContext, type: :context do - let!(:project) { FactoryGirl.create :project, :with_project_user } + subject { described_class.new(project, params) } + + let!(:project) { FactoryBot.create :project, :with_project_user } let!(:project_user) { project.project_users.last } let(:params) { attributes_for(:project_for_update, :project_users) } - subject { described_class.new(project, params) } - it { expect { subject.perform }.to change { project_user.reload.slack_user } } context 'fail' do before { project.update_column :name, '' } + it { expect { subject.perform }.not_to change { project_user.reload.slack_user } } end end diff --git a/spec/contexts/project_delete_context_spec.rb b/spec/contexts/project_delete_context_spec.rb index ce92dedf..4aeb483b 100644 --- a/spec/contexts/project_delete_context_spec.rb +++ b/spec/contexts/project_delete_context_spec.rb @@ -1,24 +1,29 @@ require 'rails_helper' describe ProjectDeleteContext do - let(:user) { FactoryGirl.create :user } - let!(:project) { FactoryGirl.create :project_has_members, owner: user } + let(:user) { FactoryBot.create :user } + let!(:project) { FactoryBot.create :project_has_members, owner: user } describe '#perform' do context 'success' do subject { described_class.new(user, project) } + it { expect { subject.perform }.to change { user.projects.count }.by(-1) } end context 'not owner' do - let(:user1) { FactoryGirl.create :user } subject { described_class.new(user1, project) } + + let(:user1) { FactoryBot.create :user } + it { expect { subject.perform }.not_to change { project.records.count } } end context 'has todo' do - let(:project_has_todos) { FactoryGirl.create :project_has_todos, owner: user } subject { described_class.new(user, project_has_todos) } + + let(:project_has_todos) { FactoryBot.create :project_has_todos, owner: user } + it { expect { subject.perform }.not_to change { project.records.count } } end diff --git a/spec/contexts/project_invite_context_spec.rb b/spec/contexts/project_invite_context_spec.rb index 20693070..59580eaa 100644 --- a/spec/contexts/project_invite_context_spec.rb +++ b/spec/contexts/project_invite_context_spec.rb @@ -1,18 +1,19 @@ require 'rails_helper' describe ProjectInviteContext do - let(:me) { FactoryGirl.create :user } - let(:user) { FactoryGirl.create :user } - let(:project) { FactoryGirl.create :project, :with_project_user, owner: me } - subject { described_class.new(me, user.email, project).perform } + let(:me) { FactoryBot.create :user } + let(:user) { FactoryBot.create :user } + let(:project) { FactoryBot.create :project, :with_project_user, owner: me } + context 'success' do it 'project has user' do expect { subject }.to change { project.reload.has_user?(user) }.to(true) end + it 'project.users.count' do expect { subject @@ -36,9 +37,10 @@ end describe 'validates_user_in_project!' do - before { described_class.new(me, user.email, project).perform } subject { described_class.new(me, user.email, project).perform } + before { described_class.new(me, user.email, project).perform } + it { expect(subject).to be_falsey } end end diff --git a/spec/contexts/project_remove_user_context_spec.rb b/spec/contexts/project_remove_user_context_spec.rb index ed75240d..1f9694d8 100644 --- a/spec/contexts/project_remove_user_context_spec.rb +++ b/spec/contexts/project_remove_user_context_spec.rb @@ -1,18 +1,19 @@ require 'rails_helper' describe ProjectRemoveUserContext do - let(:owner) { FactoryGirl.create :user } - let!(:project) { FactoryGirl.create :project_has_members, owner: owner } - let(:user) { project.users.find { |u| u.id != owner.id } } - subject { described_class.new(owner, user, project) } + let(:owner) { FactoryBot.create :user } + let!(:project) { FactoryBot.create :project_has_members, owner: owner } + let(:user) { project.users.find { |u| u.id != owner.id } } + context 'success' do it 'project not has user' do expect { subject.perform }.to change { project.reload.has_user?(user) }.to(false) end + it '#update_users_count' do expect { subject.perform @@ -21,7 +22,7 @@ end it '#validates_owner!' do - project.update_attribute :owner, FactoryGirl.create(:user) + project.update_attribute :owner, FactoryBot.create(:user) expect { @result = subject.perform }.not_to change { project.reload.users_count } diff --git a/spec/contexts/project_update_context_spec.rb b/spec/contexts/project_update_context_spec.rb index 7a566bbd..e1135b7d 100644 --- a/spec/contexts/project_update_context_spec.rb +++ b/spec/contexts/project_update_context_spec.rb @@ -1,11 +1,13 @@ require 'rails_helper' describe ProjectUpdateContext do - let(:user) { FactoryGirl.create :user } - let(:user1) { FactoryGirl.create :user } - let(:data) { attributes_for(:project_for_update, :setting) } - let!(:project) { FactoryGirl.create :project, :with_project_user, owner: user } subject { described_class.new(user, project).perform(data) } + + let(:user) { FactoryBot.create :user } + let(:user1) { FactoryBot.create :user } + let(:data) { attributes_for(:project_for_update, :setting) } + let!(:project) { FactoryBot.create :project, :with_project_user, owner: user } + context 'success' do it { expect(subject.name).to eq(data[:name]) } it { expect(subject.price_of_hour).to eq(data[:price_of_hour]) } @@ -15,9 +17,10 @@ context 'not owner' do subject { described_class.new(user1, project).perform(data) } - it { expect { subject }.not_to change { project.name } } - it { expect { subject }.not_to change { project.price_of_hour } } - it { expect { subject }.not_to change { project.hours_limit } } - it { expect { subject }.not_to change { project.description } } + + it { expect { subject }.not_to change(project, :name) } + it { expect { subject }.not_to change(project, :price_of_hour) } + it { expect { subject }.not_to change(project, :hours_limit) } + it { expect { subject }.not_to change(project, :description) } end end diff --git a/spec/contexts/record_create_context_spec.rb b/spec/contexts/record_create_context_spec.rb index 8729b64f..95f97968 100644 --- a/spec/contexts/record_create_context_spec.rb +++ b/spec/contexts/record_create_context_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe RecordCreateContext do - let(:project) { FactoryGirl.create :project, :with_project_user } + subject { described_class.new(user, project) } + + let(:project) { FactoryBot.create :project, :with_project_user } let(:user) { project.owner } let(:data) { attributes_for(:record_for_params) } - subject { described_class.new(user, project) } - it 'success' do expect { subject.perform(data) @@ -17,18 +17,20 @@ end describe '#validates_user_in_project!' do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } + it { expect { subject.perform(data) }.not_to change { project.records.count } } it { expect(subject.perform(data)).to eq false } end context 'model validates fail' do let(:params) { data.merge(minutes: nil) } + it { expect { subject.perform(data.merge(minutes: nil)) }.not_to change { project.records.count } } end describe '#notify_slack_channels' do - before { FactoryGirl.create :slack_channel, :record_created, project: project } + before { FactoryBot.create :slack_channel, :record_created, project: project } it do expect { @@ -56,8 +58,10 @@ describe '#create_todo_if_not_choose' do it { expect { subject.perform(data.merge(todo_id: '')) }.to change { user.todos.count } } + context 'new todo should be done if checked' do before { subject.perform(data.merge(todo_id: '', todo_finished: 'yes')) } + it { expect(user.reload.todos.last.finished?).to eq true } end end diff --git a/spec/contexts/record_delete_context_spec.rb b/spec/contexts/record_delete_context_spec.rb index b9a1e6b8..bea14bc0 100644 --- a/spec/contexts/record_delete_context_spec.rb +++ b/spec/contexts/record_delete_context_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' describe RecordDeleteContext do - let(:user) { FactoryGirl.create :user } - let(:user1) { FactoryGirl.create :user } - let!(:project) { FactoryGirl.create :project_has_records, owner: user } - let(:record) { project.records.last } - subject { described_class.new(user, record) } + let(:user) { FactoryBot.create :user } + let(:user1) { FactoryBot.create :user } + let!(:project) { FactoryBot.create :project_has_records, owner: user } + let(:record) { project.records.last } + it 'success' do expect { subject.perform @@ -21,8 +21,10 @@ end describe '#calculate_todo' do - let!(:todo) { FactoryGirl.create :todo, :finished, total_time: 123, project: project } + let!(:todo) { FactoryBot.create :todo, :finished, total_time: 123, project: project } + before { record.update_attribute :todo, todo } + it { expect { subject.perform }.to change { todo.reload.total_time }.to(0) } it { expect { subject.perform }.to change { todo.reload.doing? }.to(true) } it { expect { subject.perform }.to change { todo.reload.last_recorded_on }.to(nil) } diff --git a/spec/contexts/record_update_context_spec.rb b/spec/contexts/record_update_context_spec.rb index d88c94dd..df1d438a 100644 --- a/spec/contexts/record_update_context_spec.rb +++ b/spec/contexts/record_update_context_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe RecordUpdateContext do - let(:record) { FactoryGirl.create(:record) } + subject { described_class.new(user, record) } + + let(:record) { FactoryBot.create(:record) } let(:user) { record.user } let(:params) { attributes_for(:record_for_params) } - subject { described_class.new(user, record) } - it 'success' do expect { subject.perform(params) @@ -14,10 +14,10 @@ end context 'not owner' do - let(:user1) { FactoryGirl.create :user } - subject { described_class.new(user1, record) } + let(:user1) { FactoryBot.create :user } + it do expect { subject.perform(params) @@ -26,10 +26,11 @@ end describe '#calculate_todo' do - let!(:record) { FactoryGirl.create(:record, :with_todo) } + subject { described_class.new(user, record).perform(params) } + + let!(:record) { FactoryBot.create(:record, :with_todo) } let(:params) { attributes_for(:record_for_params) } let(:todo) { Todo.last } - subject { described_class.new(user, record).perform(params) } it { expect { subject }.to change { todo.reload.total_time } } end diff --git a/spec/contexts/slack_channel_create_context_spec.rb b/spec/contexts/slack_channel_create_context_spec.rb index 740ddd7d..270e9492 100644 --- a/spec/contexts/slack_channel_create_context_spec.rb +++ b/spec/contexts/slack_channel_create_context_spec.rb @@ -1,14 +1,15 @@ require 'rails_helper' describe SlackChannelCreateContext do - let(:project) { FactoryGirl.create :project } + subject { described_class.new(user, project) } + + let(:project) { FactoryBot.create :project } let(:user) { project.owner } let(:params) { attributes_for(:slack_channel_for_create) } - subject { described_class.new(user, project) } - context 'success' do it { expect { subject.perform(params) }.to change { project.slack_channels.count }.by(1) } + it do slack_channel = subject.perform(params) expect(slack_channel.name).to eq params[:name] @@ -16,9 +17,10 @@ end context 'user is not owner' do - let(:user) { FactoryGirl.create :user } subject { described_class.new(user, project) } + let(:user) { FactoryBot.create :user } + it { expect { subject.perform(params) }.not_to change { project.slack_channels.count } } end end diff --git a/spec/contexts/slack_channel_delete_context_spec.rb b/spec/contexts/slack_channel_delete_context_spec.rb index ebfb6768..583af779 100644 --- a/spec/contexts/slack_channel_delete_context_spec.rb +++ b/spec/contexts/slack_channel_delete_context_spec.rb @@ -2,18 +2,19 @@ describe SlackChannelDeleteContext do - let!(:project) { FactoryGirl.create :project_has_members } - let!(:slack_channel) { FactoryGirl.create :slack_channel, project: project } - let(:user) { project.owner } - subject { described_class.new(user, slack_channel) } + let!(:project) { FactoryBot.create :project_has_members } + let!(:slack_channel) { FactoryBot.create :slack_channel, project: project } + let(:user) { project.owner } + it { expect { subject.perform }.to change { project.slack_channels.count }.by(-1) } context 'not owner' do - let(:user2) { project.users.last } subject { described_class.new(user2, slack_channel) } + let(:user2) { project.users.last } + it { expect { subject.perform }.not_to change { project.slack_channels.count } } end end diff --git a/spec/contexts/slack_channel_update_context_spec.rb b/spec/contexts/slack_channel_update_context_spec.rb index 07d3a2f2..02e8fa12 100644 --- a/spec/contexts/slack_channel_update_context_spec.rb +++ b/spec/contexts/slack_channel_update_context_spec.rb @@ -1,34 +1,38 @@ require 'rails_helper' describe SlackChannelUpdateContext do - let(:slack_channel) { FactoryGirl.create :slack_channel } + subject { described_class.new(user, slack_channel) } + + let(:slack_channel) { FactoryBot.create :slack_channel } let(:user) { slack_channel.project.owner } let(:params) { attributes_for(:slack_channel_for_update) } - subject { described_class.new(user, slack_channel) } - it { expect { subject.perform(params) }.to change { slack_channel.reload.name }.to(params[:name]) } context 'user is not owner' do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } it { expect { subject.perform(params) }.not_to change { slack_channel.reload.name } } end context 'update :events' do let(:params) { { events: ['', 'record_created'] } } + it { expect { subject.perform(params) }.to change { slack_channel.reload.events }.to(['record_created']) } end context 'update primary' do context 'from false to true' do let(:params) { { primary: '1' } } + before { slack_channel.project.update_attribute :primary_slack_channel_id, '' } it { expect { subject.perform(params) }.to change { slack_channel.reload.primary? }.from(false).to(true) } end + context 'from true to false' do let(:params) { { primary: '0' } } + before { slack_channel.project.update_attribute :primary_slack_channel_id, slack_channel.id } it { expect { subject.perform(params) }.to change { slack_channel.reload.primary? }.from(true).to(false) } diff --git a/spec/contexts/todo_calculate_context_spec.rb b/spec/contexts/todo_calculate_context_spec.rb index a706b220..cc8cbf5b 100644 --- a/spec/contexts/todo_calculate_context_spec.rb +++ b/spec/contexts/todo_calculate_context_spec.rb @@ -1,14 +1,17 @@ require 'rails_helper' describe TodoCalculateContext do - let!(:todo) { FactoryGirl.create :todo, :with_not_calculate_record } subject { described_class.new(todo) } + let!(:todo) { FactoryBot.create :todo, :with_not_calculate_record } + it { expect { subject.perform }.to change { todo.reload.total_time } } context 'reduce record' do before { subject.perform } + before { todo.records.last.destroy } + it { expect { subject.perform }.to change { todo.reload.total_time } } end @@ -19,7 +22,8 @@ describe '#change_status' do context 'not set' do - let!(:todo) { FactoryGirl.create :todo, :with_records, :doing } + let!(:todo) { FactoryBot.create :todo, :with_records, :doing } + it { expect { subject.perform }.not_to change { todo.reload.status } } end @@ -28,17 +32,20 @@ end context 'to_doing' do - let!(:todo) { FactoryGirl.create :todo, :with_records, :finished } + let!(:todo) { FactoryBot.create :todo, :with_records, :finished } + it { expect { subject.perform(status: 'doing') }.to change { todo.reload.doing? }.to(true) } end context 'to_pending' do - let!(:todo) { FactoryGirl.create :todo, :with_records, :doing } + let!(:todo) { FactoryBot.create :todo, :with_records, :doing } + it { expect { subject.perform(status: 'pending') }.to change { todo.reload.pending? }.to(true) } end context 'to_finished but not reocrds' do - let(:todo) { FactoryGirl.create :todo } + let(:todo) { FactoryBot.create :todo } + it { expect { subject.perform(status: 'finished') }.not_to change { todo.reload.status } } end end diff --git a/spec/contexts/todo_change_status_context_spec.rb b/spec/contexts/todo_change_status_context_spec.rb index 9f9fc238..2459e713 100644 --- a/spec/contexts/todo_change_status_context_spec.rb +++ b/spec/contexts/todo_change_status_context_spec.rb @@ -4,67 +4,77 @@ subject { described_class.new(todo, status) } context 'to finished' do - let(:todo) { FactoryGirl.create :todo, :with_records, :doing } + let(:todo) { FactoryBot.create :todo, :with_records, :doing } let(:status) { 'finished' } + it { expect { subject.perform }.to change { todo.reload.finished? }.to(true) } end context 'to doing' do - let(:todo) { FactoryGirl.create :todo, :with_records, :finished } + let(:todo) { FactoryBot.create :todo, :with_records, :finished } let(:status) { 'doing' } + it { expect { subject.perform }.to change { todo.reload.doing? }.to(true) } end context 'to pending' do - let(:todo) { FactoryGirl.create :todo, :with_records, :doing } + let(:todo) { FactoryBot.create :todo, :with_records, :doing } let(:status) { 'pending' } - it { expect { subject.perform }.to change { todo.pending? }.to(true) } + + it { expect { subject.perform }.to change(todo, :pending?).to(true) } end context 'to pending if no reocrds' do - let(:todo) { FactoryGirl.create :todo, :doing } + let(:todo) { FactoryBot.create :todo, :doing } let(:status) { 'finished' } + it { expect { subject.perform }.not_to change { todo.reload.status } } end describe '#update_todo_last_recorded_at' do - let!(:todo) { FactoryGirl.create :todo, :with_records, :doing } + let!(:todo) { FactoryBot.create :todo, :with_records, :doing } let(:status) { 'finished' } + before { Timecop.freeze 1.hour.from_now } + it { expect { subject.perform }.to change { todo.reload.last_recorded_at } } end context 'remove sort if finished' do - let!(:todo) { FactoryGirl.create :todo, :with_records, :doing } + let!(:todo) { FactoryBot.create :todo, :with_records, :doing } let(:status) { 'finished' } + before { todo.insert_at(1) } it { expect { subject.perform }.to change { todo.reload.sort }.to(nil) } end context 'remove sort if pending' do - let!(:todo) { FactoryGirl.create :todo, :with_records, :doing, sort: 1 } + let!(:todo) { FactoryBot.create :todo, :with_records, :doing, sort: 1 } let(:status) { 'pending' } + before { todo.insert_at(1) } it { expect { subject.perform }.to change { todo.reload.sort }.to(nil) } context 'status = nil will not change sort and status' do let(:status) { nil } + before { todo.insert_at(1) } + it { expect { subject.perform }.not_to change { todo.reload.sort } } end end context 'add sort finished to doing' do - let!(:todo) { FactoryGirl.create :todo, :with_records, :finished } + let!(:todo) { FactoryBot.create :todo, :with_records, :finished } let(:status) { 'doing' } it { expect { subject.perform }.to change { todo.reload.sort }.to(1) } end context 'add sort pending to doing' do - let!(:todo) { FactoryGirl.create :todo, :with_records } + let!(:todo) { FactoryBot.create :todo, :with_records } let(:status) { 'doing' } it { expect { subject.perform }.to change { todo.reload.sort }.to(1) } diff --git a/spec/contexts/todo_create_by_record_context_spec.rb b/spec/contexts/todo_create_by_record_context_spec.rb index 0faaa0aa..9bb06167 100644 --- a/spec/contexts/todo_create_by_record_context_spec.rb +++ b/spec/contexts/todo_create_by_record_context_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' describe TodoCreateByRecordContext do - let(:record) { FactoryGirl.create :record, note: '123123' } - subject { described_class.new(record) } + let(:record) { FactoryBot.create :record, note: '123123' } + it { expect { subject.perform }.to change { record.user.todos.count }.by(1) } it { expect { subject.perform }.to change { record.project.todos.count }.by(1) } it { expect { subject.perform }.to change { record.reload.todo } } @@ -13,7 +13,7 @@ it { expect(subject.perform.reload.last_recorded_at).to be_present } context 'record desc blank' do - let(:record) { FactoryGirl.create :record, note: '' } + let(:record) { FactoryBot.create :record, note: '' } it { expect { subject.perform }.not_to change { record.user.todos.count } } end diff --git a/spec/contexts/todo_create_context_spec.rb b/spec/contexts/todo_create_context_spec.rb index 7cc24434..8d98ea05 100644 --- a/spec/contexts/todo_create_context_spec.rb +++ b/spec/contexts/todo_create_context_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' describe TodoCreateContext do - let(:project) { FactoryGirl.create :project, :with_project_user } - let(:user) { project.owner } - subject { described_class.new(user, params) } + let(:project) { FactoryBot.create :project, :with_project_user } + let(:user) { project.owner } + context 'success' do let(:params) { attributes_for(:todo_for_params, project_id: project.id) } diff --git a/spec/contexts/todo_delete_context_spec.rb b/spec/contexts/todo_delete_context_spec.rb index f07e4a5d..b2759da5 100644 --- a/spec/contexts/todo_delete_context_spec.rb +++ b/spec/contexts/todo_delete_context_spec.rb @@ -1,17 +1,18 @@ require 'rails_helper' describe TodoDeleteContext do - let(:todo) { FactoryGirl.create :todo } - let(:user) { todo.user } - subject { described_class.new(todo) } + let(:todo) { FactoryBot.create :todo } + let(:user) { todo.user } + context 'success' do it { expect { subject.perform }.to change { user.todos.count }.by(-1) } end context 'validates_done_yet' do - let(:todo) { FactoryGirl.create :todo, :finished } + let(:todo) { FactoryBot.create :todo, :finished } + it { expect { subject }.not_to change { user.todos.count } } end end diff --git a/spec/contexts/todo_publish_context_spec.rb b/spec/contexts/todo_publish_context_spec.rb index d54373a6..b5cd2c08 100644 --- a/spec/contexts/todo_publish_context_spec.rb +++ b/spec/contexts/todo_publish_context_spec.rb @@ -1,9 +1,10 @@ require 'rails_helper' describe TodoPublishContext, type: :context do - let(:user) { FactoryGirl.create(:user) } subject { described_class.new(user) } + let(:user) { FactoryBot.create(:user) } + it 'empty' do expect { subject.perform @@ -11,8 +12,9 @@ end context 'has todo & record' do - let!(:todo) { FactoryGirl.create :todo, :with_records, user: user } - let!(:done_todo) { FactoryGirl.create :todo, :finished, :with_records, user: user } + let!(:todo) { FactoryBot.create :todo, :with_records, user: user } + let!(:done_todo) { FactoryBot.create :todo, :finished, :with_records, user: user } + it do expect { subject.perform @@ -22,6 +24,7 @@ describe '#update_user_todos_published' do it { expect { subject.perform }.to change { user.reload.todos_published? }.to(true) } + context 'skip_user_update' do it { expect { subject.perform(skip_user_update: true) }.not_to change { user.reload.todos_published? } } end @@ -29,7 +32,7 @@ context 'todo scopes' do def add_record(todo) - RecordCreateContext.new(user, todo.project).perform(FactoryGirl.attributes_for(:record_for_params, todo_id: todo.id)) + RecordCreateContext.new(user, todo.project).perform(FactoryBot.attributes_for(:record_for_params, todo_id: todo.id)) expect(todo.reload.last_recorded_on).to be_present end @@ -47,11 +50,13 @@ def invite_user_to_project(user, project) project.project_users.create(user: user) end - let(:todo) { FactoryGirl.create(:todo, :pending, user: user) } + let(:todo) { FactoryBot.create(:todo, :pending, user: user) } + before { invite_user_to_project(user, todo.project) } context 'no record -> doing' do before { to_doing(todo) } + before { subject.perform } it { expect(subject.today_doing_todos.map(&:id)).not_to be_include(todo.id) } @@ -60,7 +65,9 @@ def invite_user_to_project(user, project) context 'doing -> no record -> pending' do before { to_doing(todo) } + before { to_pending(todo) } + before { subject.perform } it { expect(subject.today_doing_todos.map(&:id)).not_to be_include(todo.id) } @@ -69,16 +76,22 @@ def invite_user_to_project(user, project) context 'doing -> has record' do before { to_doing(todo) } + before { add_record(todo) } + before { subject.perform } + it { expect(subject.today_doing_todos.map(&:id)).to be_include(todo.id) } it { expect(subject.doing_todos.map(&:id)).to be_include(todo.id) } end context 'doing -> has record -> pending' do before { to_doing(todo) } + before { add_record(todo) } + before { to_pending(todo) } + before { subject.perform } it { expect(subject.today_doing_todos.map(&:id)).to be_include(todo.id) } diff --git a/spec/contexts/todo_update_context_spec.rb b/spec/contexts/todo_update_context_spec.rb index 8cf3f252..8bd68a33 100644 --- a/spec/contexts/todo_update_context_spec.rb +++ b/spec/contexts/todo_update_context_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe TodoUpdateContext do - let(:project) { FactoryGirl.create :project, :with_project_user } - let(:user) { project.owner } - let(:todo) { FactoryGirl.create :todo, user: user } - subject { described_class.new(todo, params) } + let(:project) { FactoryBot.create :project, :with_project_user } + let(:user) { project.owner } + let(:todo) { FactoryBot.create :todo, user: user } + context 'success' do let(:params) { attributes_for(:todo_for_params, desc: 'blablabla') } @@ -16,13 +16,15 @@ context 'validates_project!' do let(:params) { attributes_for(:todo_for_params, :has_project_id) } - it { expect { subject.perform }.not_to change { todo.project } } + it { expect { subject.perform }.not_to change(todo, :project) } end describe '#sorting' do - let(:todo) { FactoryGirl.create :todo, :doing, user: user } + let(:todo) { FactoryBot.create :todo, :doing, user: user } let(:params) { attributes_for(:todo_for_params, sort: :remove) } + before { todo.insert_at(1) } + it { expect { subject.perform }.to change { todo.reload.sort }.to(nil) } end end diff --git a/spec/contexts/user_auth_context_spec.rb b/spec/contexts/user_auth_context_spec.rb index cc94625a..c78ea770 100644 --- a/spec/contexts/user_auth_context_spec.rb +++ b/spec/contexts/user_auth_context_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' describe UserAuthContext do - let(:user) { FactoryGirl.create :unconfirmed_user } + subject { described_class.new(omniauth_data, user).perform } + + let(:user) { FactoryBot.create :unconfirmed_user } let(:omniauth_data) { omniauth_mock(:github) } let(:email) { omniauth_data['info']['email'] } - subject { described_class.new(omniauth_data, user).perform } - context 'with current_user' do it 'first bind' do expect { @@ -15,6 +15,7 @@ expect(user.authorizations.last.auth_data).to be_present expect(@result[:user].id).to eq user.id end + it 'unconfirm to confirm' do if user.confirmable? expect { @@ -22,21 +23,24 @@ }.to change { user.reload.confirmed? }.to(true) end end + it 'user2 has the same email' do - FactoryGirl.create :user, email: email + FactoryBot.create :user, email: email expect { @result = subject }.not_to change { user.reload.authorizations.count } expect(@result).to eq false end + it 'user2 has the same email with google auth' do expect { described_class.new(omniauth_mock(:google_oauth2)).perform - }.to change { User.count }.by(1) + }.to change(User, :count).by(1) expect { subject }.not_to change { user.reload.authorizations.count } end + it 'facebook then google with the same user' do expect { subject @@ -45,6 +49,7 @@ described_class.new(omniauth_mock(:google_oauth2), user).perform }.to change { user.reload.authorizations.count }.from(1).to(2) end + context 'already bind' do before { subject } @@ -54,8 +59,10 @@ }.not_to change { user.reload.authorizations.count } end end + context 'already bind to user2' do - let!(:user2) { FactoryGirl.create :user, email: email } + let!(:user2) { FactoryBot.create :user, email: email } + before { described_class.new(omniauth_data, user2).perform } it 'authorizations count' do @@ -63,6 +70,7 @@ subject }.not_to change { user.reload.authorizations.count } end + it 'update auth_data' do authorization = user2.authorizations.last authorization.update_attribute :auth_data, nil @@ -77,15 +85,17 @@ it 'success' do expect { described_class.new(omniauth_data).perform - }.to change { User.count }.by(1) + }.to change(User, :count).by(1) expect(User.last.authorizations.count).to eq 1 end + it 'email exists will auto find and bind' do user.update_column :email, email expect { described_class.new(omniauth_data).perform }.to change { user.reload.authorizations.count }.by(1) end + it 'new user bind to google' do user = described_class.new(omniauth_data).perform[:user] expect { @@ -94,7 +104,7 @@ end end - context '#update_github_data!' do + describe '#update_github_data!' do it 'success' do user = subject[:user] expect(user.github_id).to be_present @@ -103,6 +113,7 @@ expect(user.github_token).to be_present expect(user.name).to be_present end + it 'sync if auth_data changed' do subject ori_name = omniauth_data['info']['name'] @@ -127,7 +138,8 @@ end context 'exists user' do - before { FactoryGirl.create :user, email: email } + before { FactoryBot.create :user, email: email } + it do expect { subject.perform diff --git a/spec/contexts/user_create_project_context_spec.rb b/spec/contexts/user_create_project_context_spec.rb index af0900d8..75fd1f17 100644 --- a/spec/contexts/user_create_project_context_spec.rb +++ b/spec/contexts/user_create_project_context_spec.rb @@ -1,15 +1,15 @@ require 'rails_helper' describe UserCreateProjectContext do - let(:user) { FactoryGirl.create :user } - let(:data) { attributes_for(:project) } - subject { described_class.new(user, data).perform } + let(:user) { FactoryBot.create :user } + let(:data) { attributes_for(:project) } + it 'success' do expect { @project = subject - }.to change { Project.count } + }.to change(Project, :count) expect(@project.name).to be_present end diff --git a/spec/controllers/admin/base_controller_spec.rb b/spec/controllers/admin/base_controller_spec.rb index f090aa42..1f31ecb6 100644 --- a/spec/controllers/admin/base_controller_spec.rb +++ b/spec/controllers/admin/base_controller_spec.rb @@ -3,20 +3,20 @@ RSpec.describe Admin::BaseController, type: :request do it '.authenticate_user!' do get '/admin' - expect(response).not_to be_success + expect(response).not_to be_successful end - context '.authenticate_admin_user!' do + describe '.authenticate_admin_user!' do it 'success' do - signin_user(FactoryGirl.create(:admin_user)) + signin_user(FactoryBot.create(:admin_user)) get '/admin' - expect(response).to be_success + expect(response).to be_successful end it 'not admin' do - signin_user(FactoryGirl.create(:user)) + signin_user(FactoryBot.create(:user)) get '/admin' - expect(response).not_to be_success + expect(response).not_to be_successful end end end diff --git a/spec/controllers/admin/categories_controller_spec.rb b/spec/controllers/admin/categories_controller_spec.rb index 7f66a360..eca9b80f 100644 --- a/spec/controllers/admin/categories_controller_spec.rb +++ b/spec/controllers/admin/categories_controller_spec.rb @@ -13,46 +13,47 @@ require 'rails_helper' RSpec.describe Admin::CategoriesController, type: :request do - let(:category) { FactoryGirl.create :category } + let(:category) { FactoryBot.create :category } before { signin_user } context 'GET /admin/categories' do it 'html' do get '/admin/categories' - expect(response).to be_success + expect(response).to be_successful end end it 'GET /admin/categories/new' do get '/admin/categories/new' - expect(response).to be_success + expect(response).to be_successful end it 'GET /admin/categories/123' do get "/admin/categories/#{category.id}" - expect(response).to be_success + expect(response).to be_successful end it 'GET /admin/categories/123/edit' do get "/admin/categories/#{category.id}/edit" - expect(response).to be_success + expect(response).to be_successful end context 'POST /admin/categories' do it 'success' do expect { post '/admin/categories', params: { category: attributes_for(:category_for_create) } - }.to change { Category.count }.by(1) + }.to change(Category, :count).by(1) expect(response).to be_redirect follow_redirect! - expect(response).to be_success + expect(response).to be_successful expect(Category.last.tags.count).to be > 0 end + it 'fail' do expect { post '/admin/categories', params: { category: attributes_for(:category_for_create, name: '') } - }.not_to change { Category.count } + }.not_to change(Category, :count) expect(response).not_to be_redirect expect(response_flash_message('error')).to be_present end @@ -65,8 +66,9 @@ }.to change { category.reload.name }.to('Venus') expect(response).to be_redirect follow_redirect! - expect(response).to be_success + expect(response).to be_successful end + it 'fail' do expect { put "/admin/categories/#{category.id}", params: { category: { name: '' } } @@ -77,24 +79,24 @@ end it 'DELETE /admin/categories/123' do - category = FactoryGirl.create :category + category = FactoryBot.create :category expect { delete "/admin/categories/#{category.id}" - }.to change { Category.count }.by(-1) + }.to change(Category, :count).by(-1) follow_redirect! - expect(response).to be_success + expect(response).to be_successful end context 'GET /admin/categories/123/revisions' do it 'empty' do get "/admin/categories/#{category.id}/revisions" - expect(response).to be_success + expect(response).to be_successful end it 'has revisions' do Admin::Category.find(category.id).update_attribute :name, 'abcdefg' get "/admin/categories/#{category.id}/revisions" - expect(response).to be_success + expect(response).to be_successful expect(response.body).to match('abcdefg') end end @@ -104,6 +106,7 @@ post "/admin/categories/#{category.id}/restore" expect(response).to be_redirect end + it 'succes' do category.destroy expect { diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 8c1db30e..c1015fb0 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -34,47 +34,50 @@ context 'GET /admin/users' do it 'html' do get '/admin/users' - expect(response).to be_success + expect(response).to be_successful end + it 'csv' do get '/admin/users.csv' - expect(response).to be_success + expect(response).to be_successful expect(response.body).to match(current_user.name) end end it 'GET /admin/users/new' do get '/admin/users/new' - expect(response).to be_success + expect(response).to be_successful end it 'GET /admin/users/123' do get "/admin/users/#{current_user.id}" - expect(response).to be_success + expect(response).to be_successful end it 'GET /admin/users/123/edit' do get "/admin/users/#{current_user.id}/edit" - expect(response).to be_success + expect(response).to be_successful end context 'POST /admin/users' do it 'success' do expect { post '/admin/users', params: { user: attributes_for(:user_for_create) } - }.to change { User.count }.by(1) + }.to change(User, :count).by(1) expect(response).to be_redirect follow_redirect! - expect(response).to be_success + expect(response).to be_successful end + it 'with avatar' do post '/admin/users', params: { user: attributes_for(:user_for_create, avatar: file_data) } expect(User.last.avatar.url).to be_present end + it 'fail' do expect { post '/admin/users', params: { user: attributes_for(:user_for_create, email: '') } - }.not_to change { User.count } + }.not_to change(User, :count) expect(response).not_to be_redirect expect(response_flash_message('error')).to be_present end @@ -87,8 +90,9 @@ }.to change { current_user.reload.name }.to('Venus') expect(response).to be_redirect follow_redirect! - expect(response).to be_success + expect(response).to be_successful end + it 'fail' do expect { put "/admin/users/#{current_user.id}", params: { user: { email: '' } } @@ -99,11 +103,11 @@ end it 'DELETE /admin/users/123' do - user = FactoryGirl.create :user + user = FactoryBot.create :user expect { delete "/admin/users/#{user.id}" - }.to change { User.count }.by(-1) + }.to change(User, :count).by(-1) follow_redirect! - expect(response).to be_success + expect(response).to be_successful end end diff --git a/spec/controllers/authorizations_controller_spec.rb b/spec/controllers/authorizations_controller_spec.rb index 4e62b73f..edd0af80 100644 --- a/spec/controllers/authorizations_controller_spec.rb +++ b/spec/controllers/authorizations_controller_spec.rb @@ -16,28 +16,32 @@ require 'rails_helper' describe AuthorizationsController, type: :request do - context '#callback' do + describe '#callback' do let(:fb_auth) { get '/authorizations/facebook/callback', env: { 'omniauth.auth' => omniauth_mock(:facebook) } } let(:google_auth) { get '/authorizations/google_oauth2/callback', env: { 'omniauth.auth' => omniauth_mock(:google_oauth2) } } + it 'success' do expect { fb_auth - }.to change { User.count }.by(1) + }.to change(User, :count).by(1) expect(response).to be_redirect follow_redirect! - expect(response).to be_success + expect(response).to be_successful end context 'user auth fb & signed in' do let(:user2) { create(:user, email: omniauth_mock(:facebook)[:info][:email]) } + before { fb_auth } + before { follow_redirect! } + before { @user = User.last } it 'auth google' do expect { google_auth - }.not_to change { User.count } + }.not_to change(User, :count) expect(@user.authorizations.count).to eq 2 end @@ -47,7 +51,7 @@ google_auth follow_redirect! }.not_to change { @user.authorizations.count + user2.authorizations.count } - expect(response).to be_success + expect(response).to be_successful end end diff --git a/spec/controllers/base_controller_spec.rb b/spec/controllers/base_controller_spec.rb index e886ba7a..2223124c 100644 --- a/spec/controllers/base_controller_spec.rb +++ b/spec/controllers/base_controller_spec.rb @@ -3,13 +3,13 @@ RSpec.describe BaseController, type: :request do it 'GET /' do get '/' - expect(response).to be_success + expect(response).to be_successful expect(response_meta_title).to be_present end it 'GET /robots.txt' do get '/robots.txt' - expect(response).to be_success + expect(response).to be_successful expect(response.body).not_to match(' 0 } end context 'not in project' do - let!(:project) { FactoryGirl.create :project } - it { expect { subject }.not_to change { Todo.count } } + let!(:project) { FactoryBot.create :project } + + it { expect { subject }.not_to change(Todo, :count) } end end context 'PUT /todos/123.js' do - let!(:todo) { FactoryGirl.create :todo, user: user } subject { put "/todos/#{todo.id}.js", params: { todo: { desc: '123' } }, xhr: true } + + let!(:todo) { FactoryBot.create :todo, user: user } + context 'success' do before { subject } - it { expect(response).to be_success } + + it { expect(response).to be_successful } it { expect(todo.reload.desc).to eq '123' } end context 'not my todo' do - let!(:todo) { FactoryGirl.create :todo } + let!(:todo) { FactoryBot.create :todo } + it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } end end context 'DELETE /todos/123.js' do - let!(:todo) { FactoryGirl.create :todo, user: user } subject { delete "/todos/#{todo.id}.js", xhr: true } + + let!(:todo) { FactoryBot.create :todo, user: user } + context 'success' do before { subject } - it { expect(response).to be_success } + + it { expect(response).to be_successful } it { expect(Todo.count).to eq 0 } end context 'not my todo' do - let!(:todo) { FactoryGirl.create :todo } + let!(:todo) { FactoryBot.create :todo } + it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } end end @@ -112,54 +135,59 @@ context 'finished change to doing' do let(:status) { 'doing' } - let!(:todo) { FactoryGirl.create :todo, :finished, user: user } + let!(:todo) { FactoryBot.create :todo, :finished, user: user } + it { expect { subject }.to change { todo.reload.finished? }.to(false) } end context 'pending change to doing' do let(:status) { 'doing' } - let!(:todo) { FactoryGirl.create :todo, user: user } + let!(:todo) { FactoryBot.create :todo, user: user } it { expect { subject }.to change { todo.reload.doing? }.to(true) } end context 'doing change to pending' do let(:status) { 'pending' } - let!(:todo) { FactoryGirl.create :todo, :doing, user: user } + let!(:todo) { FactoryBot.create :todo, :doing, user: user } it { expect { subject }.to change { todo.reload.pending? }.to(true) } end context 'doing change to finished' do let(:status) { 'finished' } - let!(:todo) { FactoryGirl.create :todo, :with_records, :doing, user: user } + let!(:todo) { FactoryBot.create :todo, :with_records, :doing, user: user } it { expect { subject }.to change { todo.reload.finished? }.to(true) } end context 'pending change to finished' do let(:status) { 'finished' } - let!(:todo) { FactoryGirl.create :todo, :with_records, user: user } + let!(:todo) { FactoryBot.create :todo, :with_records, user: user } it { expect { subject }.to change { todo.reload.finished? }.to(true) } end context 'fail without record' do let(:status) { 'finished' } - let!(:todo) { FactoryGirl.create :todo, :doing, user: user } + let!(:todo) { FactoryBot.create :todo, :doing, user: user } + it { expect { subject }.not_to change { todo.reload.finished? } } end context 'not my todo' do let(:status) { 'finished' } - let!(:todo) { FactoryGirl.create :todo, :doing } + let!(:todo) { FactoryBot.create :todo, :doing } + it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } end end context 'POST /todos/publish' do subject { post '/todos/publish', headers: { 'HTTP_REFERER' => '/todos' } } + before { subject } + it { expect(response).to redirect_to('/todos') } end diff --git a/spec/controllers/users/passwords_controller_spec.rb b/spec/controllers/users/passwords_controller_spec.rb index 1eb51008..c4cbc5fc 100644 --- a/spec/controllers/users/passwords_controller_spec.rb +++ b/spec/controllers/users/passwords_controller_spec.rb @@ -4,6 +4,7 @@ context 'redirect new to sign_in' do subject { get '/users/password/new' } + it { expect(subject).to redirect_to('/users/sign_in') } end diff --git a/spec/controllers/users/registrations_controller.spec.rb b/spec/controllers/users/registrations_controller.spec.rb index 178b489b..87356030 100644 --- a/spec/controllers/users/registrations_controller.spec.rb +++ b/spec/controllers/users/registrations_controller.spec.rb @@ -4,6 +4,7 @@ context 'redirect new to sign_in' do subject { get '/users/sign_up' } + it { expect(subject).to redirect_to('/users/sign_in') } end diff --git a/spec/factories/authorizations.rb b/spec/factories/authorizations.rb index 12c3a4d2..ff949e36 100644 --- a/spec/factories/authorizations.rb +++ b/spec/factories/authorizations.rb @@ -13,9 +13,9 @@ # updated_at :datetime not null # -FactoryGirl.define do +FactoryBot.define do factory :authorization do - auth { FactoryGirl.create :user } + auth { FactoryBot.create :user } provider { :facebook } sequence(:uid) { |n| n } end diff --git a/spec/factories/categories.rb b/spec/factories/categories.rb index fa9990f3..736260ec 100644 --- a/spec/factories/categories.rb +++ b/spec/factories/categories.rb @@ -10,13 +10,13 @@ # sort :integer # -FactoryGirl.define do +FactoryBot.define do factory :category do sequence(:name) { |n| "category #{n}" } end - factory :category_for_create, class: Category do + factory :category_for_create, class: 'Category' do sequence(:name) { |n| "category #{n}" } - tag_list 'a,b,c' + tag_list { 'a,b,c' } end end diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index e2e453ed..48498589 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -11,13 +11,13 @@ # data :hstore # -FactoryGirl.define do +FactoryBot.define do factory :comment do - user { FactoryGirl.create :user } - item { FactoryGirl.create :record } + user { FactoryBot.create :user } + item { FactoryBot.create :record } end - factory :comment_for_create, class: Comment do - user_id { FactoryGirl.create(:user).id } + factory :comment_for_create, class: 'Comment' do + user_id { FactoryBot.create(:user).id } end end diff --git a/spec/factories/githubs.rb b/spec/factories/githubs.rb index 49db5991..e30fd8e2 100644 --- a/spec/factories/githubs.rb +++ b/spec/factories/githubs.rb @@ -10,7 +10,7 @@ # updated_at :datetime not null # -FactoryGirl.define do +FactoryBot.define do factory :github do sequence(:webhook_token) { |i| "tokenasdasdas#{i}" } end diff --git a/spec/factories/project_users.rb b/spec/factories/project_users.rb index 0491e730..9b37567a 100644 --- a/spec/factories/project_users.rb +++ b/spec/factories/project_users.rb @@ -13,17 +13,17 @@ # wage :integer # -FactoryGirl.define do +FactoryBot.define do factory :project_user do - user { FactoryGirl.create :user } - project { FactoryGirl.create :project } + user { FactoryBot.create :user } + project { FactoryBot.create :project } sequence(:slack_user) { |n| "user-#{n}" } end - factory :project_user_for_update, class: ProjectUser do - sort :last - slack_user 'haha' - wage 123 + factory :project_user_for_update, class: 'ProjectUser' do + sort { :last } + slack_user { 'haha' } + wage { 123 } end end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 46640e16..8008019a 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -11,40 +11,40 @@ # data :hstore # -FactoryGirl.define do +FactoryBot.define do factory :project do - owner { FactoryGirl.create :user } + owner { FactoryBot.create :user } sequence(:name) { |n| "Project Name - #{n}" } - price_of_hour 1000 + price_of_hour { 1000 } trait :with_project_user do after(:create) do |project| - FactoryGirl.create :project_user, project: project, user: project.owner + FactoryBot.create :project_user, project: project, user: project.owner end end trait :with_other_user do after(:create) do |project| - FactoryGirl.create :project_user, project: project + FactoryBot.create :project_user, project: project end end trait :with_slack_channel do after(:create) do |project| - slack_channel = FactoryGirl.create :slack_channel, project: project + slack_channel = FactoryBot.create :slack_channel, project: project project.update_attribute :primary_slack_channel_id, slack_channel.id end end trait :with_todos do after(:create) do |project| - FactoryGirl.create_list :todo, 2, project: project, user: project.owner + FactoryBot.create_list :todo, 2, project: project, user: project.owner end end trait :with_records do after(:create) do |project| - FactoryGirl.create_list :record, 2, :with_todo, project: project, user: project.owner + FactoryBot.create_list :record, 2, :with_todo, project: project, user: project.owner end end @@ -54,13 +54,13 @@ factory :project_has_records, traits: [:with_project_user, :with_records] end - factory :project_for_update, class: Project do + factory :project_for_update, class: 'Project' do trait :setting do - name 'blablabla' - price_of_hour 10_000_000 - hours_limit 100 - description 'hahaha' + name { 'blablabla' } + price_of_hour { 10_000_000 } + hours_limit { 100 } + description { 'hahaha' } end trait :project_users do diff --git a/spec/factories/records.rb b/spec/factories/records.rb index 5fce56b9..b5fa258c 100644 --- a/spec/factories/records.rb +++ b/spec/factories/records.rb @@ -13,25 +13,25 @@ # todo_id :integer # -FactoryGirl.define do +FactoryBot.define do factory :record do - project { FactoryGirl.create :project } - user { FactoryGirl.create :user } - todo { FactoryGirl.create(:todo) } - record_type :coding - minutes 100 + project { FactoryBot.create :project } + user { FactoryBot.create :user } + todo { FactoryBot.create(:todo) } + record_type { :coding } + minutes { 100 } trait :with_todo do end end - factory :record_for_params, class: Record do - record_type :etc - minutes 10 - note 'update minutes' + factory :record_for_params, class: 'Record' do + record_type { :etc } + minutes { 10 } + note { 'update minutes' } trait :has_todo_id do - todo_id { FactoryGirl.create(:todo).id } + todo_id { FactoryBot.create(:todo).id } end end end diff --git a/spec/factories/slack_channels.rb b/spec/factories/slack_channels.rb index d93e4260..8a829056 100644 --- a/spec/factories/slack_channels.rb +++ b/spec/factories/slack_channels.rb @@ -10,12 +10,12 @@ # updated_at :datetime not null # -FactoryGirl.define do +FactoryBot.define do factory :slack_channel do - project { FactoryGirl.create :project } - webhook 'https://hooks.slack.com/services/xxxxx/xxxx' - room '#general' - name 't123' + project { FactoryBot.create :project } + webhook { 'https://hooks.slack.com/services/xxxxx/xxxx' } + room { '#general' } + name { 't123' } trait :record_created do events { [:record_created] } @@ -26,15 +26,15 @@ end end - factory :slack_channel_for_update, class: SlackChannel do - name 'ttt' - primary '1' + factory :slack_channel_for_update, class: 'SlackChannel' do + name { 'ttt' } + primary { '1' } end - factory :slack_channel_for_create, class: SlackChannel do - robot_name 'Jupiter' - name 'tetetetet' - icon_url 'http://i.imgur.com/4G30GGh.jpg' + factory :slack_channel_for_create, class: 'SlackChannel' do + robot_name { 'Jupiter' } + name { 'tetetetet' } + icon_url { 'http://i.imgur.com/4G30GGh.jpg' } end end diff --git a/spec/factories/tags.rb b/spec/factories/tags.rb index 5932fd46..6c4a9dc9 100644 --- a/spec/factories/tags.rb +++ b/spec/factories/tags.rb @@ -7,7 +7,7 @@ # taggings_count :integer default(0) # -FactoryGirl.define do +FactoryBot.define do factory :tag do end diff --git a/spec/factories/todos.rb b/spec/factories/todos.rb index 1cb75351..c27531ce 100644 --- a/spec/factories/todos.rb +++ b/spec/factories/todos.rb @@ -15,44 +15,44 @@ # status :integer # -FactoryGirl.define do +FactoryBot.define do factory :todo do - project { FactoryGirl.create :project } - user { FactoryGirl.create :user } + project { FactoryBot.create :project } + user { FactoryBot.create :user } sequence(:desc) { |n| "desc-#{n}" } trait :with_records do last_recorded_at { Time.zone.now } after :create do |todo| - FactoryGirl.create_list(:record, 2, todo: todo) + FactoryBot.create_list(:record, 2, todo: todo) end end trait :with_not_calculate_record do after :create do |todo| - FactoryGirl.create_list(:record, 2, todo: todo) + FactoryBot.create_list(:record, 2, todo: todo) end end trait :finished do last_recorded_at { Time.zone.now } - status 'finished' + status { 'finished' } end trait :doing do - status 'doing' + status { 'doing' } end trait :pending do - status 'pending' + status { 'pending' } end end - factory :todo_for_params, class: Todo do + factory :todo_for_params, class: 'Todo' do sequence(:desc) { |n| "desc-#{n}" } trait :has_project_id do - project_id { FactoryGirl.create(:project).id } + project_id { FactoryBot.create(:project).id } end end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index e0268db6..4da42cc5 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -26,20 +26,20 @@ # todos_published :boolean default(FALSE) # -FactoryGirl.define do +FactoryBot.define do factory :user do - name '5Fpro' + name { '5Fpro' } sequence(:email) { |n| "user#{n}@5fpro.com" } - password '12341234' - confirmed_at Time.now + password { '12341234' } + confirmed_at { Time.now } github_avatar { 'https://example.com/xxx.png' } factory :admin_user do - admin true + admin { true } end factory :unconfirmed_user do - confirmed_at nil + confirmed_at { nil } end factory :user_with_avatar do @@ -47,10 +47,10 @@ end end - factory :user_for_create, class: User do - name '5Fpro' + factory :user_for_create, class: 'User' do + name { '5Fpro' } sequence(:email) { |n| "user#{n}@5fpro.com" } - password '12341234' - admin '0' + password { '12341234' } + admin { '0' } end end diff --git a/spec/mailers/base_notifier_spec.rb b/spec/mailers/base_notifier_spec.rb index 22dadc85..1d81677e 100644 --- a/spec/mailers/base_notifier_spec.rb +++ b/spec/mailers/base_notifier_spec.rb @@ -2,7 +2,7 @@ RSpec.describe BaseNotifier, type: :mailer do it '#notify' do - mail = BaseNotifier.notify.deliver_now + mail = described_class.notify.deliver_now expect(mail.body).to match('Hello') end end diff --git a/spec/models/authorization_spec.rb b/spec/models/authorization_spec.rb index 9848fd37..01bf5f59 100644 --- a/spec/models/authorization_spec.rb +++ b/spec/models/authorization_spec.rb @@ -16,7 +16,7 @@ require 'rails_helper' RSpec.describe Authorization, type: :model do - it 'FactoryGirl' do - expect(FactoryGirl.create(:authorization)).not_to be_new_record + it 'FactoryBot' do + expect(FactoryBot.create(:authorization)).not_to be_new_record end end diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index 2a38e056..fa07f370 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -13,13 +13,13 @@ require 'rails_helper' RSpec.describe Category, type: :model do - let(:category) { FactoryGirl.create :category } + let(:category) { FactoryBot.create :category } - it 'FactoryGirl' do + it 'FactoryBot' do expect { - FactoryGirl.create :category - FactoryGirl.create :category - }.to change { Category.count }.by(2) + FactoryBot.create :category + FactoryBot.create :category + }.to change(described_class, :count).by(2) end it 'acts_as_paranoid' do @@ -37,7 +37,7 @@ it 'sortable' do category.reload.update_attribute :sort, :up - category2 = FactoryGirl.create :category + category2 = FactoryBot.create :category expect { category2.update_attribute :sort, :up }.to change { described_class.sorted.try(:first).try(:id) }.to eq category2.id diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 9ecd8689..2145a7f3 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -14,9 +14,9 @@ require 'rails_helper' RSpec.describe Comment, type: :model do - let(:comment) { FactoryGirl.create :comment } + let(:comment) { FactoryBot.create :comment } - context 'FactoryGirl' do + context 'FactoryBot' do it { expect(comment).not_to be_new_record } it { attributes_for :comment_for_create } end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 3306427f..4b71141b 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -14,27 +14,28 @@ require 'rails_helper' RSpec.describe Project, type: :model do - let(:project) { FactoryGirl.create :project } + let(:project) { FactoryBot.create :project } - context 'FactoryGirl' do + context 'FactoryBot' do it { expect(project).not_to be_new_record } - it { FactoryGirl.create :project, :with_project_user } - it { FactoryGirl.create :project, :with_other_user } - it { FactoryGirl.create :project, :with_slack_channel } - it { FactoryGirl.create :project, :with_records } - it { FactoryGirl.create :project_for_slack_notify } - it { FactoryGirl.create :project_has_members } - it { FactoryGirl.create :project_has_records } + it { FactoryBot.create :project, :with_project_user } + it { FactoryBot.create :project, :with_other_user } + it { FactoryBot.create :project, :with_slack_channel } + it { FactoryBot.create :project, :with_records } + it { FactoryBot.create :project_for_slack_notify } + it { FactoryBot.create :project_has_members } + it { FactoryBot.create :project_has_records } it { attributes_for :project_for_update, :setting } it { attributes_for :project_for_update, :project_users } end describe 'order by project_user sort' do - let!(:user) { FactoryGirl.create :user } - let!(:project_user1) { FactoryGirl.create :project_user, user: user } - let!(:project_user2) { FactoryGirl.create :project_user, user: user } + let!(:user) { FactoryBot.create :user } + let!(:project_user1) { FactoryBot.create :project_user, user: user } + let!(:project_user2) { FactoryBot.create :project_user, user: user } before { project_user1.update_attribute(:sort, 2) } + before { project_user2.update_attribute(:sort, 1) } context 'sort' do diff --git a/spec/models/project_user_spec.rb b/spec/models/project_user_spec.rb index dd80e0fc..b10127e4 100644 --- a/spec/models/project_user_spec.rb +++ b/spec/models/project_user_spec.rb @@ -16,9 +16,9 @@ require 'rails_helper' RSpec.describe ProjectUser, type: :model do - let(:project_user) { FactoryGirl.create :project_user } + let(:project_user) { FactoryBot.create :project_user } - context 'FactoryGirl' do + context 'FactoryBot' do it { expect(project_user).not_to be_new_record } it { attributes_for :project_user_for_update } end diff --git a/spec/models/record_spec.rb b/spec/models/record_spec.rb index 1a58a866..456b2920 100644 --- a/spec/models/record_spec.rb +++ b/spec/models/record_spec.rb @@ -16,9 +16,9 @@ require 'rails_helper' RSpec.describe Record, type: :model do - let(:record) { FactoryGirl.create :record } + let(:record) { FactoryBot.create :record } - context 'FactoryGirl' do + context 'FactoryBot' do it { expect(record).not_to be_new_record } it { attributes_for :record_for_params } end diff --git a/spec/models/slack_channel_spec.rb b/spec/models/slack_channel_spec.rb index 46e42850..e92d57b9 100644 --- a/spec/models/slack_channel_spec.rb +++ b/spec/models/slack_channel_spec.rb @@ -13,18 +13,18 @@ require 'rails_helper' RSpec.describe SlackChannel, type: :model do - let(:slack_channel) { FactoryGirl.create :slack_channel } + let(:slack_channel) { FactoryBot.create :slack_channel } - context 'FactoryGirl' do + context 'FactoryBot' do it { expect(slack_channel).not_to be_new_record } - it { FactoryGirl.create :slack_channel, :record_created } - it { FactoryGirl.create :slack_channel, :approach_hours_limit } + it { FactoryBot.create :slack_channel, :record_created } + it { FactoryBot.create :slack_channel, :approach_hours_limit } it { attributes_for :slack_channel_for_update } it { attributes_for :slack_channel_for_create } end it '#events and & #event?' do slack_channel.update_attribute :events, ['', 'record_created'] - expect(SlackChannel.find(slack_channel.id).event?(:record_created)).to eq true + expect(described_class.find(slack_channel.id).event?(:record_created)).to eq true end end diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb index 318c010e..2c3eadf5 100644 --- a/spec/models/todo_spec.rb +++ b/spec/models/todo_spec.rb @@ -18,23 +18,24 @@ require 'rails_helper' RSpec.describe Todo, type: :model do - let(:todo) { FactoryGirl.create :todo } + let(:todo) { FactoryBot.create :todo } - context 'FactoryGirl' do + context 'FactoryBot' do it { expect(todo).not_to be_new_record } end describe '.for_bind' do - let!(:todo1) { FactoryGirl.create :todo, :doing, last_recorded_at: nil } - let!(:todo2) { FactoryGirl.create :todo, last_recorded_at: Time.zone.now.to_date } - let!(:todo3) { FactoryGirl.create :todo, :finished, last_recorded_at: 1.day.ago } - let!(:todo4) { FactoryGirl.create :todo, :finished, last_recorded_at: 1.day.from_now } - let!(:todo5) { FactoryGirl.create :todo, :finished, last_recorded_at: Time.zone.now.to_date } - let!(:todo6) { FactoryGirl.create :todo, :doing, last_recorded_at: 1.day.from_now } - let!(:todo7) { FactoryGirl.create :todo, :pending, last_recorded_at: Time.zone.now.to_date } - let!(:todo8) { FactoryGirl.create :todo, :pending, last_recorded_at: 1.day.from_now } subject { described_class.for_bind.map(&:id) } + let!(:todo1) { FactoryBot.create :todo, :doing, last_recorded_at: nil } + let!(:todo2) { FactoryBot.create :todo, last_recorded_at: Time.zone.now.to_date } + let!(:todo3) { FactoryBot.create :todo, :finished, last_recorded_at: 1.day.ago } + let!(:todo4) { FactoryBot.create :todo, :finished, last_recorded_at: 1.day.from_now } + let!(:todo5) { FactoryBot.create :todo, :finished, last_recorded_at: Time.zone.now.to_date } + let!(:todo6) { FactoryBot.create :todo, :doing, last_recorded_at: 1.day.from_now } + let!(:todo7) { FactoryBot.create :todo, :pending, last_recorded_at: Time.zone.now.to_date } + let!(:todo8) { FactoryBot.create :todo, :pending, last_recorded_at: 1.day.from_now } + it { expect(subject).to be_include(todo1.id) } it { expect(subject).to be_include(todo2.id) } it { expect(subject).not_to be_include(todo3.id) } @@ -46,13 +47,14 @@ end describe '.today_doing_and_not_finished' do - let!(:todo1) { FactoryGirl.create :todo, :doing, last_recorded_at: nil } - let!(:todo2) { FactoryGirl.create :todo, :pending, last_recorded_at: 1.day.from_now } - let!(:todo3) { FactoryGirl.create :todo, :pending, last_recorded_at: Time.zone.now.to_date } - let!(:todo4) { FactoryGirl.create :todo, :finished, last_recorded_at: Time.zone.now.to_date } - let!(:todo5) { FactoryGirl.create :todo, :doing, last_recorded_at: Time.zone.now.to_date } subject { described_class.today_doing_and_not_finished.map(&:id) } + let!(:todo1) { FactoryBot.create :todo, :doing, last_recorded_at: nil } + let!(:todo2) { FactoryBot.create :todo, :pending, last_recorded_at: 1.day.from_now } + let!(:todo3) { FactoryBot.create :todo, :pending, last_recorded_at: Time.zone.now.to_date } + let!(:todo4) { FactoryBot.create :todo, :finished, last_recorded_at: Time.zone.now.to_date } + let!(:todo5) { FactoryBot.create :todo, :doing, last_recorded_at: Time.zone.now.to_date } + it { expect(subject).not_to be_include(todo1.id) } it { expect(subject).not_to be_include(todo2.id) } it { expect(subject).to be_include(todo3.id) } @@ -61,19 +63,19 @@ end describe '.not_today' do - let!(:todo1) { FactoryGirl.create :todo, last_recorded_on: nil } - let!(:todo2) { FactoryGirl.create :todo, last_recorded_on: Time.zone.now.to_date } - let!(:todo3) { FactoryGirl.create :todo, last_recorded_on: 1.day.ago } - subject { described_class.not_today.map(&:id) } + let!(:todo1) { FactoryBot.create :todo, last_recorded_on: nil } + let!(:todo2) { FactoryBot.create :todo, last_recorded_on: Time.zone.now.to_date } + let!(:todo3) { FactoryBot.create :todo, last_recorded_on: 1.day.ago } + it { expect(subject).to be_include(todo1.id) } it { expect(subject).not_to be_include(todo2.id) } it { expect(subject).to be_include(todo3.id) } end describe 'has many records' do - let(:todo) { FactoryGirl.create :todo, :with_records } + let(:todo) { FactoryBot.create :todo, :with_records } it 'destroy dependent' do record = todo.records.last @@ -87,15 +89,17 @@ it 'present' do expect { todo.last_recorded_at = Time.now - }.to change { todo.last_recorded_on } + }.to change(todo, :last_recorded_on) end + context 'nil' do - let(:todo) { FactoryGirl.create(:todo, :finished) } - it { expect { todo.last_recorded_at = nil }.to change { todo.last_recorded_on }.to(nil) } + let(:todo) { FactoryBot.create(:todo, :finished) } + + it { expect { todo.last_recorded_at = nil }.to change(todo, :last_recorded_on).to(nil) } end end describe 'without sort' do - it { expect(todo.not_in_list?).to be_truthy } + it { expect(todo).to be_not_in_list } end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index fc60b913..950eaeba 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -29,19 +29,19 @@ require 'rails_helper' RSpec.describe User, type: :model do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } - context 'FactoryGirl' do + context 'FactoryBot' do it { expect(user).not_to be_new_record } - it { expect(FactoryGirl.create(:user_with_avatar).avatar.url).to be_present } - it { expect(FactoryGirl.create(:unconfirmed_user).confirmed?).to eq false } - it { expect(FactoryGirl.create(:admin_user).admin?).to eq true } + it { expect(FactoryBot.create(:user_with_avatar).avatar.url).to be_present } + it { expect(FactoryBot.create(:unconfirmed_user).confirmed?).to eq false } + it { expect(FactoryBot.create(:admin_user).admin?).to eq true } it { attributes_for :user_for_create } end it 'devise async' do expect { - FactoryGirl.create :unconfirmed_user + FactoryBot.create :unconfirmed_user }.not_to have_enqueued_job(Devise::Mailer) end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 0eef4e5f..18c0663d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -54,7 +54,7 @@ config.include Webmock config.include RequestClient, type: :request config.include HtmlMatchers, type: :request - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.before(:each){ webmock_all! } config.before(:each){ Redis.current.flushdb } diff --git a/spec/services/datetime_service_spec.rb b/spec/services/datetime_service_spec.rb index bfbc3de6..f8799abb 100644 --- a/spec/services/datetime_service_spec.rb +++ b/spec/services/datetime_service_spec.rb @@ -5,6 +5,7 @@ describe '#to_units_text' do subject { described_class } + before { I18n.default_locale = :en } it { expect(subject.to_units_text(12.hours + 13.minutes + 24.seconds)).to eq('12 hours 13 minutes 24 seconds') } diff --git a/spec/services/github_service_spec.rb b/spec/services/github_service_spec.rb index 000a57f6..f2c1fd9b 100644 --- a/spec/services/github_service_spec.rb +++ b/spec/services/github_service_spec.rb @@ -23,7 +23,7 @@ describe '#create_hook' do subject { described_class.new('token').create_hook('xxx/repo', 'hook_url') } - it { expect(subject.id.present?).to be_truthy } + it { expect(subject.id).to be_present } end # describe "#show_hook" do diff --git a/spec/services/timecop_spec.rb b/spec/services/timecop_spec.rb index 6cc66a12..8a7ffed6 100644 --- a/spec/services/timecop_spec.rb +++ b/spec/services/timecop_spec.rb @@ -2,9 +2,9 @@ RSpec.describe Timecop, type: :model do it '' do - Timecop.freeze Time.now + described_class.freeze Time.now time1 = Time.now - Timecop.freeze time1 + 1.hour + described_class.freeze time1 + 1.hour time2 = Time.now expect(time2 - time1).to be >= 1.hour end diff --git a/spec/support/html_matchers.rb b/spec/support/html_matchers.rb index b821922e..9d591915 100644 --- a/spec/support/html_matchers.rb +++ b/spec/support/html_matchers.rb @@ -18,7 +18,7 @@ def response_meta_canonical end def response_flash_message(klass = nil) - response.body.scan(/(
)/)[0][0] + response.body.scan(/(
)/)[0][0] rescue '' end diff --git a/spec/support/request_client.rb b/spec/support/request_client.rb index 3eb21f54..d7bd5b56 100644 --- a/spec/support/request_client.rb +++ b/spec/support/request_client.rb @@ -5,7 +5,7 @@ def signout_user end def signin_user(user = nil) - user ||= FactoryGirl.create(:admin_user) + user ||= FactoryBot.create(:admin_user) post '/users/sign_in', params: { user: { email: user.email, password: user.password } } @current_user = user if response.status == 302 end diff --git a/spec/workers/projects_hours_limit_check_worker_spec.rb b/spec/workers/projects_hours_limit_check_worker_spec.rb index 589a0001..8810ab4c 100644 --- a/spec/workers/projects_hours_limit_check_worker_spec.rb +++ b/spec/workers/projects_hours_limit_check_worker_spec.rb @@ -1,8 +1,9 @@ require 'rails_helper' RSpec.describe ProjectsHoursLimitCheckWorker, type: :worker do - before { FactoryGirl.create :project } subject { described_class.new.perform } + before { FactoryBot.create :project } + it { expect { subject }.to have_enqueued_job(Project::HoursLimitCheckJob) } end diff --git a/spec/workers/todos_auto_publish_worker_spec.rb b/spec/workers/todos_auto_publish_worker_spec.rb index a4d5a099..ab45bbd1 100644 --- a/spec/workers/todos_auto_publish_worker_spec.rb +++ b/spec/workers/todos_auto_publish_worker_spec.rb @@ -1,16 +1,17 @@ require 'rails_helper' RSpec.describe TodosAutoPublishWorker, type: :worker do - let(:user) { FactoryGirl.create :user } subject { described_class.new } + let(:user) { FactoryBot.create :user } + context 'empty record' do it { expect { subject.perform }.not_to enqueue_job(TodosAutoPublishJob) } end context 'has todo & record' do - let!(:todo) { FactoryGirl.create :todo, :with_records, user: user } - let!(:done_todo) { FactoryGirl.create :todo, :with_records, :finished, user: user } + let!(:todo) { FactoryBot.create :todo, :with_records, user: user } + let!(:done_todo) { FactoryBot.create :todo, :with_records, :finished, user: user } it do count = User.all.reject { |user| user.todos_published? || user.records.today.empty? }.size From 33bbc582713ecfcda1f60afde3fd07974842ac1a Mon Sep 17 00:00:00 2001 From: marsz Date: Fri, 1 Oct 2021 10:42:00 +0800 Subject: [PATCH 6/9] fix: deploy --- .env.example | 4 ++-- config/deploy.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index cc0d0798..6e57d42e 100644 --- a/.env.example +++ b/.env.example @@ -32,7 +32,7 @@ OAUTH_GITHUB_SECRET=acc2d9185cdb236ffc227d4def846f3ade928710 STAGING_USERNAME=myapp STAGING_PASSWORD=myapp -SLACK_WEBHOOK=https://hooks.slack.com/services/xxxxx/xxxx -DEPLOY_SLACK_WEBHOOK=https://hooks.slack.com/services/xxxxx/xxxx +SLACK_WEBHOOK=https://hooks.slack.com/services/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 +DEPLOY_SLACK_WEBHOOK=https://hooks.slack.com/services/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 GA_ID="" diff --git a/config/deploy.rb b/config/deploy.rb index fe365cd8..8300299f 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,5 +1,6 @@ # config valid only for current version of Capistrano -lock '3.11.0' +require 'capistrano/version' +lock Capistrano::VERSION set :application, 'jupiter' set :repo_url, 'git@github.com:5fpro/jupiter.git' From be1e9561bf9f7e20a63d0ebb49f51242cffce67b Mon Sep 17 00:00:00 2001 From: marsz Date: Fri, 1 Oct 2021 12:50:11 +0800 Subject: [PATCH 7/9] fixup --- .gitignore | 1 - .rubocop_todo.yml | 142 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 .rubocop_todo.yml diff --git a/.gitignore b/.gitignore index d9618c1e..b67c2d2a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,6 @@ /public/assets /public/uploads /.capistrano/* -/.rubocop_todo.yml /.byebug_history /node_modules diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..101a1057 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,142 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2021-10-01 02:08:21 UTC using RuboCop version 1.22.0. +# 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: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/loggers/base_logger_spec.rb' + +# Offense count: 34 +Lint/MissingSuper: + Enabled: false + +# Offense count: 1 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 62 + +# Offense count: 171 +# Configuration parameters: Prefixes. +# Prefixes: when, with, without +RSpec/ContextWording: + Enabled: false + +# Offense count: 3 +RSpec/EmptyExampleGroup: + Exclude: + - 'spec/controllers/githubs_controller_spec.rb' + - 'spec/controllers/webhooks_controller_spec.rb' + - 'spec/models/tag_spec.rb' + +# Offense count: 26 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 14 + +# Offense count: 1 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always_allow, single_line_only, disallow +RSpec/ExampleWithoutDescription: + Exclude: + - 'spec/services/timecop_spec.rb' + +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Exclude: + - 'spec/controllers/users/registrations_controller.spec.rb' + +# Offense count: 11 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/contexts/project_invite_context_spec.rb' + - 'spec/contexts/project_remove_user_context_spec.rb' + - 'spec/contexts/user_auth_context_spec.rb' + - 'spec/contexts/user_create_project_context_spec.rb' + - 'spec/controllers/authorizations_controller_spec.rb' + +# Offense count: 1 +RSpec/LeakyConstantDeclaration: + Exclude: + - 'spec/loggers/base_logger_spec.rb' + +# Offense count: 14 +RSpec/LetSetup: + Exclude: + - 'spec/contexts/notify/trigger_context_spec.rb' + - 'spec/contexts/project/hours_limit_check_context_spec.rb' + - 'spec/contexts/todo_publish_context_spec.rb' + - 'spec/controllers/projects_controller_spec.rb' + - 'spec/controllers/todos_controller_spec.rb' + - 'spec/workers/todos_auto_publish_worker_spec.rb' + +# Offense count: 50 +RSpec/MultipleExpectations: + Max: 8 + +# Offense count: 2 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 9 + +# Offense count: 227 +# Configuration parameters: IgnoreSharedExamples. +RSpec/NamedSubject: + Enabled: false + +# Offense count: 22 +RSpec/NestedGroups: + Max: 4 + +# Offense count: 2 +RSpec/RepeatedExampleGroupDescription: + Exclude: + - 'spec/controllers/slack_channels_controller_spec.rb' + +# Offense count: 52 +RSpec/ScatteredSetup: + Exclude: + - 'spec/contexts/notify/trigger_context_spec.rb' + - 'spec/contexts/todo_calculate_context_spec.rb' + - 'spec/contexts/todo_publish_context_spec.rb' + - 'spec/controllers/authorizations_controller_spec.rb' + - 'spec/controllers/projects_controller_spec.rb' + - 'spec/controllers/records_controller_spec.rb' + - 'spec/controllers/slack_channels_controller_spec.rb' + - 'spec/models/project_spec.rb' + +# Offense count: 5 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments +Rails/FilePath: + Exclude: + - 'app/loggers/github_logger.rb' + - 'app/settings/setting.rb' + - 'spec/factories/users.rb' + - 'spec/loggers/base_logger_spec.rb' + +# Offense count: 4 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/UniqueValidationWithoutIndex: + Exclude: + - 'app/models/authorization.rb' + - 'app/models/category.rb' + - 'app/models/github.rb' + - 'app/models/project_user.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'app/models/admin/user.rb' From 9ae92a532e391bb22ce6b10523361f19e5175144 Mon Sep 17 00:00:00 2001 From: marsz Date: Wed, 5 Jan 2022 15:04:07 +0800 Subject: [PATCH 8/9] feat: project github token --- app/contexts/github/receive_callbacks_context.rb | 8 +++++--- app/controllers/webhooks_controller.rb | 5 +++-- app/models/project.rb | 12 ++++++++++++ app/views/githubs/_update_token.html.slim | 2 +- app/views/githubs/index.html.slim | 3 +++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/contexts/github/receive_callbacks_context.rb b/app/contexts/github/receive_callbacks_context.rb index 9bbd257d..7d8fb4a9 100644 --- a/app/contexts/github/receive_callbacks_context.rb +++ b/app/contexts/github/receive_callbacks_context.rb @@ -6,11 +6,12 @@ class Github::ReceiveCallbacksContext < ::BaseContext before_perform :find_mentions before_perform :remove_self_notify! - def initialize(github, request:) + def initialize(github, request:, project: nil) @github = github @request = request @event = request.headers.to_h['HTTP_X_GITHUB_EVENT'] @params = request.params + @project = project end def perform @@ -25,14 +26,15 @@ def perform private def init_vars! - @project = @github.project + @project ||= @github.project @project_users = @project.project_users if @params[:payload] @params = JSON.parse(@params[:payload]).deep_symbolize_keys @action = @params[:action] if @params[:action] end GithubLogger.debug( - github_id: @github.id, + github_id: @github&.id, + project_id: @project.id, event: @event, action: @action, params: @params.to_json diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index 1f1cd6d3..33abb482 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -3,7 +3,7 @@ class WebhooksController < BaseController before_action :find_github def webhook_data - @mentions = Github::ReceiveCallbacksContext.new(@github, request: request).perform + @mentions = Github::ReceiveCallbacksContext.new(@github, request: request, project: @project).perform render json: { mentions: @mentions } end @@ -11,6 +11,7 @@ def webhook_data def find_github @github = Github.find_by(webhook_token: params[:token]) - render json: { error: 'token not found' }, status: :not_found unless @github + @project = Project.all.select { |project| project.github_token == params[:token] }.first + render json: { error: 'token not found' }, status: :not_found unless @github || @project end end diff --git a/app/models/project.rb b/app/models/project.rb index db95695c..4c644848 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -26,6 +26,9 @@ class Project < ApplicationRecord :github_slack_users_mapping_json validates :name, :owner_id, presence: true + before_save do + self.github_token = github_token || Digest::MD5.hexdigest(id) unless new_record? + end def has_user?(user) project_users.map(&:user_id).include?(user.id) @@ -47,6 +50,15 @@ def approached_hours_limit super == 'true' end + def github_token + (data || {})['github_token'] + end + + def github_token=(value) + self.data ||= {} + self.data['github_token'] = value + end + def primary_slack_channel return if primary_slack_channel_id.blank? diff --git a/app/views/githubs/_update_token.html.slim b/app/views/githubs/_update_token.html.slim index a5efae4a..ac7ad9dc 100644 --- a/app/views/githubs/_update_token.html.slim +++ b/app/views/githubs/_update_token.html.slim @@ -1 +1 @@ -= link_to "Update Token Permisssion", auth_github_path(scope: "user,user:email,repo,admin:repo_hook", origin: current_url), class: "btn btn-danger" unless validates_current_github_token_for_webhook += link_to "Update Token Permisssion", auth_github_path(scope: "user,user:email,repo,admin:repo_hook", origin: current_url), class: "btn btn-danger", method: :post unless validates_current_github_token_for_webhook diff --git a/app/views/githubs/index.html.slim b/app/views/githubs/index.html.slim index 40dc1de9..a5ad6ac2 100644 --- a/app/views/githubs/index.html.slim +++ b/app/views/githubs/index.html.slim @@ -4,6 +4,9 @@ br/ = render partial: "update_token" +| 專案 HookUrl: +input type="text" value="#{@project.github_token}" + table.table.table-bordered.table-striped thead tr From 4748fe2b3baa0eb96ce697d025bcb9217b81189f Mon Sep 17 00:00:00 2001 From: marsz Date: Wed, 5 Jan 2022 15:07:35 +0800 Subject: [PATCH 9/9] fixup --- app/models/project.rb | 2 +- app/views/githubs/index.html.slim | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 4c644848..6277a5ed 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -27,7 +27,7 @@ class Project < ApplicationRecord validates :name, :owner_id, presence: true before_save do - self.github_token = github_token || Digest::MD5.hexdigest(id) unless new_record? + self.github_token = github_token || Digest::MD5.hexdigest("project-#{id}") unless new_record? end def has_user?(user) diff --git a/app/views/githubs/index.html.slim b/app/views/githubs/index.html.slim index a5ad6ac2..925615e0 100644 --- a/app/views/githubs/index.html.slim +++ b/app/views/githubs/index.html.slim @@ -4,8 +4,10 @@ br/ = render partial: "update_token" +hr/ | 專案 HookUrl: -input type="text" value="#{@project.github_token}" +input type="text" value="https://#{Setting.host}/webhooks/#{@project.github_token}" +hr/ table.table.table-bordered.table-striped thead