repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
rajat2502/WikiEduDashboard | spec/features/term_recap_emails_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe 'term recap emails page', type: :feature do
let(:admin) { create(:admin, email: '<EMAIL>') }
let(:course) { create(:course, article_count: 2) }
let(:active_course) do
create(:course, slug: 'active', article_count: 10, user_count: 1, character_sum... |
rajat2502/WikiEduDashboard | lib/importers/article_importer.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/replica"
#= Imports articles from Wikipedia into the dashboard database
class ArticleImporter
def initialize(wiki)
@wiki = wiki
@articles = []
end
def import_articles(ids)
article_ids = ids.map { |id| { 'mw_page_id' => id } }
a... |
rajat2502/WikiEduDashboard | app/views/courses/_blocks.json.jbuilder | <filename>app/views/courses/_blocks.json.jbuilder
# frozen_string_literal: true
user ||= current_user
json.blocks blocks.each do |block|
json.partial! 'courses/block', block: block, course: course, user: user
end
|
rajat2502/WikiEduDashboard | spec/lib/tickets/ticket_notification_emails_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/tickets/ticket_notification_emails"
describe TicketNotificationEmails do
let(:owner) { create(:admin, email: '<EMAIL>') }
let(:course) { create(:course) }
let(:ticket) do
TicketDispenser::Dispenser.call(content: 'Help!',
... |
rajat2502/WikiEduDashboard | spec/lib/duplicate_article_deleter_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/duplicate_article_deleter"
describe DuplicateArticleDeleter do
describe '.resolve_duplicates' do
let(:en_wiki) { Wiki.get_or_create(language: 'en', project: 'wikipedia') }
let(:deleted_article) do
create(:article, title: '... |
rajat2502/WikiEduDashboard | spec/features/assigned_exercise_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe 'students with assigned exercise modules', type: :feature, js: true do
let(:student) { create(:user) }
let(:course) { create(:course, weekdays: '1111111') }
let(:week) { create(:week, course: course) }
let(:evaluate_exercise_id) { 34 }
let(:prese... |
rajat2502/WikiEduDashboard | spec/models/basic_course_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe BasicCourse do
let(:flags) { nil }
let(:subject) { create(:basic_course, flags: flags) }
describe '#assignment_edits_enabled?' do
it 'should return true by default' do
expect(subject.assignment_edits_enabled?).to eq(true)
end
cont... |
rajat2502/WikiEduDashboard | lib/analytics/campaign_csv_builder.rb | # frozen_string_literal: true
require 'csv'
require_dependency "#{Rails.root}/lib/analytics/course_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_articles_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_revisions_csv_builder"
class CampaignCsvBuilder
def initialize(campaign)... |
rajat2502/WikiEduDashboard | spec/lib/data_cycle/daily_update_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/data_cycle/daily_update"
describe DailyUpdate do
before do
course = create(:course, start: '2015-03-20', end: 1.month.from_now,
flags: { salesforce_id: 'a0f1a9063a1Wyad' })
course.campaigns << Campai... |
rajat2502/WikiEduDashboard | app/models/training_module.rb | # frozen_string_literal: true
# == Schema Information
#
# Table name: training_modules
#
# id :bigint not null, primary key
# name :string(255)
# estimated_ttc :string(255)
# wiki_page :string(255)
# slug :string(255)
# slide_slugs :text(65535)
# description :text(6... |
rajat2502/WikiEduDashboard | app/controllers/articles_controller.rb | # frozen_string_literal: true
class ArticlesController < ApplicationController
respond_to :json
before_action :set_course, except: :article_data
# returns revision score data for vega graphs
def article_data
@article = Article.find(params[:article_id])
end
# returns details about how an article chang... |
rajat2502/WikiEduDashboard | lib/alerts/unsubmitted_course_alert_manager.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
class UnsubmittedCourseAlertManager
def create_alerts
unsubmitted_recently_started_courses.each do |course|
next if Alert.exists?(course_id: course.id,
type: 'UnsubmittedCourseAlert')
alert = Alert.create(... |
rajat2502/WikiEduDashboard | lib/importers/category_importer.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
require_dependency "#{Rails.root}/lib/replica"
require_dependency "#{Rails.root}/lib/importers/revision_score_importer"
require_dependency "#{Rails.root}/lib/importers/article_importer"
require_dependency "#{Rails.root}/lib/importers/average_views_impo... |
rajat2502/WikiEduDashboard | spec/mailers/previews/course_approval_mailer_preview.rb | # frozen_string_literal: true
class CourseApprovalMailerPreview < ActionMailer::Preview
def returning_instructor_approval
CourseApprovalMailer.email(example_returning_course, example_user)
end
def new_instructor_approval
CourseApprovalMailer.email(example_course, example_user)
end
private
def ex... |
rajat2502/WikiEduDashboard | db/migrate/20191015181443_add_flags_to_training_modules_users.rb | class AddFlagsToTrainingModulesUsers < ActiveRecord::Migration[6.0]
def change
add_column :training_modules_users, :flags, :text
end
end
|
rajat2502/WikiEduDashboard | lib/errors/rescue_development_errors.rb | <gh_stars>1-10
# frozen_string_literal: true
# Extra error handling for the development environment
module Errors
module RescueDevelopmentErrors
def self.included(base)
rescue_from_rev_manifest(base)
rescue_from_no_campaigns(base)
end
REV_MANIFEST_EXPLANATION =
'<p>This error occurs wh... |
rajat2502/WikiEduDashboard | lib/training/training_base.rb | <filename>lib/training/training_base.rb
# frozen_string_literal: true
require_dependency "#{Rails.root}/lib/training/yaml_training_loader"
require_dependency "#{Rails.root}/lib/training/wiki_training_loader"
class TrainingBase
# cattr_accessor would be cause children's implementations to conflict w/each other
cla... |
rajat2502/WikiEduDashboard | spec/controllers/revision_feedback_controller_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe RevisionFeedbackController, type: :request do
describe '#index' do
let!(:course) { create(:course, id: 1) }
let(:assignment) { create(:assignment, id: 1, course_id: course.id) }
let(:params) { { 'title': 'Quantum_Chemistry', 'assignment_id': ... |
rajat2502/WikiEduDashboard | spec/lib/ores_api_spec.rb | <filename>spec/lib/ores_api_spec.rb
# frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/ores_api"
describe OresApi do
context 'when the wiki is not a wikipedia or wikidata' do
before { stub_wiki_validation }
let!(:wiki) { create(:wiki, project: 'wikivoyage', language: 'en') }
... |
rajat2502/WikiEduDashboard | spec/features/feedback_form_spec.rb | <reponame>rajat2502/WikiEduDashboard<filename>spec/features/feedback_form_spec.rb
# frozen_string_literal: true
require 'rails_helper'
describe 'feedback form' do
before { TrainingModule.load_all }
let(:slide_with_feedback_link) do
'/training/instructors/new-instructor-orientation/new-instructor-orientation-... |
rajat2502/WikiEduDashboard | spec/features/settings_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe 'settings', type: :feature, js: true do
let(:super_admin) { create(:super_admin) }
let(:user) { create(:user) }
let(:special_user) { create(:user, username: 'specialuser') }
before do
login_as(super_admin, scope: :user)
SpecialUsers.set_us... |
rajat2502/WikiEduDashboard | lib/analytics/course_students_csv_builder.rb | # frozen_string_literal: true
require 'csv'
class CourseStudentsCsvBuilder
def initialize(course)
@course = course
end
def generate_csv
csv_data = [CSV_HEADERS]
courses_users.each do |courses_user|
csv_data << row(courses_user)
end
CSV.generate { |csv| csv_data.each { |line| csv << li... |
rajat2502/WikiEduDashboard | app/workers/daily_update/import_ratings_worker.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/importers/rating_importer"
class ImportRatingsWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed
def perform
RatingImporter.update_all_ratings
end
end
|
rajat2502/WikiEduDashboard | spec/controllers/blocks_controller_spec.rb | <filename>spec/controllers/blocks_controller_spec.rb<gh_stars>100-1000
# frozen_string_literal: true
require 'rails_helper'
describe BlocksController, type: :request do
describe '#destroy' do
let!(:block) { create(:block) }
let(:admin) { create(:admin, id: 2) }
before do
allow_any_instance_of(App... |
rajat2502/WikiEduDashboard | docs/analytics_scripts/ticket_open_time.rb | <gh_stars>1-10
CSV.open("/home/sage/ticket_status.csv", 'wb') do |csv|
csv << ['opened', 'updated', 'time_difference', 'status', 'message_count', 'owner']
TicketDispenser::Ticket.all.includes(:owner).each do |ticket|
csv << [ticket.created_at, ticket.updated_at, ticket.updated_at - ticket.created_at, ticket.sta... |
rajat2502/WikiEduDashboard | spec/controllers/weeks_controller_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe WeeksController, type: :request do
describe '#destroy' do
let!(:week) { create(:week) }
let(:admin) { create(:admin, id: 2) }
before do
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(admin)
end
... |
rajat2502/WikiEduDashboard | app/models/wiki_content/revision.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
# == Schema Information
#
# Table name: revisions
#
# id :integer not null, primary key
# characters :integer default(0)
# created_at :datetime
# updated_at :datetime
# user_id :integer
# article_id... |
rajat2502/WikiEduDashboard | app/workers/daily_update/salesforce_sync_worker.rb | # frozen_string_literal: true
class SalesforceSyncWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed
def perform
Course.current.each do |course|
next unless course.flags[:salesforce_id]
next unless course.approved?
PushCourseToSalesforce.new(course)
end
Classroo... |
rajat2502/WikiEduDashboard | spec/models/assignment_spec.rb | # frozen_string_literal: true
# == Schema Information
#
# Table name: assignments
#
# id :integer not null, primary key
# created_at :datetime
# updated_at :datetime
# user_id :integer
# course_id :integer
# article_id :integer
# article_title :string(255)
# role ... |
rajat2502/WikiEduDashboard | lib/wiki_response.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/app/workers/blocked_edits_worker"
#= Reports message to Sentry about the success or failure of wiki edits
class WikiResponse
###############
# Entry point #
###############
def self.capture(response_data, opts)
message = new(response_data, opt... |
rajat2502/WikiEduDashboard | spec/lib/analytics/course_articles_csv_builder_spec.rb | <filename>spec/lib/analytics/course_articles_csv_builder_spec.rb
# frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/analytics/course_articles_csv_builder"
describe CourseArticlesCsvBuilder do
let(:course) { create(:course) }
let(:user) { create(:user, registered_at: course.start + 1.m... |
rajat2502/WikiEduDashboard | lib/data_cycle/daily_update.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/app/workers/daily_update/update_users_worker"
require_dependency "#{Rails.root}/app/workers/daily_update/update_commons_uploads_worker"
require_dependency "#{Rails.root}/app/workers/daily_update/find_assignments_worker"
require_dependency "#{Rails.root}/a... |
rajat2502/WikiEduDashboard | app/mailers/ticket_notification_mailer.rb | # frozen_string_literal: true
class TicketNotificationMailer < ApplicationMailer
add_template_helper(TicketsHelper)
def self.notify_of_message(opts)
return unless Features.email?
notify(opts).deliver_now
end
def self.notify_of_open_tickets(opts)
return unless Features.email?
open_tickets_noti... |
rajat2502/WikiEduDashboard | spec/services/update_course_stats_spec.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
require 'rails_helper'
describe UpdateCourseStats do
let(:course) { create(:course, flags: flags) }
let(:subject) { described_class.new(course) }
context 'when debugging is not enabled' do
let(:flags) { nil }
it 'posts no Sentry logs' ... |
rajat2502/WikiEduDashboard | app/controllers/personal_data_controller.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
# Allows users to download the personal data bout them stored on the Dashboard
class PersonalDataController < ApplicationController
before_action :require_signed_in
respond_to :json
def show
@user = current_user
end
end
|
rajat2502/WikiEduDashboard | spec/factories/courses_wikis.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
FactoryBot.define do
factory :courses_wikis do
end
end
|
rajat2502/WikiEduDashboard | app/models/wiki_content/article.rb | <gh_stars>1-10
# frozen_string_literal: true
# == Schema Information
#
# Table name: articles
#
# id :integer not null, primary key
# title :string(255)
# updated_at :datetime
# created_at :datetime
# views_updated_at :date
# n... |
rajat2502/WikiEduDashboard | db/migrate/20181117054036_create_training_module.rb | class CreateTrainingModule < ActiveRecord::Migration[5.2]
def change
create_table :training_modules do |t|
t.string :name
t.string :estimated_ttc
t.string :wiki_page
t.string :slug, index: { unique: true }
t.text :slide_slugs, limit: 16_000
t.text :description, limit: 16_000
... |
rajat2502/WikiEduDashboard | app/models/user_data/training_modules_users.rb | <gh_stars>1-10
# frozen_string_literal: true
# == Schema Information
#
# Table name: training_modules_users
#
# id :integer not null, primary key
# user_id :integer
# training_module_id :integer
# last_slide_completed :string(255)
# completed_at :datetime
# create... |
rajat2502/WikiEduDashboard | app/controllers/explore_controller.rb | <gh_stars>1-10
# frozen_string_literal: true
#= Controller for campaign/course functionality
class ExploreController < ApplicationController
respond_to :html
def index
# 'cohort' is the old name for campaign. We accept 'cohort' as an alternative
# Redirect to new campaign overview page if a parameter is g... |
rajat2502/WikiEduDashboard | spec/lib/data_cycle/update_logger_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/data_cycle/update_logger"
describe UpdateLogger do
describe '.update_settings_record' do
it 'adds the time of the metrics last update as a value to the settings table' do
described_class.update_settings_record('start_time' => ... |
rajat2502/WikiEduDashboard | lib/analytics/course_revisions_csv_builder.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
require 'csv'
class CourseRevisionsCsvBuilder
def initialize(course)
@course = course
set_revisions
end
def generate_csv
csv_data = [CSV_HEADERS]
revisions_rows.each do |row|
csv_data << row
end
CSV.generate { |csv... |
rajat2502/WikiEduDashboard | app/models/feedback_form_response.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
# == Schema Information
#
# Table name: feedback_form_responses
#
# id :integer not null, primary key
# subject :string(255)
# body :text(65535)
# user_id :integer
# created_at :datetime
#
class FeedbackFormResponse <... |
rajat2502/WikiEduDashboard | app/services/update_course_from_salesforce.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/word_count"
#= Pulls course-related data from Salesforce
class UpdateCourseFromSalesforce
def initialize(course)
return unless Features.wiki_ed?
@course = course
@salesforce_id = @course.flags[:salesforce_id]
return unless @salesfor... |
rajat2502/WikiEduDashboard | spec/controllers/about_this_site_controller_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe AboutThisSiteController, type: :request do
describe '#private_information' do
it 'renders privacy-related info' do
get '/private_information'
expect(response.status).to eq(200)
expect(response.body).to include('Private Information')... |
rajat2502/WikiEduDashboard | app/workers/daily_update/refresh_categories_worker.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
class RefreshCategoriesWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed
def perform
Category.refresh_categories_for(Course.current)
end
end
|
rajat2502/WikiEduDashboard | app/controllers/ask_controller.rb | # frozen_string_literal: true
require 'uri'
# Controller for ask.wikiedu.org search form
class AskController < ApplicationController
ASK_ROOT = 'https://ask.wikiedu.org/questions/scope:all/sort:relevance-desc/'
def search
if params[:q].blank?
# Default to the 'student' tag
redirect_to "#{ASK_ROOT... |
rajat2502/WikiEduDashboard | db/migrate/20190606035515_add_previous_features_to_revision.rb | class AddPreviousFeaturesToRevision < ActiveRecord::Migration[5.2]
def change
add_column :revisions, :features_previous, :text
end
end
|
rajat2502/WikiEduDashboard | app/workers/daily_update/update_article_status_worker.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/article_status_manager"
class UpdateArticleStatusWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed
def perform
ArticleStatusManager.update_article_status
end
end
|
rajat2502/WikiEduDashboard | spec/features/category_scopes_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe 'Tracked categories and template', js: true do
let(:course) { create(:course, type: 'ArticleScopedProgram') }
let(:user) { create(:user) }
before do
JoinCourse.new(course: course, user: user, role: CoursesUsers::Roles::INSTRUCTOR_ROLE)
login... |
rajat2502/WikiEduDashboard | spec/models/rapidfire/question_spec.rb | <filename>spec/models/rapidfire/question_spec.rb
# frozen_string_literal: true
require 'rails_helper'
describe Rapidfire::Question do
describe 'Answer Options Validation' do
it "raises an error if answer_options aren't specified and no course data is set" do
invalid_question = build(:q_radio, answer_optio... |
rajat2502/WikiEduDashboard | db/migrate/20191004175010_add_kind_to_training_modules.rb | <gh_stars>100-1000
class AddKindToTrainingModules < ActiveRecord::Migration[6.0]
def change
add_column :training_modules, :kind, :integer, default: 0, limit: 1
end
end
|
rajat2502/WikiEduDashboard | lib/data_cycle/training_update.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/data_cycle/batch_update_logging"
# Executes all the steps of 'update_views' data import task
class TrainingUpdate
attr_reader :result
include BatchUpdateLogging
def initialize(module_slug:)
@module_slug = module_slug
setup_logger
... |
rajat2502/WikiEduDashboard | lib/wiki_userpage_output.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/wiki_output_templates"
#= Class for generating wikitext for updating a userpage
class WikiUserpageOutput
include WikiOutputTemplates
def initialize(course)
@course = course
@templates = @course.home_wiki.edit_templates
end
def enroll... |
rajat2502/WikiEduDashboard | lib/importers/assigned_article_importer.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/importers/article_importer"
class AssignedArticleImporter
def initialize(wiki)
@wiki = wiki
end
###############
# Entry point #
###############
def self.import_articles_for_assignments
assignments_missing_articles = Assignment.wh... |
rajat2502/WikiEduDashboard | app/workers/daily_update/overdue_training_alert_worker.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/alerts/overdue_training_alert_manager"
class OverdueTrainingAlertWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed
def perform
OverdueTrainingAlertManager.new(Course.strictly_current).create_alerts
end
end
|
rajat2502/WikiEduDashboard | app/services/create_requested_account.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/wiki_edits"
require_dependency "#{Rails.root}/lib/importers/user_importer"
# Processes a RequestedAccount by creating a new mediawiki account, and
# creating the User record upon success.
class CreateRequestedAccount
attr_reader :result, :user, :cr... |
rajat2502/WikiEduDashboard | spec/controllers/survey_assignments_controller_spec.rb | <gh_stars>100-1000
# frozen_string_literal: true
require 'rails_helper'
describe SurveyAssignmentsController, type: :request do
let(:admin) { create(:admin) }
let(:survey) { create(:survey) }
describe '#create' do
let(:follow_up) { 7 }
let(:send_days) { 7 }
let(:send_email) { true }
let(:c... |
rajat2502/WikiEduDashboard | spec/lib/importers/category_importer_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/importers/category_importer"
describe CategoryImporter do
let(:wiki) { Wiki.default_wiki }
let(:subject) { described_class.new(wiki).page_titles_for_category(category, depth) }
describe '.page_titles_for_category' do
context 'f... |
rajat2502/WikiEduDashboard | app/views/explore/index.json.jbuilder | <filename>app/views/explore/index.json.jbuilder
# frozen_string_literal: true
json.courses @presenter.active_courses
|
rajat2502/WikiEduDashboard | spec/features/training_translation_spec.rb | <gh_stars>1-10
# frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/data_cycle/training_update"
describe 'Training Translations', type: :feature, js: true do
let(:basque_user) { create(:user, id: 2, username: 'ibarra', locale: 'eu') }
before do
TrainingModule.destroy_all
Traini... |
rajat2502/WikiEduDashboard | spec/mailers/previews/term_recap_mailer_preview.rb | <reponame>rajat2502/WikiEduDashboard<gh_stars>100-1000
# frozen_string_literal: true
class TermRecapMailerPreview < ActionMailer::Preview
def email_to_instructors
TermRecapMailer.email(example_course, Campaign.default_campaign)
end
def basic_email_to_instructors
TermRecapMailer.basic_email(example_cours... |
rajat2502/WikiEduDashboard | spec/models/assignment_suggestion_spec.rb | <filename>spec/models/assignment_suggestion_spec.rb
# frozen_string_literal: true
# == Schema Information
#
# Table name: assignment_suggestions
#
# id :bigint(8) not null, primary key
# text :text(65535)
# assignment_id :bigint(8)
# created_at :datetime not null
# updated_at ... |
rajat2502/WikiEduDashboard | lib/course_cache_manager.rb | # frozen_string_literal: true
require_dependency "#{Rails.root}/lib/revision_stat"
require_dependency "#{Rails.root}/lib/course_training_progress_manager"
#= Service for updating the counts that are cached on Course objects
class CourseCacheManager
def initialize(course)
@course = course
end
def update_cac... |
rajat2502/WikiEduDashboard | spec/features/course_deletion_spec.rb | # frozen_string_literal: true
require 'rails_helper'
describe 'course deletion', type: :feature, js: true do
let(:course) { create(:course) }
let(:admin) { create(:admin) }
it 'destroys the course and redirects to the home page' do
login_as admin
stub_oauth_edit
visit "/courses/#{course.slug}"
... |
rajat2502/WikiEduDashboard | app/controllers/unsubmitted_courses_controller.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
class UnsubmittedCoursesController < ApplicationController
respond_to :html
def index
@unsubmitted_courses = Course.unsubmitted.order(created_at: :desc).includes(:tags, :instructors)
end
end
|
rajat2502/WikiEduDashboard | spec/controllers/application_controller_spec.rb | <reponame>rajat2502/WikiEduDashboard
# frozen_string_literal: true
require 'rails_helper'
describe ApplicationController do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
let(:super_admin) { create(:super_admin) }
let(:course) { create(:course) }
controller do
def index
head 200
... |
rajat2502/WikiEduDashboard | app/models/course_data/articles_courses.rb | <filename>app/models/course_data/articles_courses.rb<gh_stars>1-10
# frozen_string_literal: true
# == Schema Information
#
# Table name: articles_courses
#
# id :integer not null, primary key
# created_at :datetime
# updated_at :datetime
# article_id :integer
# course_id :integer
#... |
rajat2502/WikiEduDashboard | db/migrate/20190624123659_add_references_count_to_courses_users.rb | <reponame>rajat2502/WikiEduDashboard<gh_stars>100-1000
class AddReferencesCountToCoursesUsers < ActiveRecord::Migration[5.2]
def change
add_column :courses_users, :references_count, :integer, default: 0
end
end
|
rajat2502/WikiEduDashboard | app/views/alerts_list/index.json.jbuilder | # frozen_string_literal: true
json.alerts @alerts do |alert|
json.id alert.id
json.course_id alert.course_id
json.user_id alert.user_id
json.article_id alert.article_id
json.revision_id alert.revision_id
json.message alert.message
json.target_user_id alert.target_user_id
json.subject_id alert.subject_i... |
rajat2502/WikiEduDashboard | spec/services/update_course_from_salesforce_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/app/services/update_course_from_salesforce"
describe UpdateCourseFromSalesforce do
let(:course) { create(:course, flags: flags) }
let(:salesforce_id) { 'a2qQ0101015h4HF' }
let(:mock_salesforce_record) { { 'Course_Closed_Date__c' => '201... |
rajat2502/WikiEduDashboard | spec/lib/importers/revision_importer_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/importers/revision_importer"
require "#{Rails.root}/lib/articles_courses_cleaner"
describe RevisionImporter do
describe '.users_with_no_revisions' do
let(:user) { create(:user) }
let(:course_1) { create(:course, start: '20... |
rajat2502/WikiEduDashboard | app/helpers/tickets_helper.rb | <reponame>rajat2502/WikiEduDashboard<filename>app/helpers/tickets_helper.rb
# frozen_string_literal: true
#= Helpers for tickets
module TicketsHelper
def sender_for_message(message)
message.sender&.real_name || message.sender&.username || message.details[:sender_email]
end
def successful_replies_in_reverse(... |
rajat2502/WikiEduDashboard | spec/helpers/course_helper_spec.rb | <gh_stars>100-1000
# frozen_string_literal: true
require 'rails_helper'
describe CourseHelper, type: :helper do
describe '#date_highlight_class' do
it 'returns "table-row--warning" for courses ending soon' do
course = build(:course, start: 1.month.ago, end: 5.days.from_now)
expect(date_highlight_cla... |
rajat2502/WikiEduDashboard | spec/lib/wiki_userpage_output_spec.rb | # frozen_string_literal: true
require 'rails_helper'
require "#{Rails.root}/lib/wiki_userpage_output"
describe WikiUserpageOutput do
let(:enrollment_template) { described_class.new(course).enrollment_template }
let(:enrollment_summary) { described_class.new(course).enrollment_summary }
let(:enrollment_talk_temp... |
rajat2502/WikiEduDashboard | app/mailers/unsubmitted_course_alert_mailer.rb | # frozen_string_literal: true
class UnsubmittedCourseAlertMailer < ApplicationMailer
def self.send_email(alert)
return if !alert.user || alert.user.email.blank?
email(alert).deliver_now
end
def email(alert)
@instructor = alert.user
@name = @instructor.real_name || @instructor.username
@cours... |
mark-from-usds/cron | metadata.rb | name 'cron'
maintainer '<NAME>, Inc.'
maintainer_email '<EMAIL>'
license 'Apache-2.0'
description 'Installs cron'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '6.1.1'
recipe 'cron', 'Installs the cron package and starts the crond service.'
%w(ubuntu debian fedora redhat centos scie... |
mark-from-usds/cron | resources/d.rb | #
# Cookbook:: cron
# Resource:: d
#
# Copyright:: 2008-2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... |
mark-from-usds/cron | spec/unit/recipes/default_spec.rb | require 'spec_helper'
platforms = [
{
platform: 'debian',
version: '9.3',
package: 'cron',
},
{
platform: 'ubuntu',
version: '16.04',
package: 'cron',
},
{
platform: 'centos',
version: '6.9',
package: 'cronie',
},
{
platform: 'fedora',
version: '27',
packag... |
marcreynolds/spree_affiliate | app/models/spree/user_decorator.rb | Spree::User.class_eval do
has_many :affiliates, :class_name => 'Spree::Affiliate', :foreign_key => "partner_id"
has_many :referred_users, :class_name => 'Spree::User', :through => :affiliates
has_one :affiliate_partner, :class_name => "Spree::Affiliate", :foreign_key => "user_id"
def referred_by
affiliate... |
marcreynolds/spree_affiliate | app/controllers/spree/base_controller_decorator.rb | <filename>app/controllers/spree/base_controller_decorator.rb
# This should be done in core/controller_helper for controllers not inheriting from basecontroller like devise registration
Spree::BaseController.class_eval do
before_filter :remember_affiliate
private
def remember_affiliate
cookies.permanent[:ref... |
marcreynolds/spree_affiliate | app/models/spree/affiliate_event.rb | class Spree::AffiliateEvent < ActiveRecord::Base
attr_accessible :reward, :name, :user
belongs_to :affiliate, :class_name => 'Spree::Affiliate'
belongs_to :reward, :polymorphic => true
belongs_to :user, :class_name => 'Spree::User'
belongs_to :order, :class_name => 'Spree::Order'
end
|
marcreynolds/spree_affiliate | spec/support/reset_affiliate_preferences.rb | <reponame>marcreynolds/spree_affiliate
def reset_affiliate_preferences
Spree::Preferences::Store.instance.persistence = false
config = Rails.application.config.spree.affiliate_preferences
config.reset
yield(config) if block_given?
end
|
marcreynolds/spree_affiliate | app/models/spree/affiliate_reward.rb | <filename>app/models/spree/affiliate_reward.rb
module Spree
class AffiliateReward < ActiveRecord::Base
belongs_to :user, :class_name => 'Spree::User', :foreign_key => :user_id
belongs_to :original_order, :class_name => 'Spree::Order', :foreign_key => :order_id
attr_accessible :user, :order, :amount, :d... |
marcreynolds/spree_affiliate | lib/affiliate_credits.rb | <gh_stars>0
module AffiliateCredits
private
def create_affiliate_credits(sender, recipient, event, order)
# debugger
#check if sender should receive credit on affiliate register
sender_credit_amount = [SpreeAffiliate::Config["sender_credit_on_#{event}_amount".to_sym].to_f, (SpreeAffiliate::Config["send... |
marcreynolds/spree_affiliate | spec/requests/checkout_spec.rb | require 'spec_helper'
feature 'affiliate store credit feature' do
let(:sender) { Factory(:admin_user) }
let!(:address) { FactoryGirl.create(:address, :state => Spree::State.first) }
background do
PAYMENT_STATES = Spree::Payment.state_machine.states.keys unless defined? PAYMENT_STATES
SHIPMENT_STATES =... |
marcreynolds/spree_affiliate | config/routes.rb | Spree::Core::Engine.routes.prepend do
namespace :admin do
resource :affiliate_settings
end
resources :affiliates, :only => [:show, :index]
end
|
marcreynolds/spree_affiliate | config/initializers/load_configuration.rb | # module SpreeAffiliate
# Config = SpreeAffiliate::Configuration.new
# end
|
marcreynolds/spree_affiliate | app/models/spree/affiliate.rb | <reponame>marcreynolds/spree_affiliate
class Spree::Affiliate < ActiveRecord::Base
belongs_to :partner, :class_name => "Spree::User", :foreign_key => :partner_id
belongs_to :user, :class_name => 'Spree::User'
has_many :events, :class_name => "Spree::AffiliateEvent"
attr_accessible :user_id
def name
I18n... |
marcreynolds/spree_affiliate | app/models/spree/order_decorator.rb | <filename>app/models/spree/order_decorator.rb<gh_stars>0
Spree::Order.class_eval do
# has_one :affiliate_reward, :class_name => "Spree::AffiliateReward"
end |
marcreynolds/spree_affiliate | lib/spree_affiliate.rb | <gh_stars>0
require 'spree_core'
# require 'spree_auth'
require 'spree_affiliate/engine'
|
marcreynolds/spree_affiliate | db/migrate/20121023065159_create_spree_affiliate_reward.rb | class CreateSpreeAffiliateReward < ActiveRecord::Migration
def up
create_table :spree_affiliate_rewards do |t|
t.integer :user_id
t.integer :order_id
t.float :amount
t.date :date_paid_out
t.date :date_deleted
t.string :comment
end
end
def down
drop_table :spree_aff... |
marcreynolds/spree_affiliate | spree_affiliate.gemspec | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_affiliate'
s.version = '1.0.1'
s.authors = ['Rails Dog']
s.email = '<EMAIL>'
s.homepage = 'http://github.com/spree/spree_affiliate'
s.summary = 'Affiliate support for S... |
marcreynolds/spree_affiliate | app/controllers/spree/checkout_controller_decorator.rb | Spree::CheckoutController.class_eval do
include AffiliateCredits
private
def after_complete
# debugger
session[:order_id] = nil
# still should create reward if the user was a guest
sender = (current_user && current_user.affiliate_partner) || (cookies[:ref_id] && Spree::User.find_by_id(cookies[:... |
kozo2/bio-keggapi | lib/keggapi.rb | <filename>lib/keggapi.rb
require 'net/http'
module Keggapi
def self.info(database)
url = URI.parse("http://rest.kegg.jp/info/")
res = Net::HTTP.start(url.host, url.port) do |http|
sub = root + database
http.get(sub)
end
p res.body
end
end
|
JulianNicholls/Complete-Finance-Tracker | app/controllers/user/registrations_controller.rb | # Controller for user registration to allow for first and last names
class User::RegistrationsController < Devise::RegistrationsController
before_filter :configure_permitted_parameters
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up).push(:first_name, :last_name)
dev... |
JulianNicholls/Complete-Finance-Tracker | test/models/user_stock_test.rb | require 'test_helper'
# Tests for User tracked Stocks
class UserStockTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
|
JulianNicholls/Complete-Finance-Tracker | app/controllers/user_stocks_controller.rb | # Controller fur user tracked stocks
class UserStocksController < ApplicationController
# GET /user_stocks
# GET /user_stocks.json
def index
@user_stocks = UserStock.all
end
# GET /user_stocks/new
def new
@user_stock = UserStock.new
end
# POST /user_stocks
# POST /user_stocks.json
def crea... |
JulianNicholls/Complete-Finance-Tracker | test/controllers/welcome_controller_test.rb | <filename>test/controllers/welcome_controller_test.rb<gh_stars>1-10
require 'test_helper'
# Tests for home page controller
class WelcomeControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
|
JulianNicholls/Complete-Finance-Tracker | app/controllers/friendships_controller.rb | <reponame>JulianNicholls/Complete-Finance-Tracker<filename>app/controllers/friendships_controller.rb
class FriendshipsController < ApplicationController
def destroy
friend = current_user.friendships.where(friend_id: params[:id]).first
friend.destroy
respond_to do |format|
format.html { redirect_to m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.