Add subscription controller
This commit is contained in:
20
app/controllers/subscription_controller.rb
Normal file
20
app/controllers/subscription_controller.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
class SubscriptionController < ApplicationController
|
||||||
|
|
||||||
|
def authorize!
|
||||||
|
authorize(@submission || @submissions)
|
||||||
|
end
|
||||||
|
private :authorize!
|
||||||
|
|
||||||
|
def set_subscription
|
||||||
|
@subscription = Subscription.find(params[:id])
|
||||||
|
authorize!
|
||||||
|
end
|
||||||
|
private :set_subscription
|
||||||
|
|
||||||
|
def subscription_params
|
||||||
|
current_user_id = current_user.try(:id)
|
||||||
|
current_user_class_name = current_user.try(:class).try(:name)
|
||||||
|
params[:subscription].permit(:request_for_comment, :type).merge(user_id: current_user_id, user_type: current_user_class_name)
|
||||||
|
end
|
||||||
|
private :subscription_params
|
||||||
|
end
|
7
test/controllers/subscription_controller_test.rb
Normal file
7
test/controllers/subscription_controller_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class SubscriptionControllerTest < ActionController::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Reference in New Issue
Block a user