source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/controllers/v1/subscriptions_controller.rb | Ruby | mit | 87 | master | 212 | class V1::SubscriptionsController < V1::BaseController
def index
user = User.find params[:id]
render json: user.subscriptions.where(:created_at.gt => Date.parse("Feb 2016")).desc(:created_at)
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/controllers/v1/transactions_controller.rb | Ruby | mit | 87 | master | 221 | class V1::TransactionsController < V1::BaseController
#before_action :authenticate_user!
def index
user = User.find params[:id]
render json: user.transactions.where(hidden: false).desc(:created_at)
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/controllers/concerns/judges_actions.rb | Ruby | mit | 87 | master | 576 | module JudgesActions
def comments
@comments = @resource.comments
end
def comment
@comment = @resource.comments.build(comment_params)
@comment.user = current_user
if @comment.save
@comment = Comment.new
else
@resource.reload
end
@comments = @resource.comments
render ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/controllers/concerns/repo_pagination.rb | Ruby | mit | 87 | master | 533 | module RepoPagination
def paginate(pages_count)
@total_count = if params[:total_count].present?
params[:total_count].to_i
else
GITHUB.per_page * pages_count
end
@pagination = Kaminari.paginate_array([], total_count: @total_count)... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/controllers/concerns/gh_cache_helper.rb | Ruby | mit | 87 | master | 609 | module GhCacheHelper
private
def cache_user_repos(page)
Rails.cache.fetch("#{current_user.github_handle}/repos/#{page}", expires_in: 1.hour) do
GITHUB.repositories.list({
user: current_user.github_handle,
page: page,
sort: 'updated',
direction: 'desc'
})
end
e... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/controllers/concerns/contribution_helper.rb | Ruby | mit | 87 | master | 483 | module ContributionHelper
def contribution_data(user = current_user)
@user_commits = user.commits.group_by {|t| t.commit_date.beginning_of_month }
.sort
@xAxis = []
@commits = []
@points = []
@username = user.eql?(current_user) ? ['Your'] : ["#{user.name.titleize}'s... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/controllers/users/omniauth_callbacks_controller.rb | Ruby | mit | 87 | master | 495 | class Users::OmniauthCallbacksController < ApplicationController
before_action :authenticate_user!, except: [:github, :failure]
def github
@user = User.from_omniauth(request.env["omniauth.auth"])
#normal user sign in
sign_in :user, @user
unless @user.terms_and_conditions
redirect_to terms_a... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/helpers/repositories_helper.rb | Ruby | mit | 87 | master | 270 | module RepositoriesHelper
def repository_uri(type = :source_url)
return params[:repository][:source_url] if params[:repository].present?
end
def popular_repository_label
"Repository with minimum #{REPOSITORY_CONFIG['popular']['stars']} stars."
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/helpers/scores_helper.rb | Ruby | mit | 87 | master | 840 | module ScoresHelper
def score_color(scorable)
case scorable.scores.count
when 0
'bs-callout bs-callout-danger'
when 1
'bs-callout bs-callout-warning'
when 2
'bs-callout bs-callout-warning'
else
'bs-callout bs-callout-success'
end
end
def status_color(user)
# ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/helpers/users_helper.rb | Ruby | mit | 87 | master | 486 | module UsersHelper
def logged_in_user?
current_user == @user
end
def github_points_options
REDEEM['github_redeem_amounts'].collect do |amount|
["$#{amount}", amount]
end
end
def remove_prefix(twitter_handle)
twitter_handle[1..-1]
end
def amount_earned(user)
user.transactions.... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/helpers/home_helper.rb | Ruby | mit | 87 | master | 464 | module HomeHelper
def select_avatar(sponsorer)
if sponsorer.avatar?
sponsorer.avatar
else
avatar_url(sponsorer.user)
end
end
def redirect(sponsorer)
if sponsorer.organization_url?
sponsorer.organization_url
else
user_path(sponsorer.user.github_handle.downcase)
end... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/helpers/application_helper.rb | Ruby | mit | 87 | master | 1,475 | module ApplicationHelper
def is_active(action, contr)
return 'active' if action == params[:action] && contr == params[:controller]
end
def avatar_url(user = nil)
user = current_user if user.nil?
user.avatar_url || 'http://robohash.org/dummy?set=3&size=160x160'
end
def github_url(user = nil)
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/helpers/admin/repositories_helper.rb | Ruby | mit | 87 | master | 223 | module Admin::RepositoriesHelper
def check_boolean(str)
str == "true"
end
def child_count(id)
repos = @forks_repos_count.to_a.select{ |r| r['_id'] == id}
repos[0]['count'] unless repos.empty?
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/helpers/admin/redeem_requests_helper.rb | Ruby | mit | 87 | master | 284 | module Admin::RedeemRequestsHelper
def amount_for_store(store = nil)
redeem_requests = RedeemRequest.where(status: false)
redeem_requests = redeem_requests.where(store: store) if store and REDEEM['amazon_stores'].include?(store)
redeem_requests.sum(:amount)
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/commit.rb | Ruby | mit | 87 | master | 2,135 | class Commit
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Search
include JudgeScoringHelper
COMMIT_TYPE = {score: 'Scores', commit: 'Commits'}
attr_accessor :branch
field :message, type: String
field :commit_date, type: DateTime
field :html_url, type:... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/score.rb | Ruby | mit | 87 | master | 329 | class Score
include Mongoid::Document
include Mongoid::Timestamps
field :value, type: Integer, default: 0
field :comment, type: String
embedded_in :scorable, polymorphic: true
belongs_to :user
validates :user, :value, presence: true
validates :value, numericality: { only_integer: true, greater_than: ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/code_file.rb | Ruby | mit | 87 | master | 320 | class CodeFile
include Mongoid::Document
include Mongoid::Timestamps
field :name, type: String
field :commits_count, type: Integer, default: 0
field :bugspots_score, type: Integer, default: 0
field :branches, type: Array, default: []
belongs_to :repository
index({ name: 1 })
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/user.rb | Ruby | mit | 87 | master | 5,272 | class User
include Mongoid::Document
include Mongoid::Timestamps
include GlobalID::Identification
include UserGithubHelper
include Mongoid::Slug
ROLES = {admin: 'Admin'}
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable, :registerable
de... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/file_to_be_ignored.rb | Ruby | mit | 87 | master | 507 | class FileToBeIgnored
include Mongoid::Document
include Mongoid::Timestamps
field :name, type: String
field :programming_language, type: String
field :ignored, type: Boolean, default: false
field :count, type: Integer, default: 0
field :highest_score, type: Float, default: 0
validates :name, presence:... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/repository.rb | Ruby | mit | 87 | master | 4,972 | class Repository
include Mongoid::Document
include Mongoid::Timestamps
include GlobalID::Identification
include RepoLeaders
include Mongoid::Paranoia
field :name, type: String
field :description, type: String
field :stars, type: Integer, default: 0
field :watchers, type: Integer, ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/git_app.rb | Ruby | mit | 87 | master | 493 | class GitApp
include Mongoid::Document
@@access_token = nil
def self.access_token
@@access_token
end
def self.info
update_token
Github.new(
oauth_token: @@access_token,
client_id: ENV['GIT_APP_ID'],
client_secret: ENV['GIT_APP_SECRET']
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/budget.rb | Ruby | mit | 87 | master | 721 | class Budget
include Mongoid::Document
include Mongoid::Timestamps
field :start_date, type: Date
field :end_date, type: Date
field :day_amount, type: Float
field :amount, type: Float
field :is_all_repos, type: Boolean, default: false
field :is_deactivated, type: Boolean, default... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/redeem_request.rb | Ruby | mit | 87 | master | 2,984 | class RedeemRequest
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
include GlobalID::Identification
field :coupon_code, type: String
field :status, type: Boolean, default: false
field :points, type: Integer
field :amount, type: Float
field :retailer, ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/transaction.rb | Ruby | mit | 87 | master | 1,514 | class Transaction
include Mongoid::Document
include Mongoid::Paranoia
include Mongoid::Timestamps
TRANSACTION_TYPES = ['royalty_bonus', 'Round', 'GoalBonus', 'daily reward']
field :type, type: String
field :points , type: Integer, default: 0
field :transaction_type, type: String
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/git_fetcher.rb | Ruby | mit | 87 | master | 2,512 | class GitFetcher
include Vcs
attr_reader :repo_owner, :repo_name,
:branch_name, :from_date, :to_date
def initialize(**options)
@repo_owner = options[:repo_owner]
@repo_name = options[:repo_name]
@branch_name = options[:branch_name]
@from_date = options[:from_date]
@to_date = op... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/commit_reward.rb | Ruby | mit | 87 | master | 1,620 | class CommitReward
attr_accessor :date
def initialize(date)
@date = date
end
def calculate
set_score
repo_budget = RepoBudget.new(@date).calculate
set_reward_for_commit(repo_budget)
create_transaction
end
private
def set_score
day_commits.each do |commit|
score = 0
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/sponsor.rb | Ruby | mit | 87 | master | 314 | class Sponsor
include Mongoid::Document
field :name, type: String
field :is_individual, type: Boolean, default: false
has_many :budgets, dependent: :destroy
accepts_nested_attributes_for :budgets, allow_destroy: true
validates :name, presence: true
validates :name, uniqueness: true
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/comment.rb | Ruby | mit | 87 | master | 331 | class Comment
include Mongoid::Document
include Mongoid::Timestamps
field :content, type: String
field :is_public, type: Boolean, default: false
belongs_to :commentable, polymorphic: true
belongs_to :user
validates :content, presence: true
after_create do |c|
c.commentable.inc(comments_count: 1)... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/pull_request.rb | Ruby | mit | 87 | master | 412 | class PullRequest
include Mongoid::Document
include Mongoid::Timestamps
field :number, type: Integer
field :created_at_git, type: String
field :comment_count, type: Integer
field :author_association, type: String
field :label, type: DateTime
has_many :commits
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/concerns/repo_leaders.rb | Ruby | mit | 87 | master | 677 | module RepoLeaders
def leaders(round)
map = %Q{
function() {
emit(this.user_id, this.judges_score || this.auto_score || 0);
}
}
reduce = %Q{
function(key, values) {
return Array.sum(values);
}
}
repo_ids = Repository.or(source_gh_id: gh_id).or(gh_id... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/concerns/active_job_retries_count.rb | Ruby | mit | 87 | master | 577 | module ActiveJobRetriesCount
extend ActiveSupport::Concern
MAX_RETRY_COUNT = 5
included do
attr_accessor :retries_count
end
# define the activejob methods to increment the retry count during failed retries of a job
def initialize(*arguments)
super
@retries_count ||= 0
end
def deserialize(... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/concerns/user_github_helper.rb | Ruby | mit | 87 | master | 1,316 | module UserGithubHelper
def gh_auth_token
User.encrypter.decrypt_and_verify(auth_token)
end
def gh_client
@gh_client ||= Github.new({
oauth_token: auth_token.present? ? gh_auth_token : ENV['GIT_OAUTH_TOKEN'],
client_id: ENV['GIT_APP_ID'],
client_secret: ENV['GIT_APP_SECRET']
})
en... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/models/concerns/judge_scoring_helper.rb | Ruby | mit | 87 | master | 840 | module JudgeScoringHelper
extend ActiveSupport::Concern
included do
field :judges_score, type: Integer
end
def set_judges_avg_score
score = scores.any? ? (scores.pluck(:value).sum/scores.count.to_f).round : nil
self.set(judges_score: score)
end
def avg_score
if self.scores.any?... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/jobs/fetch_commit_job.rb | Ruby | mit | 87 | master | 1,912 | class FetchCommitJob < ApplicationJob
include Sidekiq::Status::Worker
include ActiveJobRetriesCount
queue_as :git
def perform(repo_owner: , repo_name: , branch_name: , **options)
from_date = options[:from_date].presence || Date.yesterday.beginning_of_day
to_date = options[:to_date].presence || Date.yes... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/jobs/user_repos_job.rb | Ruby | mit | 87 | master | 2,780 | class UserReposJob < ApplicationJob
include Sidekiq::Status::Worker
queue_as :git
attr_accessor :user
rescue_from(StandardError) do |exception|
Sidekiq.logger.info "**************************************Exception *******************************"
Sidekiq.logger.info "User: #{user.github_handle}"
Si... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/jobs/user_gh_repos_job.rb | Ruby | mit | 87 | master | 1,526 | class UserGhReposJob < ApplicationJob
queue_as :git
attr_accessor :user, :type
rescue_from(StandardError) do |exception|
if user
user.set(last_repo_sync_at: nil) if type == 'user'
user.set(last_org_repo_sync_at: nil) if type == 'org'
end
end
def perform(user, type)
@user = user
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/mailers/redeem_mailer.rb | Ruby | mit | 87 | master | 639 | class RedeemMailer < ApplicationMailer
default from: 'info@codecuriosity.org'
def redeem_request(request)
@user = request.user
@points = request.points
mail(to: @user.email, subject: "[CODECURIOSITY] #{@points} points redemption request")
end
def notify_admin(request)
@redeem_request = reques... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/mailers/subscription_mailer.rb | Ruby | mit | 87 | master | 959 | class SubscriptionMailer < ApplicationMailer
def subscription_email(user)
@user = user
subject_message = "Welcome to #{Date.today.strftime("%B")} challenge round of Code Curiosity"
mail(subject:"#{subject_message}")
end
def progress(user, round)
@user = user
@subscription = user.subscription... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/services/frequency_factor_calculator.rb | Ruby | mit | 87 | master | 971 | class FrequencyFactorCalculator
def initialize(commit)
@user = commit.user
@commit = commit
end
attr_reader :user, :commit
def result
1 + (weight / threshold)
end
private
def weight
[weight_sum, 0].max
end
def weight_sum
evaluation_days.collect do |date|
date.in?(number_... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/services/multi_line_chart/contribution.rb | Ruby | mit | 87 | master | 938 | class MultiLineChart::Contribution
class << self
def get
contributions = Commit.collection.aggregate([match, project, group, sort])
contributions.collect do |r|
[
"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}",
r['total']
]
end
end
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/services/multi_line_chart/user.rb | Ruby | mit | 87 | master | 913 | class MultiLineChart::User
class << self
def get
users = User.collection.aggregate([match, project, group, sort])
users.collect do |r|
[
"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}",
r['total']
]
end
end
private
def match
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | app/services/multi_line_chart/index.rb | Ruby | mit | 87 | master | 390 | class MultiLineChart::Index
def self.get
users = MultiLineChart::User.get
contributions = MultiLineChart::Contribution.get
xAxis = contributions.map(&:first)
u_trend = users.inject([]){ |acc, value| acc << acc.last.to_i + value[1].to_i }
c_trend = contributions.inject([]){ |acc, value| acc << acc... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | bin/aws.rb | Ruby | mit | 87 | master | 799 | #!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'aws.rb' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
b... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/test_helper.rb | Ruby | mit | 87 | master | 2,220 | # require "codeclimate-test-reporter"
require 'sidekiq/testing'
# CodeClimate::TestReporter.start
require 'simplecov'
ENV["RAILS_ENV"] = "test"
SimpleCov.start 'rails'
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "webmock/minitest"
requir... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/serializers/transaction_serializer_test.rb | Ruby | mit | 87 | master | 1,036 | require "test_helper"
class TransactionSerializerTest < ActiveSupport::TestCase
def setup
super
@user = create :user, auth_token: 'dah123rty'
@transaction = create(:transaction, type: 'credit', points: 500, user: @user, transaction_type: 'royalty_bonus')
@redeem_request = create(:redeem_request, poin... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/helpers/users_helper_test.rb | Ruby | mit | 87 | master | 912 | require 'test_helper'
class UsersHelperTest < ActionView::TestCase
test "show remove twitter handle prefix from twitter handle" do
twitter_handle = "@amitk301293"
assert_equal "amitk301293", remove_prefix(twitter_handle)
end
test 'must return sum amount of only debit transactions made by user' do
us... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/helpers/admin/repositories_helper_test.rb | Ruby | mit | 87 | master | 250 | require "test_helper"
class Admin::RepositoriesHelperTest < ActionView::TestCase
test "should return true of string true and vice versa" do
assert_equal check_boolean("true"), true
assert_equal check_boolean("false"), false
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/helpers/admin/redeem_requests_helper_test.rb | Ruby | mit | 87 | master | 943 | require "test_helper"
class Admin::RedeemRequestsHelperTest < ActionView::TestCase
test "check value of points if store is not provided" do
seed_data
create(:redeem_request, points: 100, user: @user)
create(:redeem_request, points: 100, user: @user, store: 'amazon.in')
create(:redeem_request, points... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/jobs/user_repos_job_test.rb | Ruby | mit | 87 | master | 4,878 | require "test_helper"
class UserReposJobTest < ActiveJob::TestCase
def setup
super
@user = create :user, github_handle: 'prasadsurase', auth_token: 'somerandomtoken'
clear_enqueued_jobs
clear_performed_jobs
assert_no_performed_jobs
assert_no_enqueued_jobs
assert @user.auth_token.present?
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/commits_controller_test.rb | Ruby | mit | 87 | master | 1,159 | require "test_helper"
describe CommitsController do
before do
user = create :user, :auth_token => 'dah123rty'
5.times.each do |i|
create :commit, user: user, commit_date: Date.today, message: "commit_#{i}"
end
sign_in user
end
def test_index
get :index
assert_response :success
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/registrations_controller_test.rb | Ruby | mit | 87 | master | 539 | require 'test_helper'
class RegistrationsControllerTest < ActionController::TestCase
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
@user = create(:user, :auth_token => 'dah123rty')
sign_in @user
end
test 'if user has not accepted terms and conditions' do
get :terms_and_condit... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/home_controller_test.rb | Ruby | mit | 87 | master | 611 | require 'test_helper'
class HomeControllerTest < ActionController::TestCase
def setup
super
@user = create :user, auth_token: 'dah123rty'
end
test 'should get index for non logged-in user' do
get :index
assert_response :success
assert_template :index
end
test 'should redirect to dashboa... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/transactions_controller_test.rb | Ruby | mit | 87 | master | 359 | require "test_helper"
class TransactionsControllerTest < ActionController::TestCase
include Devise::TestHelpers
test "must get user transactions" do
skip 'Route not defined'
user = create :user
sign_in user
xhr :get, :index, format: :js, :id => user.id
assert_response :success
assert_not_... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/users_controller_test.rb | Ruby | mit | 87 | master | 1,095 | require 'test_helper'
class UsersControllerTest < ActionController::TestCase
def setup
super
@user = create :user, auth_token: 'dah123rty'
end
test 'destroy' do
assert_equal @user.deleted?, false
sign_in @user
delete :destroy, { id: @user.id }
@user.reload
assert @user.deleted?
a... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/redeem_controller_test.rb | Ruby | mit | 87 | master | 1,616 | require "test_helper"
class RedeemControllerTest < ActionController::TestCase
def test_controller_and_action_name
seed_user
xhr :post, :create, redeem_request: {:retailer => 'github', :points => 100}, :id => @user.id
assert_equal "text/javascript", @response.content_type
assert_equal "create", @cont... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/users/omniauth_callbacks_controller_test.rb | Ruby | mit | 87 | master | 1,895 | require 'test_helper'
class Users::OmniauthCallbacksControllerTest < ActionController::TestCase
include Devise::TestHelpers
before do
OmniAuth.config.test_mode = true
@date = Date.new(2015, 10, 10)
@omniauth_hash = {
:provider => 'github',
:uid => '12345',
:info => {
:name =... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/admin/sponsors_controller_test.rb | Ruby | mit | 87 | master | 1,473 | require "test_helper"
class Admin::SponsorsControllerTest < ActionController::TestCase
def setup
role = create :role, :admin
user = create :user, auth_token: 'dah123rty'
user.roles << role
sign_in user
end
test 'show all sponsors' do
create_list(:sponsor, 5)
get :index
assert_respon... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/admin/ignored_files_controller_test.rb | Ruby | mit | 87 | master | 1,932 | require "test_helper"
class Admin::IgnoredFilesControllerTest < ActionController::TestCase
def setup
super
role = create(:role, :name => 'Admin')
@user = create(:user, :auth_token => 'dah123rty')
@user.roles << role
sign_in @user
end
test "should get ignored_files list" do
ignored_file ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/admin/redeem_requests_controller_test.rb | Ruby | mit | 87 | master | 6,977 | require "test_helper"
class Admin::RedeemRequestsControllerTest < ActionController::TestCase
test "must get users redemption requests" do
seed_data
xhr :get, :index, parameters, format: :js, :id => @user.id
assert_response :success
end
test "should not update redeem_request without any parameter" ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/admin/commits_controller_test.rb | Ruby | mit | 87 | master | 1,925 | require 'test_helper'
describe CommitsController do
before do
user = create :user, :auth_token => 'abc123'
user.name = 'user'
repository = create :repository
user.repositories << repository
5.times.each do |i|
create :commit, user: user, commit_date: Date.yesterday, message: "commit_#{i}"
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/admin/repositories_controller_test.rb | Ruby | mit | 87 | master | 3,257 | require "test_helper"
class Admin::RepositoriesControllerTest < ActionController::TestCase
def setup
role = create(:role, :name => 'Admin')
@user = create(:user, :auth_token => 'dah123rty')
@user.roles << role
sign_in @user
@repo = create(:repository, gh_id: 123439, type: 'popular')
end
tes... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/admin/users_controller_test.rb | Ruby | mit | 87 | master | 1,251 | require "test_helper"
class Admin::UsersControllerTest < ActionController::TestCase
def setup
super
@admin_role = create :role, :admin
@user = create :user, auth_token: 'dah123rty'
end
test 'should not access index if the current user is non-admin' do
sign_in @user
get :index
assert_res... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/controllers/v1/transactions_controller_test.rb | Ruby | mit | 87 | master | 1,962 | require "test_helper"
class V1::TransactionsControllerTest < ActionController::TestCase
include Devise::TestHelpers
def setup
super
@request.env['Accept'] = 'application/vnd.codecuriosity.org; version=1'
@user = create :user, auth_token: 'dah123rty'
@transaction = create(:transaction, type: 'credi... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/factories/repositories.rb | Ruby | mit | 87 | master | 782 | FactoryBot.define do
factory :repository do
name {Faker::Name.name}
ssh_url { Faker::Internet.url(host: 'github.com', path: "/#{Faker::Lorem.word}/#{Faker::Lorem.word}") }
source_url { Faker::Internet.url(host: 'github.com', path: "/#{Faker::Lorem.word}/#{Faker::Lorem.word}") }
description { Faker::Lo... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/factories/pull_requests.rb | Ruby | mit | 87 | master | 324 | FactoryBot.define do
factory :pull_request do
number {Faker::Number.number(digits: 2)}
comment_count {Faker::Number.number(digits: 2)}
author_association {"COLLABORATOR"}
label {"bug"}
created_at_git {Faker::Date.between(from: 1.month.ago, to: 2.month.ago)}
end
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/factories/users.rb | Ruby | mit | 87 | master | 673 | FactoryBot.define do
factory :user do
name {Faker::Name.name}
email { Faker::Internet.email }
password {Faker::Internet.password}
sign_in_count {Faker::Number.digit}
active {random_boolean = [true, false].sample}
is_judge {random_boolean = [true, false].sample}
github_handle {Faker::Intern... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/factories/budgets.rb | Ruby | mit | 87 | master | 211 | FactoryBot.define do
factory :budget do
start_date {Date.today}
end_date {Date.tomorrow}
amount {Faker::Number.number(digits: 4)}
is_all_repos {random_boolean = [true, false].sample}
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/comment_test.rb | Ruby | mit | 87 | master | 833 | require "test_helper"
class CommentTest < ActiveSupport::TestCase
def test_content_should_be_present
comment = build(:comment, :content => nil)
comment.valid?
assert_not_empty comment.errors[:content]
end
def test_commemt_count_should_be_zero_before_creating_any_comment
comment = build(:comment... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/pull_request_test.rb | Ruby | mit | 87 | master | 839 | require_relative "../test_helper"
class PullRequestTest < ActiveSupport::TestCase
test "number must be present" do
pull_request = build(:pull_request, number: '')
pull_request.valid?
assert_not_empty pull_request.errors[:number]
end
test "created_at_git must be present" do
pull_request = build(:... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/redeem_request_test.rb | Ruby | mit | 87 | master | 6,702 | require "test_helper"
class RedeemRequestTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
def redeem_request
@redeem_request ||= build(:redeem_request)
end
test "validity of redeem_request" do
user = create :user
redeem_request = build(:redeem_request, :points => 2, :address => 'baner... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/file_to_be_ignored_test.rb | Ruby | mit | 87 | master | 2,193 | require "test_helper"
class FileToBeIgnoredTest < ActiveSupport::TestCase
def setup
super
end
test 'file name must be present' do
file = build :file_to_be_ignored , name: nil
file.valid?
assert_not_empty file.errors[:name]
end
test 'file name is present in the ignore list' do
file_1 = ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/commit_reward_test.rb | Ruby | mit | 87 | master | 1,503 | require 'test_helper'
class CommitRewardTest < ActiveSupport::TestCase
def setup
@user = create :user, auth_token: 'abcd1234', name: 'user'
@repository1 = create :repository, :language => 'Ruby', :gh_repo_created_at => 5
@repository2 = create :repository, :language => 'Java', :gh_repo_created_at => 5
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/commit_test.rb | Ruby | mit | 87 | master | 2,559 | require 'test_helper'
class CommitTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
def setup
super
stub_get("/repos/joshsoftware/code-curiosity/commits/eb0df748bbf084ca522f5ce4ebcf508d16169b96")
.to_return(body: File.read('test/fixtures/commit.json'), status: 200,
headers: {... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/user_test.rb | Ruby | mit | 87 | master | 3,863 | require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "must save a new user with all params" do
assert_difference 'User.count' do
create(:user)
end
end
test "email address must be present" do
user = build(:user,:email => nil)
user.valid?
assert_not_empty user.errors[:emai... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/budget_test.rb | Ruby | mit | 87 | master | 692 | require "test_helper"
class BudgetTest < ActiveSupport::TestCase
test 'start date must be present' do
budget = build(:budget, start_date: '')
budget.valid?
assert_not_empty budget.errors[:start_date]
end
test 'end date must be present' do
budget = build(:budget, end_date: '')
budget.valid?
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/sponsor_test.rb | Ruby | mit | 87 | master | 414 | require "test_helper"
class SponsorTest < ActiveSupport::TestCase
test 'name must be present' do
sponsor = build(:sponsor, name: '')
sponsor.valid?
assert_not_empty sponsor.errors[:name]
end
test 'name must be unique' do
sponsor_1 = create(:sponsor, name: 'sample')
sponsor_2 = build(:sponsor... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/score_test.rb | Ruby | mit | 87 | master | 873 | require 'test_helper'
class ScoreTest < ActiveSupport::TestCase
def test_user_must_be_present
score = build :score, user: nil
score.valid?
assert_not_empty score.errors[:user]
assert_includes(score.errors[:user], "can't be blank")
end
def test_value_must_be_present
score = build :score, valu... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/git_app_test.rb | Ruby | mit | 87 | master | 861 | require "test_helper"
class GitAppTest < ActiveSupport::TestCase
GIT_INFO = YAML.load_file('config/git.yml')
def setup
@user = create :user, name: 'user'
end
def git_app
@git_app ||= GitApp.new
end
def test_valid
assert git_app.valid?
end
test 'info method should update access_token ... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/git_fetcher_test.rb | Ruby | mit | 87 | master | 2,982 | require 'test_helper'
class GitFetcherTest < ActiveSupport::TestCase
before do
options = {
repo_owner: 'pain11',
repo_name: 'Facebook'
}
@git_fetcher = GitFetcher.new(**options)
create :repository, name: 'Facebook', owner: 'pain11'
end
describe 'Commits found for given date range' do... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/transaction_test.rb | Ruby | mit | 87 | master | 2,661 | require "test_helper"
class TransactionTest < ActiveSupport::TestCase
def test_transaction_type_must_be_present
transaction = build(:transaction, :type => nil)
transaction.valid?
assert_not_empty transaction.errors[:type]
end
def test_points_must_be_present
transaction = build(:transaction, :po... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/models/repository_test.rb | Ruby | mit | 87 | master | 2,362 | require 'test_helper'
class RepositoryTest < ActiveSupport::TestCase
test "repository name must be present" do
repo = build(:repository,:name => nil)
repo.valid?
assert_not_empty repo.errors[:name]
end
test "repository source url must be present" do
repo = build(:repository,:source_url => nil)
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/mailers/redeem_mailer_test.rb | Ruby | mit | 87 | master | 1,190 | require "test_helper"
class RedeemMailerTest < ActionMailer::TestCase
include ActiveJob::TestHelper
def test_mail_is_enqueued_to_be_delivered_later
user = create(:user)
transaction = create(:transaction, :type => 'credit', :points => 20, user: user)
r = create(:redeem_request, :points => 2, user: user... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/mailers/previews/redeem_mailer_preview.rb | Ruby | mit | 87 | master | 437 | # Preview all emails at http://localhost:3000/rails/mailers/redeem_mailer
class RedeemMailerPreview < ActionMailer::Preview
def redeem_request
RedeemMailer.redeem_request(RedeemRequest.first)
end
def notify_admin
RedeemMailer.notify_admin(RedeemRequest.first)
end
def coupon_code
request = Redee... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/mailers/previews/subscription_mailer_preview.rb | Ruby | mit | 87 | master | 388 | # Preview all emails at http://localhost:3000/rails/mailers/subscription_mailer
class SubscriptionMailerPreview < ActionMailer::Preview
def progress
user = User.contestants.first
SubscriptionMailer.progress(user, Round.opened)
end
def redeem_points
user = User.contestants.first
SubscriptionMaile... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/integration/user_flow_test.rb | Ruby | mit | 87 | master | 1,293 | require "test_helper"
class UserFlowTest < ActionDispatch::IntegrationTest
before(:all) do
@user = create(:user, name: 'josh', auth_token: 'dah123rty', github_user_since: Date.today)
Warden.test_mode!
end
after(:all) do
Capybara.reset_sessions!
end
# test "user can redeem only when redemption c... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/lib/tasks/set_test.rb | Ruby | mit | 87 | master | 1,836 | require 'test_helper'
class SetTest < ActiveSupport::TestCase
setup do
CodeCuriosity::Application.load_tasks
end
test 'assign auto_score to score' do
commit = create :commit, auto_score: 2
assert_not_equal commit.score, commit.auto_score
Rake::Task['set:score'].invoke
commit.reload
as... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/lib/tasks/fetch_commits_test.rb | Ruby | mit | 87 | master | 800 | require 'test_helper'
class FetchCommitsTest < ActiveSupport::TestCase
setup do
CodeCuriosity::Application.load_tasks
end
test 'daily commits' do
VCR.use_cassette("my_commits", record: :new_episodes) do
repo = create :repository, name: 'tanya-josh', owner: 'tanya-saroha', language: 'Ruby'
au... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/lib/tasks/score_and_reward_test.rb | Ruby | mit | 87 | master | 619 | require 'test_helper'
class ScoreAndRewardTest < ActiveSupport::TestCase
setup do
CodeCuriosity::Application.load_tasks
end
def test_score_and_reward_calculations
repo = create :repository, name: 'tanya-josh', owner: 'tanya-saroha', language: 'Ruby'
user = create :user, github_handle: 'tanya-saroha... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | test/lib/tasks/repo_test.rb | Ruby | mit | 87 | master | 2,134 | require 'test_helper'
class RepoTest < ActiveSupport::TestCase
def setup
@path = "#{Rails.root.join(SCORING_ENGINE_CONFIG[:repositories]).to_s}"
CodeCuriosity::Application.load_tasks
Rake::Task['repo:delete_repository_dir'].reenable
Dir.mkdir("#{@path}") unless Dir.exists?("#{@path}")
end
=begin
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/development_mail_interceptor.rb | Ruby | mit | 87 | master | 256 | class DevelopmentMailInterceptor
def self.delivering_email(message)
message.subject = "#{message.to} #{message.subject}"
message.to = "testvx100@gmail.com"
Rails.logger.debug "Interceptor prevented sending mail #{message.inspect}!"
end
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/git_lib_ext.rb | Ruby | mit | 87 | master | 1,128 | module GitLibExt
def commit_branch(sha)
command('branch', ['--contains', sha]).sub('* ', '')
end
def commit_grep(message)
command_lines('log', ['--grep', message, '--pretty="%H - %s"'])
end
def commits_by_file(file)
command_lines('log', ['--pretty="%H - %s"', '--follow', file])
end
end
module... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/github_client.rb | Ruby | mit | 87 | master | 399 | class GithubClient
URL = 'https://github.com'
class << self
attr_accessor :client
def init(options = {})
self.client = Github.new(options)
end
def repo(owner, repo_name)
@client.repos.get(owner, repo_name)
rescue
nil
end
def repos
@client.repos.get(ownder)
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/hide_undebited_requests.rake | Ruby | mit | 87 | master | 205 | desc 'hide the redeem requests which are undebited'
task :hide_undebited_requests => :environment do
RedeemRequest.where(status: false).map(&:destroy)
Transaction.where(hidden: true).map(&:destroy)
end |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/set.rake | Ruby | mit | 87 | master | 1,678 | namespace :set do
desc "assign auto_score to score"
task score: :environment do
Commit.each do |commit|
auto_score = commit.auto_score || 0.0
commit.set(score: auto_score)
end
end
desc 'set gh_repo_created_at and language for all repos'
task repo_fields: :environment do
Repository.req... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/fetch_data.rake | Ruby | mit | 87 | master | 1,297 | namespace :fetch_data do
desc "Sync repositories for every user"
task :sync_repos => :environment do |t, args|
per_batch = 1000
# dont fetch repos of blocked users
users = User.contestants.allowed
0.step(users.count, per_batch) do |offset|
users.limit(per_batch).skip(offset).each do |user|
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/fix_august_budget.rake | Ruby | mit | 87 | master | 360 | desc 'fix budget for august 1 and 2'
task :fix_august_budget => :environment do
budget = Budget.new
budget.start_date = Date.new(2018, 8, 1)
budget.end_date = Date.new(2018, 8, 2)
budget.sponsor_id = Sponsor.first.id
budget.amount = 20
budget.is_all_repos = true
budget.save
Rake::Task[:score_and_rewa... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/score_and_reward.rake | Ruby | mit | 87 | master | 644 | desc 'set score and reward daily'
task :score_and_reward, [:from_date, :to_date] => :environment do |t, args|
from_date = args[:from_date].present? ? args[:from_date].to_date : Date.yesterday
to_date = args[:to_date].present? ? args[:to_date].to_date : Date.yesterday
date = from_date..to_date
date.each{ |date|... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/repo.rake | Ruby | mit | 87 | master | 1,688 | require 'find'
namespace :repo do
desc "Delete the cloned repositories having size greater than SIZE_LIMIT MB"
task delete_large_repositories: :environment do
repos = Dir.entries(Rails.root.join(SCORING_ENGINE_CONFIG[:repositories]).to_s) - ['.','..']
repos.each do |repo|
total_size = 0
repo_p... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/fetch_commits.rake | Ruby | mit | 87 | master | 685 | desc "Fetch commits daily."
task :fetch_commits, [:from_date, :to_date] => :environment do |t, args|
from_date = args[:from_date].present? ? args[:from_date] : nil
to_date = args[:to_date].present? ? args[:to_date] : nil
repos = Repository.required
repos.each do |repo|
repo.branches.each do |branch|
... |
github | joshsoftware/code-curiosity | https://github.com/joshsoftware/code-curiosity | lib/tasks/notify_all.rake | Ruby | mit | 87 | master | 460 | namespace :notify_all do
desc "Send mail to all contenstants about change in Terms of Service"
task notify_contestants: :environment do
users = User.contestants.any_of({notify_monthly_points: nil}, {notify_monthly_points: true}).where(:points.gte => 85, :points.lt => 1000).pluck(:id)
User.contestants.where(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.