fix rubocop warnings
This commit is contained in:
parent
bb22e23dfb
commit
a32076abd6
5 changed files with 17 additions and 19 deletions
|
@ -26,7 +26,7 @@ class DiaryEntryController < ApplicationController
|
|||
end
|
||||
|
||||
# Subscribe user to diary comments
|
||||
@diary_entry.subscriptions.create(user: @user)
|
||||
@diary_entry.subscriptions.create(:user => @user)
|
||||
|
||||
redirect_to :controller => "diary_entry", :action => "list", :display_name => @user.display_name
|
||||
else
|
||||
|
@ -70,7 +70,7 @@ class DiaryEntryController < ApplicationController
|
|||
end
|
||||
|
||||
# Add the commenter to the subscribers if necessary
|
||||
@entry.subscriptions.create(user: @user) unless @entry.subscribers.exists?(@user.id)
|
||||
@entry.subscriptions.create(:user => @user) unless @entry.subscribers.exists?(@user.id)
|
||||
|
||||
redirect_to :controller => "diary_entry", :action => "view", :display_name => @entry.user.display_name, :id => @entry.id
|
||||
else
|
||||
|
@ -83,7 +83,7 @@ class DiaryEntryController < ApplicationController
|
|||
def subscribe
|
||||
diary_entry = DiaryEntry.find(params[:id])
|
||||
|
||||
diary_entry.subscriptions.create(user: @user) unless diary_entry.subscribers.exists?(@user.id)
|
||||
diary_entry.subscriptions.create(:user => @user) unless diary_entry.subscribers.exists?(@user.id)
|
||||
|
||||
redirect_to :controller => "diary_entry", :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
@ -93,7 +93,7 @@ class DiaryEntryController < ApplicationController
|
|||
def unsubscribe
|
||||
diary_entry = DiaryEntry.find(params[:id])
|
||||
|
||||
diary_entry.subscriptions.where(user: @user).delete_all if diary_entry.subscribers.exists?(@user.id)
|
||||
diary_entry.subscriptions.where(:user => @user).delete_all if diary_entry.subscribers.exists?(@user.id)
|
||||
|
||||
redirect_to :controller => "diary_entry", :action => "view", :display_name => diary_entry.user.display_name, :id => diary_entry.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -4,7 +4,7 @@ class DiaryEntry < ActiveRecord::Base
|
|||
|
||||
has_many :comments, -> { order(:id).preload(:user) }, :class_name => "DiaryComment"
|
||||
has_many :visible_comments, -> { joins(:user).where(:visible => true, :users => { :status => %w(active confirmed) }).order(:id) }, :class_name => "DiaryComment"
|
||||
has_many :subscriptions, :class_name => 'DiaryEntrySubscription'
|
||||
has_many :subscriptions, :class_name => "DiaryEntrySubscription"
|
||||
has_many :subscribers, :through => :subscriptions, :source => :user
|
||||
|
||||
scope :visible, -> { where(:visible => true) }
|
||||
|
|
|
@ -4,7 +4,7 @@ class User < ActiveRecord::Base
|
|||
has_many :traces, -> { where(:visible => true) }
|
||||
has_many :diary_entries, -> { order(:created_at => :desc) }
|
||||
has_many :diary_comments, -> { order(:created_at => :desc) }
|
||||
has_many :diary_entry_subscriptions, :class_name => 'DiaryEntrySubscription'
|
||||
has_many :diary_entry_subscriptions, :class_name => "DiaryEntrySubscription"
|
||||
has_many :diary_subscriptions, :through => :diary_entry_subscriptions, :source => :diary_entry
|
||||
has_many :messages, -> { where(:to_user_visible => true).order(:sent_on => :desc).preload(:sender, :recipient) }, :foreign_key => :to_user_id
|
||||
has_many :new_messages, -> { where(:to_user_visible => true, :message_read => false).order(:sent_on => :desc) }, :class_name => "Message", :foreign_key => :to_user_id
|
||||
|
|
|
@ -11,7 +11,7 @@ class AddJoinTableBetweenUsersAndDiaryEntries < ActiveRecord::Migration
|
|||
|
||||
def up
|
||||
DiaryEntry.find_each do |diary_entry|
|
||||
diary_entry.subscriptions.create(user: diary_entry.user) unless diary_entry.subscribers.exists?(@user)
|
||||
diary_entry.subscriptions.create(:user => diary_entry.user) unless diary_entry.subscribers.exists?(@user.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -667,8 +667,6 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
def test_subscribe_success
|
||||
diary_entry = create(:diary_entry, :user_id => users(:normal_user).id)
|
||||
|
||||
#basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
assert_difference "diary_entry.subscribers.count", 1 do
|
||||
post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => users(:public_user).id }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue