Commit 64882672 authored by Matija Čupić's avatar Matija Čupić

Rename Callout to UserCallout

parent 838cc090
Pipeline #17016185 failed with stages
in 44 minutes and 28 seconds
class CalloutsController < ApplicationController
class UserCalloutsController < ApplicationController
def create
if ensure_callout
respond_to do |format|
......
module CalloutsHelper
module UserCalloutsHelper
GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze
# Higher value = higher priority
......
......@@ -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
......
class Callout < ActiveRecord::Base
class UserCallout < ActiveRecord::Base
belongs_to :user
validates :user, presence: true
......
......@@ -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
......
# 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
......@@ -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
......
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
......
FactoryBot.define do
factory :callout do
factory :user_callout do
feature_name 'test_callout'
user
......
require "spec_helper"
describe CalloutsHelper do
describe UserCalloutsHelper do
let(:user) { create(:user) }
before do
......
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) }
......
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