rubocop: Layout/AlignParameters, 708

Seriously considered renaming vote_thusly_on_story_or_comment_for_user_because
just becaues of how many weird linewraps it causes.
This commit is contained in:
Peter Bhat Harkins 2018-03-14 10:44:26 -06:00
parent a15c5d540e
commit bf4327de49
30 changed files with 160 additions and 164 deletions

View File

@ -51,8 +51,7 @@ class AvatarsController < ApplicationController
f.write av
end
File.rename("#{CACHE_DIR}/.#{u.username}-#{size}.png",
"#{CACHE_DIR}/#{u.username}-#{size}.png")
File.rename("#{CACHE_DIR}/.#{u.username}-#{size}.png", "#{CACHE_DIR}/#{u.username}-#{size}.png")
response.headers["Expires"] = 1.hour.from_now.httpdate
send_data av, :type => "image/png", :disposition => "inline"

View File

@ -4,7 +4,7 @@ class CommentsController < ApplicationController
# for rss feeds, load the user's tag filters if a token is passed
before_action :find_user_from_rss_token, :only => [:index]
before_action :require_logged_in_user_or_400,
:only => [:create, :preview, :upvote, :downvote, :unvote]
:only => [:create, :preview, :upvote, :downvote, :unvote]
# for rss feeds, load the user's tag filters if a token is passed
before_action :find_user_from_rss_token, :only => [:index]
@ -140,12 +140,13 @@ class CommentsController < ApplicationController
end
if params[:preview].blank? && comment.save
votes = Vote.comment_votes_by_user_for_comment_ids_hash(@user.id,
[comment.id])
votes = Vote.comment_votes_by_user_for_comment_ids_hash(@user.id, [comment.id])
comment.current_vote = votes[comment.id]
render :partial => "comments/comment", :layout => false,
:content_type => "text/html", :locals => { :comment => comment }
render :partial => "comments/comment",
:layout => false,
:content_type => "text/html",
:locals => { :comment => comment }
else
comment.current_vote = { :vote => 1 }
@ -158,8 +159,9 @@ class CommentsController < ApplicationController
return render :plain => "can't find comment", :status => 400
end
Vote.vote_thusly_on_story_or_comment_for_user_because(0, comment.story_id,
comment.id, @user.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(
0, comment.story_id, comment.id, @user.id, nil
)
render :plain => "ok"
end
@ -169,8 +171,9 @@ class CommentsController < ApplicationController
return render :plain => "can't find comment", :status => 400
end
Vote.vote_thusly_on_story_or_comment_for_user_because(1, comment.story_id,
comment.id, @user.id, params[:reason])
Vote.vote_thusly_on_story_or_comment_for_user_because(
1, comment.story_id, comment.id, @user.id, params[:reason]
)
render :plain => "ok"
end
@ -188,8 +191,9 @@ class CommentsController < ApplicationController
return render :plain => "not permitted to downvote", :status => 400
end
Vote.vote_thusly_on_story_or_comment_for_user_because(-1, comment.story_id,
comment.id, @user.id, params[:reason])
Vote.vote_thusly_on_story_or_comment_for_user_because(
-1, comment.story_id, comment.id, @user.id, params[:reason]
)
render :plain => "ok"
end
@ -262,8 +266,10 @@ class CommentsController < ApplicationController
@cur_url = "/threads"
end
thread_ids = @showing_user.recent_threads(20,
include_submitted_stories = !!(@user && @user.id == @showing_user.id))
thread_ids = @showing_user.recent_threads(
20,
include_submitted_stories = !!(@user && @user.id == @showing_user.id)
)
comments = Comment.where(
:thread_id => thread_ids
@ -277,8 +283,7 @@ class CommentsController < ApplicationController
@threads = comments_by_thread_id.values_at(*thread_ids).compact
if @user
@votes = Vote.comment_votes_by_user_for_story_hash(@user.id,
comments.map(&:story_id).uniq)
@votes = Vote.comment_votes_by_user_for_story_hash(@user.id, comments.map(&:story_id).uniq)
comments.each do |c|
if @votes[c.id]

View File

@ -1,7 +1,6 @@
class HatsController < ApplicationController
before_action :require_logged_in_user, :except => [:index]
before_action :require_logged_in_moderator,
:except => [:build_request, :index, :create_request]
before_action :require_logged_in_moderator, :except => [:build_request, :index, :create_request]
def build_request
@title = "Request a Hat"
@ -54,8 +53,7 @@ class HatsController < ApplicationController
def reject_request
@hat_request = HatRequest.find(params[:id])
@hat_request.reject_by_user_for_reason!(@user,
params[:hat_request][:rejection_comment])
@hat_request.reject_by_user_for_reason!(@user, params[:hat_request][:rejection_comment])
flash[:success] = "Successfully rejected hat request."

View File

@ -1,6 +1,5 @@
class InvitationsController < ApplicationController
before_action :require_logged_in_user,
:except => [:build, :create_by_request, :confirm_email]
before_action :require_logged_in_user, :except => [:build, :create_by_request, :confirm_email]
def build
if Rails.application.allow_invitation_requests?

View File

@ -95,8 +95,7 @@ class LoginController < ApplicationController
end
def reset_password
@found_user = User.where("email = ? OR username = ?", params[:email].to_s,
params[:email].to_s).first
@found_user = User.where("email = ? OR username = ?", params[:email], params[:email]).first
if !@found_user
flash.now[:error] = "Invalid e-mail address or username."

View File

@ -74,8 +74,7 @@ class SettingsController < ApplicationController
session[:totp_secret] = ROTP::Base32.random_base32
end
totp = ROTP::TOTP.new(session[:totp_secret],
:issuer => Rails.application.name)
totp = ROTP::TOTP.new(session[:totp_secret], :issuer => Rails.application.name)
totp_url = totp.provisioning_uri(@user.email)
# no option for inline svg, so just strip off leading <?xml> tag

View File

@ -1,8 +1,8 @@
class StoriesController < ApplicationController
before_action :require_logged_in_user_or_400,
:only => [:upvote, :downvote, :unvote, :hide, :unhide, :preview, :save, :unsave]
before_action :require_logged_in_user, :only => [:destroy, :create, :edit,
:fetch_url_attributes, :new, :suggest,]
:only => [:upvote, :downvote, :unvote, :hide, :unhide, :preview, :save, :unsave]
before_action :require_logged_in_user,
:only => [:destroy, :create, :edit, :fetch_url_attributes, :new, :suggest,]
before_action :verify_user_can_submit_stories, :only => [:new, :create]
before_action :find_user_story, :only => [:destroy, :edit, :undelete, :update]
before_action :find_story!, :only => [:suggest, :submit_suggestions]
@ -132,8 +132,9 @@ class StoriesController < ApplicationController
@title = @story.title
@short_url = @story.short_id_url
@comments = @story.merged_comments.includes(:user, :story, :hat,
:votes => :user).arrange_for_user(@user)
@comments = @story.merged_comments
.includes(:user, :story, :hat, :votes => :user)
.arrange_for_user(@user)
respond_to do |format|
format.html {
@ -250,8 +251,9 @@ class StoriesController < ApplicationController
return render :plain => "can't find story", :status => 400
end
Vote.vote_thusly_on_story_or_comment_for_user_because(0, story.id,
nil, @user.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(
0, story.id, nil, @user.id, nil
)
render :plain => "ok"
end
@ -261,8 +263,9 @@ class StoriesController < ApplicationController
return render :plain => "can't find story", :status => 400
end
Vote.vote_thusly_on_story_or_comment_for_user_because(1, story.id,
nil, @user.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(
1, story.id, nil, @user.id, nil
)
render :plain => "ok"
end
@ -280,8 +283,9 @@ class StoriesController < ApplicationController
return render :plain => "not permitted to downvote", :status => 400
end
Vote.vote_thusly_on_story_or_comment_for_user_because(-1, story.id,
nil, @user.id, params[:reason])
Vote.vote_thusly_on_story_or_comment_for_user_because(
-1, story.id, nil, @user.id, params[:reason]
)
render :plain => "ok"
end

View File

@ -1,6 +1,6 @@
class UsersController < ApplicationController
before_action :require_logged_in_moderator,
:only => [:enable_invitation, :disable_invitation, :ban, :unban]
:only => [:enable_invitation, :disable_invitation, :ban, :unban]
def show
@showing_user = User.where(:username => params[:username]).first!
@ -18,8 +18,7 @@ class UsersController < ApplicationController
newest_user = User.last.id
if params[:by].to_s == "karma"
content = Rails.cache.fetch("users_by_karma_#{newest_user}",
:expires_in => (60 * 60 * 24)) {
content = Rails.cache.fetch("users_by_karma_#{newest_user}", :expires_in => (60 * 60 * 24)) {
@users = User.order("karma DESC, id ASC").to_a
@user_count = @users.length
@title << " By Karma"
@ -33,8 +32,7 @@ class UsersController < ApplicationController
@title = "Moderators and Administrators"
render :action => "list"
else
content = Rails.cache.fetch("users_tree_#{newest_user}",
:expires_in => (60 * 60 * 24)) {
content = Rails.cache.fetch("users_tree_#{newest_user}", :expires_in => (60 * 60 * 24)) {
users = User.order("id DESC").to_a
@user_count = users.length
@users_by_parent = users.group_by(&:invited_by_user_id)

View File

@ -9,8 +9,11 @@ module StoriesHelper
end
if Moderation.joins(:story)
.where("stories.user_id = ? AND moderations.created_at > ?", @user.id,
5.days.ago).exists?
.where(
"stories.user_id = ? AND moderations.created_at > ?",
@user.id,
5.days.ago
).exists?
return true
end

View File

@ -1,13 +1,13 @@
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :story,
:inverse_of => :comments
:inverse_of => :comments
has_many :votes,
:dependent => :delete_all
:dependent => :delete_all
belongs_to :parent_comment,
:class_name => "Comment"
:class_name => "Comment"
has_one :moderation,
:class_name => "Moderation"
:class_name => "Moderation"
belongs_to :hat
attr_accessor :current_vote, :previewing, :indent_level
@ -17,9 +17,8 @@ class Comment < ActiveRecord::Base
self.assign_initial_confidence
self.assign_thread_id
end
after_create :record_initial_upvote, :mark_submitter,
:deliver_reply_notifications, :deliver_mention_notifications,
:log_hat_use
after_create :record_initial_upvote, :mark_submitter, :deliver_reply_notifications,
:deliver_mention_notifications, :log_hat_use
after_destroy :unassign_votes
scope :active, -> { where(:is_deleted => false, :is_moderated => false) }
@ -395,8 +394,9 @@ class Comment < ActiveRecord::Base
end
def record_initial_upvote
Vote.vote_thusly_on_story_or_comment_for_user_because(1, self.story_id,
self.id, self.user_id, nil, false)
Vote.vote_thusly_on_story_or_comment_for_user_because(
1, self.story_id, self.id, self.user_id, nil, false
)
self.story.update_comments_count!
end

View File

@ -1,7 +1,6 @@
class Hat < ActiveRecord::Base
belongs_to :user
belongs_to :granted_by_user,
:class_name => "User"
belongs_to :granted_by_user, :class_name => "User"
validates :user, :hat, :presence => true
validates :granted_by_user, :presence => true

View File

@ -7,8 +7,7 @@ class Invitation < ActiveRecord::Base
end
end
before_validation :create_code,
:on => :create
before_validation :create_code, :on => :create
def create_code
(1...10).each do |tries|

View File

@ -1,10 +1,10 @@
class Message < ActiveRecord::Base
belongs_to :recipient,
:class_name => "User",
:foreign_key => "recipient_user_id"
:class_name => "User",
:foreign_key => "recipient_user_id"
belongs_to :author,
:class_name => "User",
:foreign_key => "author_user_id"
:class_name => "User",
:foreign_key => "author_user_id"
validates_presence_of :recipient
@ -13,11 +13,9 @@ class Message < ActiveRecord::Base
validates_length_of :subject, :in => 1..100
validates_length_of :body, :maximum => (64 * 1024)
scope :unread, -> { where(:has_been_read => false,
:deleted_by_recipient => false) }
scope :unread, -> { where(:has_been_read => false, :deleted_by_recipient => false) }
before_validation :assign_short_id,
:on => :create
before_validation :assign_short_id, :on => :create
after_create :deliver_email_notifications
after_save :update_unread_counts
after_save :check_for_both_deleted

View File

@ -1,7 +1,5 @@
class Moderation < ActiveRecord::Base
belongs_to :moderator,
:class_name => "User",
:foreign_key => "moderator_user_id"
belongs_to :moderator, :class_name => "User", :foreign_key => "moderator_user_id"
belongs_to :story
belongs_to :comment
belongs_to :user

View File

@ -154,8 +154,7 @@ class Search
if user
case what
when "stories"
votes = Vote.story_votes_by_user_for_story_ids_hash(user.id,
self.results.map { |s| s.id })
votes = Vote.story_votes_by_user_for_story_ids_hash(user.id, self.results.map(&:id))
self.results.each do |r|
if votes[r.id]
@ -164,8 +163,7 @@ class Search
end
when "comments"
votes = Vote.comment_votes_by_user_for_comment_ids_hash(user.id,
self.results.map { |c| c.id })
votes = Vote.comment_votes_by_user_for_comment_ids_hash(user.id, self.results.map(&:id))
self.results.each do |r|
if votes[r.id]

View File

@ -13,8 +13,7 @@ class StoriesPaginator
def get
with_pagination_info @scope.limit(per_page + 1)
.offset((@page - 1) * per_page)
.includes(:user, :suggested_titles, :suggested_taggings,
:taggings => :tag)
.includes(:user, :suggested_titles, :suggested_taggings, :taggings => :tag)
end
private

View File

@ -1,22 +1,22 @@
class Story < ActiveRecord::Base
belongs_to :user
belongs_to :merged_into_story,
:class_name => "Story",
:foreign_key => "merged_story_id"
:class_name => "Story",
:foreign_key => "merged_story_id"
has_many :merged_stories,
:class_name => "Story",
:foreign_key => "merged_story_id"
:class_name => "Story",
:foreign_key => "merged_story_id"
has_many :taggings,
:autosave => true
:autosave => true
has_many :suggested_taggings
has_many :suggested_titles
has_many :comments,
:inverse_of => :story
:inverse_of => :story
has_many :tags, :through => :taggings
has_many :votes, -> { where(:comment_id => nil) }
has_many :voters, -> { where('votes.comment_id' => nil) },
:through => :votes,
:source => :user
:through => :votes,
:source => :user
scope :unmerged, -> { where(:merged_story_id => nil) }
@ -59,15 +59,13 @@ class Story < ActiveRecord::Base
tinyurl.com tny.im tr.im tweez.md twitthis.com u.bb u.to v.gd vzturl.com
wp.me .ws .ws x.co yep.it yourls.org zip.net }
attr_accessor :vote, :already_posted_story, :previewing, :seen_previous,
:is_hidden_by_cur_user, :is_saved_by_cur_user
attr_accessor :editor, :moderation_reason, :merge_story_short_id,
:editing_from_suggestions
attr_accessor :fetching_ip
attr_accessor :already_posted_story, :editing_from_suggestions, :editor,
:fetching_ip, :is_hidden_by_cur_user, :is_saved_by_cur_user,
:merge_story_short_id, :moderation_reason, :previewing,
:seen_previous, :vote
attr_writer :fetched_content
before_validation :assign_short_id_and_upvote,
:on => :create
before_validation :assign_short_id_and_upvote, :on => :create
before_create :assign_initial_hotness
before_save :log_moderation
before_save :fix_bogus_chars
@ -533,8 +531,7 @@ class Story < ActiveRecord::Base
end
def record_initial_upvote
Vote.vote_thusly_on_story_or_comment_for_user_because(1, self.id, nil,
self.user_id, nil, false)
Vote.vote_thusly_on_story_or_comment_for_user_because(1, self.id, nil, self.user_id, nil, false)
end
def score
@ -698,11 +695,7 @@ class Story < ActiveRecord::Base
.parameterize
.gsub(/[^a-z0-9]/, "_")
.split("_")
<<<<<<< HEAD
.reject {|z| ["", "a", "an", "and", "but", "in", "of", "or", "that", "the", "to"] .include?(z) }
=======
.reject { |z| TITLE_DROP_WORDS.include?(z) }
>>>>>>> 777001a... rubocop: Metrics/*, 805
.reject {|z| TITLE_DROP_WORDS.include?(z) }
.each do |w|
if wl + w.length <= max_len
words.push w

View File

@ -1,8 +1,6 @@
class Tag < ActiveRecord::Base
has_many :taggings,
:dependent => :delete_all
has_many :stories,
:through => :taggings
has_many :taggings, :dependent => :delete_all
has_many :stories, :through => :taggings
attr_accessor :filtered_count, :stories_count

View File

@ -1,34 +1,34 @@
class User < ActiveRecord::Base
has_many :stories,
-> { includes :user }
-> { includes :user }
has_many :comments
has_many :sent_messages,
:class_name => "Message",
:foreign_key => "author_user_id"
:class_name => "Message",
:foreign_key => "author_user_id"
has_many :received_messages,
:class_name => "Message",
:foreign_key => "recipient_user_id"
:class_name => "Message",
:foreign_key => "recipient_user_id"
has_many :tag_filters
has_many :tag_filter_tags,
:class_name => "Tag",
:through => :tag_filters,
:source => :tag,
:dependent => :delete_all
:class_name => "Tag",
:through => :tag_filters,
:source => :tag,
:dependent => :delete_all
belongs_to :invited_by_user,
:class_name => "User"
:class_name => "User"
belongs_to :banned_by_user,
:class_name => "User"
:class_name => "User"
belongs_to :disabled_invite_by_user,
:class_name => "User"
:class_name => "User"
has_many :invitations
has_many :moderations, :inverse_of => :moderator
has_many :votes
has_many :voted_stories, -> { where('votes.comment_id' => nil) },
:through => :votes,
:source => :story
:through => :votes,
:source => :story
has_many :upvoted_stories,
-> { where('votes.comment_id' => nil, 'votes.vote' => 1) },
:through => :votes,
-> { where('votes.comment_id' => nil, 'votes.vote' => 1) },
:through => :votes,
:source => :story
has_many :hats
has_many :wearable_hats, -> { where('doffed_at is null') }, :class_name => "Hat"
@ -54,15 +54,16 @@ class User < ActiveRecord::Base
s.string :twitter_username
end
validates :email, :format => { :with => /\A[^@ ]+@[^@ ]+\.[^@ ]+\Z/ },
:uniqueness => { :case_sensitive => false }
validates :email,
:format => { :with => /\A[^@ ]+@[^@ ]+\.[^@ ]+\Z/ },
:uniqueness => { :case_sensitive => false }
validates :password, :presence => true, :on => :create
VALID_USERNAME = /[A-Za-z0-9][A-Za-z0-9_-]{0,24}/
validates :username,
:format => { :with => /\A#{VALID_USERNAME}\z/ },
:uniqueness => { :case_sensitive => false }
:format => { :with => /\A#{VALID_USERNAME}\z/ },
:uniqueness => { :case_sensitive => false }
validates_each :username do |record,attr,value|
if BANNED_USERNAMES.include?(value.to_s.downcase)
@ -497,8 +498,7 @@ class User < ActiveRecord::Base
end
def update_unread_message_count!
Keystore.put("user:#{self.id}:unread_messages",
self.received_messages.unread.count)
Keystore.put("user:#{self.id}:unread_messages", self.received_messages.unread.count)
end
def unread_replies_count

View File

@ -78,8 +78,9 @@ class Vote < ActiveRecord::Base
end
end
def self.vote_thusly_on_story_or_comment_for_user_because(vote, story_id,
comment_id, user_id, reason, update_counters = true)
def self.vote_thusly_on_story_or_comment_for_user_because(
vote, story_id, comment_id, user_id, reason, update_counters = true
)
v = Vote.where(:user_id => user_id, :story_id => story_id,
:comment_id => comment_id).first_or_initialize
@ -120,8 +121,7 @@ class Vote < ActiveRecord::Base
User.update_counters c.user_id, :karma => upvote - downvote
end
c.give_upvote_or_downvote_and_recalculate_confidence!(upvote,
downvote)
c.give_upvote_or_downvote_and_recalculate_confidence!(upvote, downvote)
else
s = Story.find(v.story_id)
if s.user_id != user_id

View File

@ -1,4 +1,5 @@
# Be sure to restart your server when you modify this file.
Lobsters::Application.config.session_store :cookie_store,
key: 'lobster_trap', expire_after: 1.month
key: 'lobster_trap',
expire_after: 1.month

View File

@ -31,8 +31,8 @@ class EmailParser
def sending_user
return @sending_user if @sending_user
if (user = User.where("mailing_list_mode > 0 AND mailing_list_token = ?",
user_token).first) && user.is_active?
if (user = User.where("mailing_list_mode > 0 AND mailing_list_token = ?", user_token).first) &&
user.is_active?
@sending_user = user
return user
end

View File

@ -10,8 +10,7 @@ class Github
end
def self.oauth_consumer
OAuth::Consumer.new(self.CLIENT_ID, self.CLIENT_SECRET,
{ :site => "https://api.github.com" })
OAuth::Consumer.new(self.CLIENT_ID, self.CLIENT_SECRET, { :site => "https://api.github.com" })
end
def self.token_and_user_from_code(code)

View File

@ -96,8 +96,7 @@ class Sponge
end
end
def fetch(url, method = :get, fields = nil, raw_post_data = nil,
headers = {}, limit = 10)
def fetch(url, method = :get, fields = nil, raw_post_data = nil, headers = {}, limit = 10)
raise ArgumentError, "http redirection too deep" if limit <= 0
uri = URI.parse(url)

View File

@ -20,8 +20,7 @@ class Twitter
end
def self.oauth_consumer
OAuth::Consumer.new(self.CONSUMER_KEY, self.CONSUMER_SECRET,
{ :site => "https://api.twitter.com" })
OAuth::Consumer.new(self.CONSUMER_KEY, self.CONSUMER_SECRET, :site => "https://api.twitter.com")
end
def self.oauth_request(req, method = :get, post_data = nil)
@ -31,8 +30,7 @@ class Twitter
begin
Timeout.timeout(120) do
at = OAuth::AccessToken.new(self.oauth_consumer, self.AUTH_TOKEN,
self.AUTH_SECRET)
at = OAuth::AccessToken.new(self.oauth_consumer, self.AUTH_TOKEN, self.AUTH_SECRET)
if method == :get
res = at.get(req)
@ -56,8 +54,7 @@ class Twitter
end
def self.token_secret_and_user_from_token_and_verifier(tok, verifier)
rt = OAuth::RequestToken.from_hash(self.oauth_consumer,
{ :oauth_token => tok })
rt = OAuth::RequestToken.from_hash(self.oauth_consumer, { :oauth_token => tok })
at = rt.get_access_token({ :oauth_verifier => verifier })
res = at.get("/1.1/account/verify_credentials.json")

View File

@ -17,8 +17,12 @@ class String
return self
end
str = self.dup.force_encoding("binary").encode("utf-8",
:invalid => :replace, :undef => :replace, :replace => "?")
str = self.dup.force_encoding("binary").encode(
"utf-8",
:invalid => :replace,
:undef => :replace,
:replace => "?"
)
if !str.valid_encoding? || str.encoding.to_s != "UTF-8"
raise Encoding::UndefinedConversionError

View File

@ -134,8 +134,12 @@ Keystore.put(LAST_STORY_KEY, last_story_id)
last_comment_id = (Keystore.value_for(LAST_COMMENT_KEY) ||
Comment.last.id).to_i
Comment.where("id > ? AND (is_deleted = ? AND is_moderated = ?)",
last_comment_id, false, false).order(:id).each do |c|
Comment.where(
"id > ? AND (is_deleted = ? AND is_moderated = ?)",
last_comment_id,
false,
false
).order(:id).each do |c|
# allow some time for newer comments to be edited before sending them out
if (Time.now - (c.updated_at || c.created_at)) < 2.minutes
break

View File

@ -66,8 +66,11 @@ StoriesPaginator.new(StoryRepository.new.hottest).get.first
status = title + status
end
res = Twitter.oauth_request("/1.1/statuses/update.json", :post,
{ "status" => status })
res = Twitter.oauth_request(
"/1.1/statuses/update.json",
:post,
{ "status" => status }
)
begin
if res["id_str"].to_s.match(/\d+/)

View File

@ -62,13 +62,21 @@ to_add.each_slice(100) do |g|
#puts "adding: #{g.inspect}"
Twitter.oauth_request("/1.1/lists/members/create_all.json", :post,
{ "list_id" => list_id, "screen_name" => g.join(",") })
Twitter.oauth_request(
"/1.1/lists/members/create_all.json",
:post,
"list_id" => list_id,
"screen_name" => g.join(",")
)
end
to_del.each_slice(100) do |g|
#puts "deleting: #{g.inspect}"
Twitter.oauth_request("/1.1/lists/members/destroy_all.json", :post,
{ "list_id" => list_id, "screen_name" => g.join(",") })
Twitter.oauth_request(
"/1.1/lists/members/destroy_all.json",
:post,
"list_id" => list_id,
"screen_name" => g.join(",")
)
end

View File

@ -10,8 +10,7 @@ describe Vote do
u = User.make!
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id,
nil, u.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id, nil, u.id, nil)
s.reload
@ -25,8 +24,7 @@ describe Vote do
u = User.make!
2.times do
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id,
nil, u.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id, nil, u.id, nil)
s.reload
@ -41,8 +39,7 @@ describe Vote do
u = User.make!
Vote.vote_thusly_on_story_or_comment_for_user_because(0, s.id,
nil, u.id, "H")
Vote.vote_thusly_on_story_or_comment_for_user_because(0, s.id, nil, u.id, "H")
s.reload
expect(s.user.karma).to eq(0)
expect(s.upvotes).to eq(1)
@ -56,8 +53,7 @@ describe Vote do
u = User.make!
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id,
c.id, u.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id, c.id, u.id, nil)
c.reload
expect(c.user.karma).to eq(1)
# initial poster upvote plus new user's vote
@ -65,8 +61,9 @@ describe Vote do
expect(c.downvotes).to eq(0)
# flip vote
Vote.vote_thusly_on_story_or_comment_for_user_because(-1, s.id,
c.id, u.id, Vote::COMMENT_REASONS.keys.first)
Vote.vote_thusly_on_story_or_comment_for_user_because(
-1, s.id, c.id, u.id, Vote::COMMENT_REASONS.keys.first
)
c.reload
expect(c.user.karma).to eq(-1)
@ -80,15 +77,13 @@ describe Vote do
u = User.make!
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id,
c.id, u.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(1, s.id, c.id, u.id, nil)
c.reload
expect(c.user.karma).to eq(1)
expect(c.upvotes).to eq(2)
expect(c.downvotes).to eq(0)
Vote.vote_thusly_on_story_or_comment_for_user_because(0, s.id,
c.id, u.id, nil)
Vote.vote_thusly_on_story_or_comment_for_user_because(0, s.id, c.id, u.id, nil)
c.reload
expect(c.user.karma).to eq(0)