Skip to content

Instantly share code, notes, and snippets.

View subhashb's full-sized avatar

Subhash Bhushan subhashb

  • Team8 Solutions LLC
  • Vancouver, BC
View GitHub Profile
@subhashb
subhashb / dynamic_methods.rb
Created March 12, 2013 14:11
Defining Dynamic Method and passing model as argument
class Person
attr_accessor :firstname
attr_accessor :age
end
class Object
def metaclass
class << self; self; end
end
end
@subhashb
subhashb / test.log - devise sign_in fail case
Created June 19, 2013 07:56
test.log - devise sign_in fail case
ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
(0.2ms) BEGIN
Started GET "/users/sign_in" for 127.0.0.1 at 2013-06-19 13:23:51 +0530
Processing by Devise::SessionsController#new as HTML
Rendered devise/sessions/new.html.slim within layouts/application (69.6ms)
Rendered layouts/_header.html.slim (5.8ms)
Rendered layouts/_footer.html.slim (4.4ms)
Completed 200 OK in 235ms (Views: 177.0ms | ActiveRecord: 1.5ms)
Started POST "/users/sign_in" for 127.0.0.1 at 2013-06-19 13:23:51 +0530
Processing by Devise::SessionsController#create as HTML
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable
def full_name
([first_name, last_name] - ['']).compact.join(' ')
@subhashb
subhashb / course-access-specs.rb
Last active January 2, 2016 16:59
Course Access Specs
Courses
GET /courses/:id
when accessing an archived course
as a superadmin
responds with 403
as a publisher
responds with 403
as an admin
responds with 403
as a learner
@subhashb
subhashb / access-for-kayps-for-update.rb
Last active January 4, 2016 21:49
Access for KayPs for update API
Api::V1::AssetsController
GET /assets/:id/kayps_for_update
when called
return the Kps that use an asset
should only return a Kp once even if it uses the asset many times
should flag the KPs that use old versions of the asset
access restrictions
for a learner returns 403
for a publisher returns 200
for an admin returns 200
@subhashb
subhashb / Search-Request-Specs.rb
Created February 5, 2014 17:18
Search-Request-Specs
Api::V1::SearchController
Search for courses
returns the accessible courses to learner 3
returns the accessible courses to publisher 1
returns the accessible courses to learner 2
iknowrecommendations returns recommended courses
returns the accessible courses to publisher 2
returns the accessible courses to learner 1
correctly counts new courses for a user (PENDING: Temporarily disabled with xit)
returns courses that were updated after learner viewed them (PENDING: Temporarily disabled with xit)
@subhashb
subhashb / gist:9284773
Created March 1, 2014 03:45
Course Updated_by Specs
Courses
POST /courses
when authorized
when publisher
does not set updated_by during creation
when ghost publisher
does not set updated_by during creation
PUT /courses/:id
when authorized
sets updated_by to publisher
@subhashb
subhashb / testing-move_public_kayps
Last active August 29, 2015 13:57
Manual Tests for Rake job "move_public_kayps"
$ rake db:list_public_kayps
options: {:range=>1..5, :default_rater=>"owner"}
No public KayPs found
$ rake db:list_public_kayps
options: {:range=>1..5, :default_rater=>"owner"}
********************************************************************
0) Setting Up Wireless Gateway (52f9ccd85cdd21e9b300008c) - Status: active - Publisher: Ken Thompson (kenthecdeveloper@gmail.com)
1) Setting Up Wireless Gateway 2 (52f9ccda5cdd21e9b300009f) - Status: active - Publisher: Ken Thompson (kenthecdeveloper@gmail.com)
2) Cisco ISE - MDM Partner Integration (52f9ccdb5cdd21e9b30000b2) - Status: active - Publisher: Ken Thompson (kenthecdeveloper@gmail.com)
@subhashb
subhashb / deprecated-log
Created December 14, 2014 17:49
RSpec 3.1 Upgrade - Remaining Deprecated methods
--------------------------------------------------------------------------------
Mongoid::Matchers::Validations::HaveValidationMatcher implements a legacy RSpec matcher
protocol. For the current protocol you should expose the failure messages
via the `failure_message` and `failure_message_when_negated` methods.
(Used from /vagrant/kaybus/spec/services/courses/destroy_course_spec.rb:4:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Mongoid::Matchers::Associations::HaveAssociationMatcher implements a legacy RSpec matcher
protocol. For the current protocol you should expose the failure messages
via the `failure_message` and `failure_message_when_negated` methods.
@subhashb
subhashb / dynamic-properties.py
Last active August 27, 2020 21:22
Add properties dynamically to class
from collections import defaultdict
from enum import Enum
class ElementTypes(Enum):
PHONE = "PHONE"
CAR = "CAR"
class Registry: