Commit 3240138a authored by Matija Čupić's avatar Matija Čupić

Rename Callout to UserCallout

parent 679ed9bc
class CalloutsController < ApplicationController class UserCalloutsController < ApplicationController
def create def create
if ensure_callout if ensure_callout
respond_to do |format| respond_to do |format|
......
module CalloutsHelper module UserCalloutsHelper
GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze
# Higher value = higher priority # Higher value = higher priority
......
...@@ -139,7 +139,7 @@ class User < ActiveRecord::Base ...@@ -139,7 +139,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 :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 :custom_attributes, class_name: 'UserCustomAttribute'
has_many :callouts has_many :callouts, class_name: 'UserCallout'
# #
# Validations # Validations
......
class Callout < ActiveRecord::Base class UserCallout < ActiveRecord::Base
belongs_to :user belongs_to :user
validates :user, presence: true validates :user, presence: true
......
...@@ -76,8 +76,8 @@ Rails.application.routes.draw do ...@@ -76,8 +76,8 @@ Rails.application.routes.draw do
resources :issues, module: :boards, only: [:index, :update] resources :issues, module: :boards, only: [:index, :update]
end end
# Callouts # UserCallouts
resources :callouts, only: [:create] resources :user_callouts, only: [:create]
end end
# Koding route # Koding route
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # 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. # Set this constant to true if this migration requires downtime.
DOWNTIME = false DOWNTIME = false
def change def change
create_table :callouts do |t| create_table :user_callouts do |t|
t.string :feature_name, null: false t.string :feature_name, null: false
t.references :user, index: true, foreign_key: { on_delete: :cascade }, null: false t.references :user, index: true, foreign_key: { on_delete: :cascade }, null: false
end end
add_index :callouts, [:user_id, :feature_name], unique: true add_index :user_callouts, [:user_id, :feature_name], unique: true
end end
end end
...@@ -278,16 +278,6 @@ ActiveRecord::Schema.define(version: 20180201101405) do ...@@ -278,16 +278,6 @@ ActiveRecord::Schema.define(version: 20180201101405) do
add_index "broadcast_messages", ["starts_at", "ends_at", "id"], name: "index_broadcast_messages_on_starts_at_and_ends_at_and_id", using: :btree 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| create_table "chat_names", force: :cascade do |t|
t.integer "user_id", null: false t.integer "user_id", null: false
t.integer "service_id", null: false t.integer "service_id", null: false
...@@ -2280,6 +2270,14 @@ ActiveRecord::Schema.define(version: 20180201101405) do ...@@ -2280,6 +2270,14 @@ ActiveRecord::Schema.define(version: 20180201101405) do
add_index "user_agent_details", ["subject_id", "subject_type"], name: "index_user_agent_details_on_subject_id_and_subject_type", using: :btree 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| create_table "user_custom_attributes", force: :cascade do |t|
t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false t.datetime_with_timezone "updated_at", null: false
...@@ -2452,7 +2450,6 @@ ActiveRecord::Schema.define(version: 20180201101405) do ...@@ -2452,7 +2450,6 @@ ActiveRecord::Schema.define(version: 20180201101405) do
add_foreign_key "board_labels", "labels", on_delete: :cascade add_foreign_key "board_labels", "labels", on_delete: :cascade
add_foreign_key "boards", "namespaces", column: "group_id", name: "fk_1e9a074a35", on_delete: :cascade add_foreign_key "boards", "namespaces", column: "group_id", name: "fk_1e9a074a35", on_delete: :cascade
add_foreign_key "boards", "projects", name: "fk_f15266b5f9", on_delete: :cascade 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 "chat_teams", "namespaces", on_delete: :cascade
add_foreign_key "ci_build_trace_section_names", "projects", 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 add_foreign_key "ci_build_trace_sections", "ci_build_trace_section_names", column: "section_name_id", name: "fk_264e112c66", on_delete: :cascade
...@@ -2614,6 +2611,7 @@ ActiveRecord::Schema.define(version: 20180201101405) do ...@@ -2614,6 +2611,7 @@ ActiveRecord::Schema.define(version: 20180201101405) do
add_foreign_key "todos", "projects", name: "fk_45054f9c45", on_delete: :cascade add_foreign_key "todos", "projects", name: "fk_45054f9c45", on_delete: :cascade
add_foreign_key "trending_projects", "projects", on_delete: :cascade add_foreign_key "trending_projects", "projects", on_delete: :cascade
add_foreign_key "u2f_registrations", "users" 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_custom_attributes", "users", on_delete: :cascade
add_foreign_key "user_synced_attributes_metadata", "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 add_foreign_key "users_star_projects", "projects", name: "fk_22cd27ddfc", on_delete: :cascade
......
require 'spec_helper' require 'spec_helper'
describe CalloutsController do describe UserCalloutsController do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
...@@ -12,7 +12,7 @@ describe CalloutsController do ...@@ -12,7 +12,7 @@ describe CalloutsController do
context 'when callout entry does not exist' do context 'when callout entry does not exist' do
it 'should create a callout entry with dismissed state' 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 end
it 'should return success' do it 'should return success' do
...@@ -23,7 +23,7 @@ describe CalloutsController do ...@@ -23,7 +23,7 @@ describe CalloutsController do
end end
context 'when callout entry already exists' do 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 it 'should return success' do
subject subject
......
FactoryBot.define do FactoryBot.define do
factory :callout do factory :user_callout do
feature_name 'test_callout' feature_name 'test_callout'
user user
......
require "spec_helper" require "spec_helper"
describe CalloutsHelper do describe UserCalloutsHelper do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'rails_helper' require 'rails_helper'
describe Callout do describe UserCallout do
let!(:callout) { create(:callout) } let!(:callout) { create(:user_callout) }
describe 'relationships' do describe 'relationships' do
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment