gitlab-org--gitlab-foss/app/controllers/user_callouts_controller.rb

31 lines
667 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-02-02 16:51:03 -05:00
class UserCalloutsController < ApplicationController
2018-02-02 16:23:26 -05:00
def create
callout = ensure_callout
if callout.persisted?
callout.update(dismissed_at: Time.current)
2018-02-02 16:23:26 -05:00
respond_to do |format|
format.json { head :ok }
end
else
2018-02-02 16:23:26 -05:00
respond_to do |format|
format.json { head :bad_request }
end
2018-01-26 16:13:54 -05:00
end
end
private
# rubocop: disable CodeReuse/ActiveRecord
def ensure_callout
current_user.callouts.find_or_create_by(feature_name: UserCallout.feature_names[feature_name])
2018-01-26 16:13:54 -05:00
end
# rubocop: enable CodeReuse/ActiveRecord
2018-01-26 16:13:54 -05:00
def feature_name
2018-01-26 16:13:54 -05:00
params.require(:feature_name)
end
end