diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-02-03 00:51:03 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-02-03 00:51:03 +0300 |
commit | 648826721f13ee4309a11638e538d96006648b39 (patch) | |
tree | 9e2cb1b728208671c4d653d32223a02d19f3fe82 | |
parent | 838cc0907c963a025553d639283b3bbf8140dae8 (diff) |
Rename Callout to UserCallout
-rw-r--r-- | app/controllers/user_callouts_controller.rb (renamed from app/controllers/callouts_controller.rb) | 2 | ||||
-rw-r--r-- | app/helpers/user_callouts_helper.rb (renamed from app/helpers/callouts_helper.rb) | 2 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/models/user_callout.rb (renamed from app/models/callout.rb) | 2 | ||||
-rw-r--r-- | config/routes.rb | 4 | ||||
-rw-r--r-- | db/migrate/20180125214301_create_user_callouts.rb (renamed from db/migrate/20180125214301_create_callouts.rb) | 6 | ||||
-rw-r--r-- | db/schema.rb | 20 | ||||
-rw-r--r-- | spec/controllers/user_callouts_controller_spec.rb (renamed from spec/controllers/callouts_controller_spec.rb) | 6 | ||||
-rw-r--r-- | spec/factories/user_callouts.rb (renamed from spec/factories/callouts.rb) | 2 | ||||
-rw-r--r-- | spec/helpers/user_callouts_helper_spec.rb (renamed from spec/helpers/callouts_helper_spec.rb) | 2 | ||||
-rw-r--r-- | spec/models/user_callout_spec.rb (renamed from spec/models/callout_spec.rb) | 4 |
11 files changed, 25 insertions, 27 deletions
diff --git a/app/controllers/callouts_controller.rb b/app/controllers/user_callouts_controller.rb index 0fffad3a927..69dc444f13a 100644 --- a/app/controllers/callouts_controller.rb +++ b/app/controllers/user_callouts_controller.rb @@ -1,4 +1,4 @@ -class CalloutsController < ApplicationController +class UserCalloutsController < ApplicationController def create if ensure_callout respond_to do |format| diff --git a/app/helpers/callouts_helper.rb b/app/helpers/user_callouts_helper.rb index 168b731ae89..3725545d4cc 100644 --- a/app/helpers/callouts_helper.rb +++ b/app/helpers/user_callouts_helper.rb @@ -1,4 +1,4 @@ -module CalloutsHelper +module UserCalloutsHelper GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze # Higher value = higher priority diff --git a/app/models/user.rb b/app/models/user.rb index b54d44fe80a..587ee71e812 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -137,7 +137,7 @@ class User < ActiveRecord::Base has_many :assigned_merge_requests, dependent: :nullify, foreign_key: :assignee_id, class_name: "MergeRequest" # rubocop:disable Cop/ActiveRecordDependent has_many :custom_attributes, class_name: 'UserCustomAttribute' - has_many :callouts + has_many :callouts, class_name: 'UserCallout' # # Validations diff --git a/app/models/callout.rb b/app/models/user_callout.rb index c8f41a39cf3..8b31aa6fa5c 100644 --- a/app/models/callout.rb +++ b/app/models/user_callout.rb @@ -1,4 +1,4 @@ -class Callout < ActiveRecord::Base +class UserCallout < ActiveRecord::Base belongs_to :user validates :user, presence: true diff --git a/config/routes.rb b/config/routes.rb index 827de9d5b40..e72ea1881cd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,8 +61,8 @@ Rails.application.routes.draw do resources :issues, module: :boards, only: [:index, :update] end - # Callouts - resources :callouts, only: [:create] + # UserCallouts + resources :user_callouts, only: [:create] end # Koding route diff --git a/db/migrate/20180125214301_create_callouts.rb b/db/migrate/20180125214301_create_user_callouts.rb index bce3d808efd..945f4181274 100644 --- a/db/migrate/20180125214301_create_callouts.rb +++ b/db/migrate/20180125214301_create_user_callouts.rb @@ -1,16 +1,16 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -class CreateCallouts < ActiveRecord::Migration +class CreateUserCallouts < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false def change - create_table :callouts do |t| + create_table :user_callouts do |t| t.string :feature_name, null: false t.references :user, index: true, foreign_key: { on_delete: :cascade }, null: false end - add_index :callouts, [:user_id, :feature_name], unique: true + add_index :user_callouts, [:user_id, :feature_name], unique: true end end diff --git a/db/schema.rb b/db/schema.rb index 1b837db4e8d..46e4b6d2188 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -203,16 +203,6 @@ ActiveRecord::Schema.define(version: 20180125214301) do add_index "broadcast_messages", ["starts_at", "ends_at", "id"], name: "index_broadcast_messages_on_starts_at_and_ends_at_and_id", using: :btree - create_table "callouts", force: :cascade do |t| - t.string "feature_name", null: false - t.integer "user_id", null: false - t.datetime_with_timezone "created_at", null: false - t.datetime_with_timezone "updated_at", null: false - end - - add_index "callouts", ["user_id", "feature_name"], name: "index_callouts_on_user_id_and_feature_name", unique: true, using: :btree - add_index "callouts", ["user_id"], name: "index_callouts_on_user_id", using: :btree - create_table "chat_names", force: :cascade do |t| t.integer "user_id", null: false t.integer "service_id", null: false @@ -1779,6 +1769,14 @@ ActiveRecord::Schema.define(version: 20180125214301) do add_index "user_agent_details", ["subject_id", "subject_type"], name: "index_user_agent_details_on_subject_id_and_subject_type", using: :btree + create_table "user_callouts", force: :cascade do |t| + t.string "feature_name", null: false + t.integer "user_id", null: false + end + + add_index "user_callouts", ["user_id", "feature_name"], name: "index_user_callouts_on_user_id_and_feature_name", unique: true, using: :btree + add_index "user_callouts", ["user_id"], name: "index_user_callouts_on_user_id", using: :btree + create_table "user_custom_attributes", force: :cascade do |t| t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false @@ -1934,7 +1932,6 @@ ActiveRecord::Schema.define(version: 20180125214301) do add_index "web_hooks", ["type"], name: "index_web_hooks_on_type", using: :btree add_foreign_key "boards", "projects", name: "fk_f15266b5f9", on_delete: :cascade - add_foreign_key "callouts", "users", on_delete: :cascade add_foreign_key "chat_teams", "namespaces", on_delete: :cascade add_foreign_key "ci_build_trace_section_names", "projects", on_delete: :cascade add_foreign_key "ci_build_trace_sections", "ci_build_trace_section_names", column: "section_name_id", name: "fk_264e112c66", on_delete: :cascade @@ -2051,6 +2048,7 @@ ActiveRecord::Schema.define(version: 20180125214301) do add_foreign_key "todos", "projects", name: "fk_45054f9c45", on_delete: :cascade add_foreign_key "trending_projects", "projects", on_delete: :cascade add_foreign_key "u2f_registrations", "users" + add_foreign_key "user_callouts", "users", on_delete: :cascade add_foreign_key "user_custom_attributes", "users", on_delete: :cascade add_foreign_key "user_synced_attributes_metadata", "users", on_delete: :cascade add_foreign_key "users_star_projects", "projects", name: "fk_22cd27ddfc", on_delete: :cascade diff --git a/spec/controllers/callouts_controller_spec.rb b/spec/controllers/user_callouts_controller_spec.rb index d4879832ef3..ac295aa72bb 100644 --- a/spec/controllers/callouts_controller_spec.rb +++ b/spec/controllers/user_callouts_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CalloutsController do +describe UserCalloutsController do let(:user) { create(:user) } before do @@ -12,7 +12,7 @@ describe CalloutsController do context 'when callout entry does not exist' do it 'should create a callout entry with dismissed state' do - expect { subject }.to change { Callout.count }.by(1) + expect { subject }.to change { UserCallout.count }.by(1) end it 'should return success' do @@ -23,7 +23,7 @@ describe CalloutsController do end context 'when callout entry already exists' do - let!(:callout) { create(:callout, feature_name: 'feature_name', user: user) } + let!(:callout) { create(:user_callout, feature_name: 'feature_name', user: user) } it 'should return success' do subject diff --git a/spec/factories/callouts.rb b/spec/factories/user_callouts.rb index f28df49b00a..ae83d65da2e 100644 --- a/spec/factories/callouts.rb +++ b/spec/factories/user_callouts.rb @@ -1,5 +1,5 @@ FactoryBot.define do - factory :callout do + factory :user_callout do feature_name 'test_callout' user diff --git a/spec/helpers/callouts_helper_spec.rb b/spec/helpers/user_callouts_helper_spec.rb index d0a5addc231..42c2e7827b2 100644 --- a/spec/helpers/callouts_helper_spec.rb +++ b/spec/helpers/user_callouts_helper_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe CalloutsHelper do +describe UserCalloutsHelper do let(:user) { create(:user) } before do diff --git a/spec/models/callout_spec.rb b/spec/models/user_callout_spec.rb index 29299678ebc..b39d12e48ac 100644 --- a/spec/models/callout_spec.rb +++ b/spec/models/user_callout_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' -describe Callout do - let!(:callout) { create(:callout) } +describe UserCallout do + let!(:callout) { create(:user_callout) } describe 'relationships' do it { is_expected.to belong_to(:user) } |