repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/authorization/ability.rb
app/authorization/ability.rb
class Ability include CanCan::Ability def initialize(user = nil) # Define abilities for the passed in user here. For example: user ||= User.new # guest user (not logged in) if user.admin? can :manage, :all end can [:show, :index], Organization unless user.new_record? can :create, Organization can :manage, Organization do |organization| no_reviews = organization.reviews.count == 0 only_review_by_user = organization.reviews.count == 1 && organization.reviews.first.user == user no_reviews || only_review_by_user end end can [:show, :index], Review can :manage, Review, :user_id => user.id unless user.new_record? # if user.admin? # can :manage, :all # else # can :read, :all # end # # The first argument to `can` is the action you are giving the user permission to do. # If you pass :manage it will apply to every action. Other common actions here are # :read, :create, :update and :destroy. # # The second argument is the resource the user can perform the action on. If you pass # :all it will apply to every resource. Otherwise pass a Ruby class of the resource. # # The third argument is an optional hash of conditions to further filter the objects. # For example, here the user can only update published articles. # # can :update, Article, :published => true # # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/organizations_controller.rb
app/controllers/organizations_controller.rb
class OrganizationsController < ApplicationController before_filter :authenticate_user!, :except => [:index, :show] # GET /organizations # GET /organizations.json def index authorize! :index, Organization @organizations = Organization.paginate(:page => params[:page]) @organizations = @organizations.where(:category_id => params[:category]) unless params[:category].blank? @organizations = @organizations.joins(%(LEFT JOIN "cache_review_stats" ON "cache_review_stats"."organization_id" = "organizations"."id")). where(%("cache_review_stats"."condition_id" = 0 OR "cache_review_stats"."condition_id" IS NULL)). select(%("organizations".*, "cache_review_stats"."num_reviews", "cache_review_stats"."avg_review")). order(%("cache_review_stats"."avg_review" DESC NULLS LAST)). order(%("cache_review_stats"."num_reviews" DESC)) @organizations = @organizations.near(params[:zipcode], 25) unless params[:zipcode].blank? respond_to do |format| format.html # index.html.erb format.json { render json: @organizations } end end # GET /organizations/1 # GET /organizations/1.json def show @organization = Organization.find(params[:id]) authorize! :show, @organization @reviews = @organization.reviews.reverse_chronological.paginate(:page => params[:page]) @review = Review.new @review.organization = @organization @review.condition_id = 0 @title = @organization.name respond_to do |format| format.html # show.html.erb format.json { render json: @organization } end end # GET /organizations/new # GET /organizations/new.json def new @organization = Organization.new @organization.name = params[:name] @organization.url = params[:url] @organization.homepage_url = params[:homepage_url] @organization.address = params[:address] authorize! :new, @organization @title = new_action_title respond_to do |format| format.html # new.html.erb format.json { render json: @organization } end end # GET /organizations/1/edit def edit @organization = Organization.find(params[:id]) authorize! :edit, @organization @title = edit_action_title end # POST /organizations # POST /organizations.json def create @organization = Organization.new(permitted_params) authorize! :create, @organization respond_to do |format| if @organization.save format.html { redirect_to @organization, notice: 'Organization was successfully created.' } format.json { render json: @organization, status: :created, location: @organization } else format.html { existing_organization = Organization.with_url(@organization.url) if existing_organization.nil? @title = new_action_title; render action: "new" else redirect_to existing_organization, :notice => "Organization has already been submitted." end } format.json { render json: @organization.errors, status: :unprocessable_entity } end end end # PUT /organizations/1 # PUT /organizations/1.json def update @organization = Organization.find(params[:id]) authorize! :update, @organization respond_to do |format| if @organization.update_attributes(permitted_params) format.html { redirect_to @organization, notice: 'Organization was successfully updated.' } format.json { head :no_content } else format.html { @title = edit_action_title; render action: "edit" } format.json { render json: @organization.errors, status: :unprocessable_entity } end end end # DELETE /organizations/1 # DELETE /organizations/1.json def destroy @organization = Organization.find(params[:id]) authorize! :destroy, @organization @organization.destroy respond_to do |format| format.html { redirect_to organizations_url } format.json { head :no_content } end end protected def permitted_params params.require(:organization).permit(:address, :category_id, :homepage_url, :latitude, :longitude, :name, :url) end def new_action_title "Share an Organization" end def edit_action_title "Edit Organization" end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/reviews_controller.rb
app/controllers/reviews_controller.rb
class ReviewsController < ApplicationController before_filter :authenticate_user!, :except => [:index, :show] # GET /reviews # GET /reviews.json def index authorize! :index, Review @reviews = Review.paginate(:page => params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @reviews } end end # GET /reviews/1 # GET /reviews/1.json def show @review = Review.find(params[:id]) authorize! :show, @review respond_to do |format| format.html # show.html.erb format.json { render json: @review } end end # GET /reviews/new # GET /reviews/new.json def new @review = Review.new(:organization_id => params[:o_id]) @review.user = current_user authorize! :new, @review @title = new_action_title respond_to do |format| format.html # new.html.erb format.json { render json: @review } end end # GET /reviews/1/edit def edit @review = Review.find(params[:id]) authorize! :edit, @review @title = edit_action_title end # POST /reviews # POST /reviews.json def create @review = Review.new(permitted_params) @review.user = current_user authorize! :create, @review respond_to do |format| if @review.save format.html { redirect_to @review.organization || root_path, notice: 'Review was successfully created.' } format.json { render json: @review, status: :created, location: @review } else format.html { @title = new_action_title; render action: "new" } format.json { render json: @review.errors, status: :unprocessable_entity } end end end # PUT /reviews/1 # PUT /reviews/1.json def update @review = Review.find(params[:id]) authorize! :update, @review respond_to do |format| if @review.update_attributes(permitted_params) format.html { redirect_to @review.organization || @review, notice: 'Review was successfully updated.' } format.json { head :no_content } else format.html { @title = edit_action_title; render action: "edit" } format.json { render json: @review.errors, status: :unprocessable_entity } end end end # DELETE /reviews/1 # DELETE /reviews/1.json def destroy @review = Review.find(params[:id]) authorize! :destroy, @review @review.destroy respond_to do |format| format.html { redirect_to @review.organization || root_path } format.json { head :no_content } end end protected def permitted_params params.require(:review).permit(:condition_id, :content, :organization_id, :rating) end def new_action_title "New Review" end def edit_action_title "Edit Review" end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/pages_controller.rb
app/controllers/pages_controller.rb
class PagesController < ApplicationController before_filter :authenticate_user!, :only => [:favorites] skip_before_action :verify_authenticity_token, :only => [:bookmarklet] def about @title = "About" end def bookmarklet @title = "Bookmarklet" respond_to do |format| format.html format.js { service_string = params[:service].downcase rescue nil @new_window = params[:new_window] || false case service_string when "yelp" render "pages/bookmarklets/yelp_bookmarklet" else render "pages/bookmarklets/error_bookmarklet", :status => 404 end } end end def favorites @organizations = current_user.favorite_organizations.paginate(:page => params[:page]) if @organizations.count == 0 redirect_to root_path, :notice => "You haven't selected any favorites yet" end end def press @title = "Press" end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/application_controller.rb
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base before_filter :configure_permitted_parameters, if: :devise_controller? protect_from_forgery protected def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) << [:login, :username, :email] end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/relationships/organization_users_controller.rb
app/controllers/relationships/organization_users_controller.rb
class Relationships::OrganizationUsersController < ApplicationController before_filter :authenticate_user! # GET /relationships/organization_users # GET /relationships/organization_users.json def index @relationships_organization_users = Relationships::OrganizationUser.paginate(:page => params[:page]) authorize! :index, Relationships::OrganizationUser respond_to do |format| format.html # index.html.erb format.json { render json: @relationships_organization_users } end end # GET /relationships/organization_users/1 # GET /relationships/organization_users/1.json def show @relationships_organization_user = Relationships::OrganizationUser.find(params[:id]) authorize! :show, @relationships_organization_user respond_to do |format| format.html # show.html.erb format.json { render json: @relationships_organization_user } end end # GET /relationships/organization_users/new # GET /relationships/organization_users/new.json def new @relationships_organization_user = Relationships::OrganizationUser.new authorize! :new, @relationships_organization_user respond_to do |format| format.html # new.html.erb format.json { render json: @relationships_organization_user } end end # GET /relationships/organization_users/1/edit def edit @relationships_organization_user = Relationships::OrganizationUser.find(params[:id]) authorize! :edit, @relationships_organization_user end # POST /relationships/organization_users # POST /relationships/organization_users.json def create @relationships_organization_user = Relationships::OrganizationUser.new(permitted_params) authorize! :create, @relationships_organization_user respond_to do |format| if @relationships_organization_user.save format.html { redirect_to @relationships_organization_user, notice: 'Organization user was successfully created.' } format.json { render json: @relationships_organization_user, status: :created, location: @relationships_organization_user } else format.html { render action: "new" } format.json { render json: @relationships_organization_user.errors, status: :unprocessable_entity } end end end # PUT /relationships/organization_users/1 # PUT /relationships/organization_users/1.json def update @relationships_organization_user = Relationships::OrganizationUser.find(params[:id]) authorize! :update, @relationships_organization_user respond_to do |format| if @relationships_organization_user.update_attributes(permitted_params) format.html { redirect_to @relationships_organization_user, notice: 'Organization user was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @relationships_organization_user.errors, status: :unprocessable_entity } end end end # DELETE /relationships/organization_users/1 # DELETE /relationships/organization_users/1.json def destroy @relationships_organization_user = Relationships::OrganizationUser.find(params[:id]) authorize! :destroy, @relationships_organization_user @relationships_organization_user.destroy respond_to do |format| format.html { redirect_to relationships_organization_users_url } format.json { head :no_content } end end # POST /relationships/organization_users/favorite # POST /relationships/organization_users/favorite.js # POST /relationships/organization_users/favorite.json def favorite @organization = Organization.find(params[:organization_id]) @relationships_organization_user = current_user.favorite!(@organization) respond_to do |format| format.html { redirect_to @organization } format.json { render json: @relationships_organization_user, status: :created } format.js end end # DELETE /relationships/organization_users/unfavorite # DELETE /relationships/organization_users/unfavorite.js # DELETE /relationships/organization_users/unfavorite.json def unfavorite @organization = Organization.find(params[:organization_id]) @relationships_organization_user = current_user.unfavorite!(@organization) respond_to do |format| format.html { redirect_to @organization } format.json { render json: @relationships_organization_user, status: :created } format.js end end protected def permitted_params params.require(:relationships_organization_user).permit(:organization_id, :user_id) end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/api/v1/organizations_controller.rb
app/controllers/api/v1/organizations_controller.rb
class Api::V1::OrganizationsController < Api::V1::ApplicationController after_filter :track_google_analytics def index @organizations = Organization.paginate(:page => params[:page]) unless params[:category].blank? or params[:category].downcase == "all" @organizations = @organizations.where(:category_id => params[:category]) end @organizations = @organizations.joins(%(LEFT JOIN "cache_review_stats" ON "cache_review_stats"."organization_id" = "organizations"."id")). select(%("organizations".*, "cache_review_stats"."num_reviews", "cache_review_stats"."avg_review")). where(%("cache_review_stats"."condition_id" = 0 OR "cache_review_stats"."condition_id" IS NULL)). order(%("cache_review_stats"."avg_review" DESC NULLS LAST)). order(%("cache_review_stats"."num_reviews" DESC)) if params[:latitude].present? and params[:longitude].present? and params[:radius].present? @organizations = @organizations.near([params[:latitude], params[:longitude]], params[:radius]) elsif params[:latitude].present? or params[:longitude].present? or params[:radius].present? render :status => 500, :text => "Invalid API Call - must provide latitude, longitude, and radius" end end def show @organization = Organization.find(params[:id]) @reviews = @organization.reviews.with_condition(0).paginate(:page => params[:page]).includes(:user) end private def track_google_analytics unless Rails.env.test? gabba = Gabba::Gabba.new(APP_CONFIG["google_analytics"][Rails.env], "revtilt.com") gabba.page_view("api call", request.fullpath) end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/api/v1/pages_controller.rb
app/controllers/api/v1/pages_controller.rb
class Api::V1::PagesController < ApplicationController def documentation @title = "API Documentation" end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/controllers/api/v1/application_controller.rb
app/controllers/api/v1/application_controller.rb
class Api::V1::ApplicationController < ActionController::Base protect_from_forgery before_filter :allow_origin_multiple_origin_domains rescue_from CanCan::AccessDenied do |exception| render :text => "Access Forbidden", :status => 403, :layout => false end private def allow_origin_multiple_origin_domains response.headers["Access-Control-Allow-Origin"] = "*" end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/models/review.rb
app/models/review.rb
# == Schema Information # Schema version: 20130424042424 # # Table name: reviews # # id :integer not null, primary key # rating :integer # content :text # user_id :integer # condition_id :integer # organization_id :integer # created_at :datetime not null # updated_at :datetime not null # class Review < ActiveRecord::Base # attr_accessible :condition_id, :content, :organization_id, :rating # Validations validates_presence_of :condition_id validates_presence_of :content validates_presence_of :organization_id validates_presence_of :rating validates_presence_of :user_id # Database Relationships belongs_to :user, :class_name => "User", :foreign_key => "user_id" belongs_to :organization, :class_name => "Organization", :foreign_key => "organization_id" scope :with_condition, Proc.new { |n| where(:condition_id => n) } scope :reverse_chronological, -> { order(%("reviews"."id" DESC))} after_save :update_cache!, :if => Proc.new { rating_changed? or condition_id_changed? } after_destroy :update_cache! private def update_cache! unless organization.nil? organization.update_cache!(condition_id) if condition_id_changed? organization.update_cache!(condition_id_was) unless condition_id_was.nil? end end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/models/organization.rb
app/models/organization.rb
# == Schema Information # Schema version: 20130501180835 # # Table name: organizations # # id :integer not null, primary key # name :string(255) # url :string(255) # url_type :string(255) # latitude :float # longitude :float # created_at :datetime not null # updated_at :datetime not null # category_id :integer # address :string(255) # display_location :string(255) # homepage_url :string(255) # require "open-uri" class Organization < ActiveRecord::Base # attr_accessible :address, :category_id, :homepage_url, :latitude, :longitude, :name, :url # Validations validates_presence_of :category_id validates_presence_of :name validates_presence_of :url, :message => "must be a yelp URL" validates_uniqueness_of :url validates_format_of :homepage_url, with: UrlFormatter.url_regexp, message: "is not a valid URL", if: "homepage_url?" validates_presence_of :address # Database Relationships has_many :organization_user_relationships, :class_name => "Relationships::OrganizationUser", :foreign_key => "organization_id", :dependent => :destroy has_many :reviews, :class_name => "Review", :foreign_key => "organization_id" has_many :users, :through => :organization_user_relationships, :source => :user has_many :cache_review_stats, :class_name => "Cache::ReviewStat", :foreign_key => "organization_id", :dependent => :destroy # URL cleaning before_validation :clean_url # Based on https://github.com/nhocki/url_formatter before_validation do self.homepage_url = UrlFormatter.format_url(self.homepage_url) end # Geocoding geocoded_by :address after_validation :geocode, :if => :address_changed? reverse_geocoded_by :latitude, :longitude do |obj,results| if geo = results.first obj.display_location = [geo.city, geo.state_code, geo.postal_code].join(", ") end end after_validation :reverse_geocode, :if => :address_changed? # Class Methods def self.category_options return { "activities" => 1, "childcare / home care" => 2, "dentist / orthodontist" => 3, "education" => 7, "hair salon / barber" => 5, "healthcare" => 4, "housing" => 14, "non-profit / government" => 13, "other" => 0, "restaurants" => 6, "therapy - cognitive behavioral" => 10, "therapy - occupational" => 9, "therapy - speech & language" => 8, "therapy - physical" => 12, "therapy - other" => 11 } end def self.category_text(q_category_id) Organization.category_options.select { |k,v| v == q_category_id }.keys[0] rescue "MISC" end def self.with_url(q_url) where(:url => q_url).first end # Instance Methods def to_param "#{id}-#{name}".parameterize end def category_text Organization.category_text(category_id) end def update_cache!(condition_id) review_cache = cache_review_stats.with_condition(condition_id).first if review_cache.nil? review_cache = cache_review_stats.create(:condition_id => condition_id) end review_cache.num_reviews = reviews.with_condition(condition_id).count review_cache.avg_review = reviews.with_condition(condition_id).average(:rating) || 0 review_cache.save! end private def clean_url unless url.blank? query_url = self.url unless query_url =~ /\Ahttps?:\/\// query_url = "http://" + query_url end components = URI.split(query_url) res = "" if components[2] =~ /yelp\.com/ and components[5] =~ /\A\/biz\// res << "http://www.yelp.com" res << components[5] self.url_type = "yelp" end self.url = res end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/models/user.rb
app/models/user.rb
# == Schema Information # Schema version: 20130424193539 # # Table name: users # # id :integer not null, primary key # email :string(255) default(""), not null # encrypted_password :string(255) default(""), not null # reset_password_token :string(255) # reset_password_sent_at :datetime # remember_created_at :datetime # sign_in_count :integer default(0) # current_sign_in_at :datetime # last_sign_in_at :datetime # current_sign_in_ip :string(255) # last_sign_in_ip :string(255) # authentication_token :string(255) # username :string(255) default(""), not null # created_at :datetime not null # updated_at :datetime not null # admin :boolean default(FALSE) # class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :authentication_keys => [:login] # Setup accessible (or protected) attributes for your model # attr_accessible :username, :email, :password, :password_confirmation, :remember_me # attr_accessible :title, :body # attr_accessible :login attr_accessor :login # Validations validates_presence_of :username validates_uniqueness_of :username, :case_sensitive => false validates_format_of :username, :with => /\A[\w]+\z/, :on => :create, :message => "cannot have whitespace" # Database Relationships has_many :organization_user_relationships, :class_name => "Relationships::OrganizationUser", :foreign_key => "user_id", :dependent => :destroy has_many :favorite_organizations, :through => :organization_user_relationships, :source => :organization # Instance Methods def favorite!(organization) self.favorite_organizations += [organization] return organization end def unfavorite!(organization) self.favorite_organizations -= [organization] return organization end def favorited?(organization) Relationships::OrganizationUser.where(:organization_id => organization.id, :user_id => self.id).first end protected # Allowing for devise to use either the username or email as the authentication key def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first else super end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/models/cache/review_stat.rb
app/models/cache/review_stat.rb
# == Schema Information # Schema version: 20130501214342 # # Table name: cache_review_stats # # id :integer not null, primary key # organization_id :integer # num_reviews :integer default(0) # avg_review :float default(0.0) # condition_id :integer # created_at :datetime not null # updated_at :datetime not null # class Cache::ReviewStat < ActiveRecord::Base # attr_accessible :avg_review, :condition_id, :num_reviews, :organization_id # Validations validates_presence_of :organization_id validates_presence_of :condition_id # Database Relationships belongs_to :organization, :class_name => "Organization", :foreign_key => "organization_id" scope :with_condition, Proc.new { |n| where(:condition_id => n) } end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/models/relationships/organization_user.rb
app/models/relationships/organization_user.rb
# == Schema Information # Schema version: 20130423230554 # # Table name: relationships_organization_users # # id :integer not null, primary key # organization_id :integer # user_id :integer # created_at :datetime not null # updated_at :datetime not null # class Relationships::OrganizationUser < ActiveRecord::Base # attr_accessible :organization_id, :user_id validates_presence_of :organization_id validates_presence_of :user_id belongs_to :organization, :class_name => "Organization", :foreign_key => "organization_id" belongs_to :user, :class_name => "User", :foreign_key => "user_id" end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/namespaces/relationships.rb
app/namespaces/relationships.rb
module Relationships def self.table_name_prefix 'relationships_' end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/app/namespaces/cache.rb
app/namespaces/cache.rb
module Cache def self.table_name_prefix 'cache_' end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/seeds.rb
db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first)
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/schema.rb
db/schema.rb
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20130721085018) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "cache_review_stats", force: true do |t| t.integer "organization_id" t.integer "num_reviews", default: 0 t.float "avg_review", default: 0.0 t.integer "condition_id" t.datetime "created_at" t.datetime "updated_at" end add_index "cache_review_stats", ["avg_review"], name: "index_cache_review_stats_on_avg_review", using: :btree add_index "cache_review_stats", ["condition_id"], name: "index_cache_review_stats_on_condition_id", using: :btree add_index "cache_review_stats", ["num_reviews"], name: "index_cache_review_stats_on_num_reviews", using: :btree add_index "cache_review_stats", ["organization_id"], name: "index_cache_review_stats_on_organization_id", using: :btree create_table "organizations", force: true do |t| t.string "name" t.string "url" t.string "url_type" t.float "latitude" t.float "longitude" t.datetime "created_at" t.datetime "updated_at" t.integer "category_id" t.string "address" t.string "display_location" t.string "homepage_url" end add_index "organizations", ["category_id"], name: "index_organizations_on_category_id", using: :btree add_index "organizations", ["latitude"], name: "index_organizations_on_latitude", using: :btree add_index "organizations", ["longitude"], name: "index_organizations_on_longitude", using: :btree add_index "organizations", ["name"], name: "index_organizations_on_name", using: :btree create_table "relationships_organization_users", force: true do |t| t.integer "organization_id" t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" end add_index "relationships_organization_users", ["organization_id"], name: "index_relationships_organization_users_on_organization_id", using: :btree add_index "relationships_organization_users", ["user_id"], name: "index_relationships_organization_users_on_user_id", using: :btree create_table "reviews", force: true do |t| t.integer "rating" t.text "content" t.integer "user_id" t.integer "condition_id" t.integer "organization_id" t.datetime "created_at" t.datetime "updated_at" end add_index "reviews", ["condition_id"], name: "index_reviews_on_condition_id", using: :btree add_index "reviews", ["organization_id"], name: "index_reviews_on_organization_id", using: :btree add_index "reviews", ["rating"], name: "index_reviews_on_rating", using: :btree add_index "reviews", ["user_id"], name: "index_reviews_on_user_id", using: :btree create_table "users", force: true do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.string "authentication_token" t.string "username", default: "", null: false t.datetime "created_at" t.datetime "updated_at" t.boolean "admin", default: false end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree add_index "users", ["username"], name: "index_users_on_username", using: :btree end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130501214342_create_cache_review_stats.rb
db/migrate/20130501214342_create_cache_review_stats.rb
class CreateCacheReviewStats < ActiveRecord::Migration def change create_table :cache_review_stats do |t| t.integer :organization_id t.integer :num_reviews, :default => 0 t.float :avg_review, :default => 0.0 t.integer :condition_id t.timestamps end add_index :cache_review_stats, :organization_id add_index :cache_review_stats, :num_reviews add_index :cache_review_stats, :avg_review add_index :cache_review_stats, :condition_id end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130424214510_change_display_location_to_addresss.rb
db/migrate/20130424214510_change_display_location_to_addresss.rb
class ChangeDisplayLocationToAddresss < ActiveRecord::Migration def change rename_column :organizations, :display_location, :address end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130501180835_add_homepage_url_to_organizations.rb
db/migrate/20130501180835_add_homepage_url_to_organizations.rb
class AddHomepageUrlToOrganizations < ActiveRecord::Migration def change add_column :organizations, :homepage_url, :string end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130416210931_create_users.rb
db/migrate/20130416210931_create_users.rb
class CreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable t.string :email, :null => false, :default => "" t.string :encrypted_password, :null => false, :default => "" ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable t.integer :sign_in_count, :default => 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token # t.datetime :confirmed_at # t.datetime :confirmation_sent_at # t.string :unconfirmed_email # Only if using reconfirmable ## Lockable # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts # t.string :unlock_token # Only if unlock strategy is :email or :both # t.datetime :locked_at ## Token authenticatable t.string :authentication_token t.string :username, :null => false, :default => "" t.timestamps end add_index :users, :email, :unique => true add_index :users, :reset_password_token, :unique => true # add_index :users, :confirmation_token, :unique => true # add_index :users, :unlock_token, :unique => true # add_index :users, :authentication_token, :unique => true end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130423222405_add_category_id_to_organizations.rb
db/migrate/20130423222405_add_category_id_to_organizations.rb
class AddCategoryIdToOrganizations < ActiveRecord::Migration def change add_column :organizations, :category_id, :integer add_index :organizations, :category_id add_column :organizations, :display_location, :string end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130424221615_add_display_location_to_organization.rb
db/migrate/20130424221615_add_display_location_to_organization.rb
class AddDisplayLocationToOrganization < ActiveRecord::Migration def change add_column :organizations, :display_location, :string end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130721085018_add_index_for_username.rb
db/migrate/20130721085018_add_index_for_username.rb
class AddIndexForUsername < ActiveRecord::Migration def change add_index :users, :username end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130417181129_create_organizations.rb
db/migrate/20130417181129_create_organizations.rb
class CreateOrganizations < ActiveRecord::Migration def change create_table :organizations do |t| t.string :name t.string :url t.string :url_type t.float :latitude t.float :longitude t.timestamps end add_index :organizations, :latitude add_index :organizations, :longitude add_index :organizations, :name end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130423230554_create_relationships_organization_users.rb
db/migrate/20130423230554_create_relationships_organization_users.rb
class CreateRelationshipsOrganizationUsers < ActiveRecord::Migration def change create_table :relationships_organization_users do |t| t.integer :organization_id t.integer :user_id t.timestamps end add_index :relationships_organization_users, :organization_id add_index :relationships_organization_users, :user_id end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130424193539_add_admin_to_users.rb
db/migrate/20130424193539_add_admin_to_users.rb
class AddAdminToUsers < ActiveRecord::Migration def change add_column :users, :admin, :boolean, :default => false add_index :users, :admin end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/db/migrate/20130424042424_create_reviews.rb
db/migrate/20130424042424_create_reviews.rb
class CreateReviews < ActiveRecord::Migration def change create_table :reviews do |t| t.integer :rating t.text :content t.integer :user_id t.integer :condition_id t.integer :organization_id t.timestamps end add_index :reviews, :user_id add_index :reviews, :condition_id add_index :reviews, :organization_id add_index :reviews, :rating end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/rails_helper.rb
spec/rails_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require 'spec_helper' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'webmock/rspec' require 'capybara/rspec' # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end # in _spec.rb will both be required and run as specs, causing the specs to be # run twice. It is recommended that you do not name files matching this glob to # end with _spec.rb. You can configure this pattern with with the --pattern # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } # Checks for pending migrations before tests are run. # If you are not using ActiveRecord, you can remove this line. ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) RSpec.configure do |config| config.mock_with :rspec # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and # `post` in specs under `spec/controllers`. # # You can disable this behaviour by removing the line below, and instead # explicitly tag your specs with their type, e.g.: # # RSpec.describe UsersController, :type => :controller do # # ... # end # # The different available types are documented in the features, such as in # https://relishapp.com/rspec/rspec-rails/docs config.infer_spec_type_from_file_location! end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/spec_helper.rb
spec/spec_helper.rb
# This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause this # file to always be loaded, without a need to explicitly require it in any files. # # Given that it is always loaded, you are encouraged to keep this file as # light-weight as possible. Requiring heavyweight dependencies from this file # will add to the boot time of your test suite on EVERY test run, even for an # individual file that may not need all of that loaded. Instead, make a # separate helper file that requires this one and then use it only in the specs # that actually need it. # # The `.rspec` file also contains a few flags that are not defaults but that # users commonly want. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. =begin # These two settings work together to allow you to limit a spec run # to individual examples or groups you care about by tagging them with # `:focus` metadata. When nothing is tagged with `:focus`, all examples # get run. config.filter_run :focus config.run_all_when_everything_filtered = true # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an # individual spec file. if config.files_to_run.one? # Use the documentation formatter for detailed output, # unless a formatter has already been configured # (e.g. via a command-line flag). config.default_formatter = 'doc' end # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow. config.profile_examples = 10 # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = :random # Seed global randomization in this process using the `--seed` CLI option. # Setting this allows you to use `--seed` to deterministically reproduce # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. config.expect_with :rspec do |expectations| # Enable only the newer, non-monkey-patching expect syntax. # For more details, see: # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax expectations.syntax = :expect end # rspec-mocks config goes here. You can use an alternate test double # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| # Enable only the newer, non-monkey-patching expect syntax. # For more details, see: # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ mocks.syntax = :expect # Prevents you from mocking or stubbing a method that does not exist on # a real object. This is generally recommended. mocks.verify_partial_doubles = true end =end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/support/devise.rb
spec/support/devise.rb
RSpec.configure do |config| config.include Devise::TestHelpers, :type => :controller config.include Devise::TestHelpers, :type => :helper config.include Warden::Test::Helpers, :type => :request end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/routing/reviews_routing_spec.rb
spec/routing/reviews_routing_spec.rb
require "rails_helper" describe ReviewsController, :type => :routing do describe "routing" do it "routes to #index" do expect(get("/reviews")).to route_to("reviews#index") end it "routes to #new" do expect(get("/reviews/new")).to route_to("reviews#new") end it "routes to #show" do expect(get("/reviews/1")).to route_to("reviews#show", :id => "1") end it "routes to #edit" do expect(get("/reviews/1/edit")).to route_to("reviews#edit", :id => "1") end it "routes to #create" do expect(post("/reviews")).to route_to("reviews#create") end it "routes to #update" do expect(put("/reviews/1")).to route_to("reviews#update", :id => "1") end it "routes to #destroy" do expect(delete("/reviews/1")).to route_to("reviews#destroy", :id => "1") end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/routing/organizations_routing_spec.rb
spec/routing/organizations_routing_spec.rb
require "rails_helper" describe OrganizationsController, :type => :routing do describe "routing" do it "routes to #index" do expect(get("/organizations")).to route_to("organizations#index") end it "routes to #new" do expect(get("/organizations/new")).to route_to("organizations#new") end it "routes to #show" do expect(get("/organizations/1")).to route_to("organizations#show", :id => "1") end it "routes to #edit" do expect(get("/organizations/1/edit")).to route_to("organizations#edit", :id => "1") end it "routes to #create" do expect(post("/organizations")).to route_to("organizations#create") end it "routes to #update" do expect(put("/organizations/1")).to route_to("organizations#update", :id => "1") end it "routes to #destroy" do expect(delete("/organizations/1")).to route_to("organizations#destroy", :id => "1") end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/routing/pages_routing_spec.rb
spec/routing/pages_routing_spec.rb
require "rails_helper" describe PagesController, :type => :routing do describe "routing" do it "routes to about" do expect(get("/about")).to route_to("pages#about") end it "routes to bookmarklet" do expect(get("/bookmarklet")).to route_to("pages#bookmarklet") end it "routes to favorites" do expect(get("/favorites")).to route_to("pages#favorites") end it "routes to press" do expect(get("/press")).to route_to("pages#press") end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/routing/relationships/organization_users_routing_spec.rb
spec/routing/relationships/organization_users_routing_spec.rb
require "rails_helper" describe Relationships::OrganizationUsersController, :type => :routing do describe "routing" do it "routes to #index" do expect(get("/relationships/organization_users")).to route_to("relationships/organization_users#index") end it "routes to #new" do expect(get("/relationships/organization_users/new")).to route_to("relationships/organization_users#new") end it "routes to #show" do expect(get("/relationships/organization_users/1")).to route_to("relationships/organization_users#show", :id => "1") end it "routes to #edit" do expect(get("/relationships/organization_users/1/edit")).to route_to("relationships/organization_users#edit", :id => "1") end it "routes to #create" do expect(post("/relationships/organization_users")).to route_to("relationships/organization_users#create") end it "routes to #update" do expect(put("/relationships/organization_users/1")).to route_to("relationships/organization_users#update", :id => "1") end it "routes to #destroy" do expect(delete("/relationships/organization_users/1")).to route_to("relationships/organization_users#destroy", :id => "1") end it "routes to #favorite" do expect(post("/relationships/organization_users/favorite")).to route_to("relationships/organization_users#favorite") end it "routes to #unfavorite" do expect(delete("/relationships/organization_users/unfavorite")).to route_to("relationships/organization_users#unfavorite") end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/routing/api/v1/organizations_routing_spec.rb
spec/routing/api/v1/organizations_routing_spec.rb
require "rails_helper" describe Api::V1::OrganizationsController, :type => :routing do describe "routing" do it "routes to #index" do expect(get("/api/v1/organizations")).to route_to("api/v1/organizations#index") end it "routes to #show" do expect(get("/api/v1/organizations/1")).to route_to("api/v1/organizations#show", :id => "1") end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/helpers/pages_helper_spec.rb
spec/helpers/pages_helper_spec.rb
require 'rails_helper' # Specs in this file have access to a helper object that includes # the PagesHelper. For example: # # describe PagesHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end describe PagesHelper, :type => :helper do describe "bookmarklet_javascript" do it "should respond_to bookmarklet_javascript" do expect(helper).to respond_to(:bookmarklet_javascript) end it "should return the a javascript string" do js_string = %(javascript:(function(){__script=document.createElement('SCRIPT');__script.type='text/javascript';__script.src='http://test.host/bookmarklet.js?service=yelp';document.getElementsByTagName('head')[0].appendChild(__script);})();) expect(helper.bookmarklet_javascript("yelp")).to eq(js_string) end it "should return the a javascript string with a new_window argument" do js_string = %(javascript:(function(){__script=document.createElement('SCRIPT');__script.type='text/javascript';__script.src='http://test.host/bookmarklet.js?new_window=true&service=yelp';document.getElementsByTagName('head')[0].appendChild(__script);})();) expect(helper.bookmarklet_javascript("yelp", true)).to eq(js_string) end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/helpers/reviews_helper_spec.rb
spec/helpers/reviews_helper_spec.rb
require 'rails_helper' # Specs in this file have access to a helper object that includes # the ReviewsHelper. For example: # # describe ReviewsHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end describe ReviewsHelper, :type => :helper do # pending "add some examples to (or delete) #{__FILE__}" end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/helpers/organizations_helper_spec.rb
spec/helpers/organizations_helper_spec.rb
require 'rails_helper' # Specs in this file have access to a helper object that includes # the OrganizationsHelper. For example: # # describe OrganizationsHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end describe OrganizationsHelper, :type => :helper do # pending "add some examples to (or delete) #{__FILE__}" end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
require 'rails_helper' # Specs in this file have access to a helper object that includes # the PagesHelper. For example: # # describe PagesHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end describe ApplicationHelper, :type => :helper do describe "bootstrap_alert_type" do it "should return 'danger' when given 'alert'" do expect(helper.bootstrap_alert_type("alert")).to eq("danger") expect(helper.bootstrap_alert_type(:alert)).to eq("danger") end it "should return 'danger' when given 'error'" do expect(helper.bootstrap_alert_type("error")).to eq("danger") expect(helper.bootstrap_alert_type(:error)).to eq("danger") end it "should return 'warning' when given 'notice'" do expect(helper.bootstrap_alert_type("notice")).to eq("warning") expect(helper.bootstrap_alert_type(:notice)).to eq("warning") end it "should return 'success' when given 'success'" do expect(helper.bootstrap_alert_type("success")).to eq("success") expect(helper.bootstrap_alert_type(:success)).to eq("success") end end describe "title_helper" do let(:base) { "RevTilt" } it "should return 'Revtilt'" do @title = nil expect(helper.title).to eq(base) @title = "" expect(helper.title).to eq(base) end it "should return 'RevTilt | Home'" do @title = "Home" expect(helper.title).to eq("#{base} | Home") end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/helpers/relationships/organization_users_helper_spec.rb
spec/helpers/relationships/organization_users_helper_spec.rb
require 'rails_helper' # Specs in this file have access to a helper object that includes # the Relationships::OrganizationUsersHelper. For example: # # describe Relationships::OrganizationUsersHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end describe Relationships::OrganizationUsersHelper, :type => :helper do # pending "add some examples to (or delete) #{__FILE__}" end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/helpers/api/v1/pages_helper_spec.rb
spec/helpers/api/v1/pages_helper_spec.rb
require 'rails_helper' # Specs in this file have access to a helper object that includes # the Api::V1::PagesHelper. For example: # # describe Api::V1::PagesHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end describe Api::V1::PagesHelper, :type => :helper do # pending "add some examples to (or delete) #{__FILE__}" end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/helpers/api/v1/organizations_helper_spec.rb
spec/helpers/api/v1/organizations_helper_spec.rb
require 'rails_helper' # Specs in this file have access to a helper object that includes # the Api::V1::SearchHelper. For example: # # describe Api::V1::SearchHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end describe Api::V1::OrganizationsHelper, :type => :helper do # pending "add some examples to (or delete) #{__FILE__}" end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/authorization/ability_spec.rb
spec/authorization/ability_spec.rb
require 'rails_helper' require "cancan/matchers" describe Ability do describe "admin" do before(:each) do @user = FactoryGirl.create(:user, :admin => true) @ability = Ability.new(@user) end subject { @ability } it { is_expected.to be_able_to(:manage, :all) } end describe "Reviews" do describe "guest" do before(:each) do @ability = Ability.new end subject { @ability } it { is_expected.to be_able_to(:show, FactoryGirl.build(:review)) } it { is_expected.not_to be_able_to(:manage, FactoryGirl.build(:review)) } end describe "signed in user" do before(:each) do @user = FactoryGirl.create(:user) @ability = Ability.new(@user) end subject { @ability } it { is_expected.to be_able_to(:show, FactoryGirl.build(:review)) } it { is_expected.to be_able_to(:manage, FactoryGirl.build(:review, :user => @user)) } it { is_expected.not_to be_able_to(:manage, FactoryGirl.build(:review, :user_id => @user.id - 1)) } end end describe "Organizations" do describe "guest" do before(:each) do @ability = Ability.new end subject { @ability } it { is_expected.to be_able_to(:show, FactoryGirl.build(:organization)) } it { is_expected.not_to be_able_to(:create, Organization) } it { is_expected.not_to be_able_to(:manage, FactoryGirl.build(:organization)) } end describe "signed in user" do before(:each) do @user = FactoryGirl.create(:user) @ability = Ability.new(@user) end subject { @ability } it { is_expected.to be_able_to(:show, FactoryGirl.build(:organization)) } it { is_expected.to be_able_to(:create, FactoryGirl.build(:organization)) } it { is_expected.to be_able_to(:manage, FactoryGirl.build(:organization)) } it "should not be able to manage an organization if it has reviews" do organization = FactoryGirl.create(:organization) review = FactoryGirl.create(:review, :organization => organization) is_expected.not_to be_able_to(:manage, organization) end it "should be able to manage an organization if it only has one review and it is by the user" do organization = FactoryGirl.create(:organization) review = FactoryGirl.create(:review, :organization => organization, :user => @user) is_expected.to be_able_to(:manage, organization) end end end describe "Relationships::OrganizationUser" do describe "signed in user" do before(:each) do @user = FactoryGirl.create(:user) @ability = Ability.new(@user) end subject { @ability } it { is_expected.not_to be_able_to(:update, FactoryGirl.build(:relationships_organization_user)) } it { is_expected.not_to be_able_to(:show, FactoryGirl.build(:relationships_organization_user)) } it { is_expected.not_to be_able_to(:manage, FactoryGirl.build(:relationships_organization_user)) } end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/factories/users.rb
spec/factories/users.rb
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do sequence(:email) {|n| "person-#{n}@example.com" } sequence(:username) {|n| Faker::Name.first_name + "#{n}" } factory :user do email password "foobar12" username end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/factories/organizations.rb
spec/factories/organizations.rb
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do sequence(:url) {|n| "http://www.yelp.com/biz/#{n}" } factory :organization do name "MyString" url url_type "MyString" homepage_url nil address "500 college ave, Swarthmore PA 19081" latitude 1.5 longitude 1.5 category_id 1 end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/factories/reviews.rb
spec/factories/reviews.rb
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :review do rating 1 content "MyText" user_id 1 condition_id 1 organization_id 1 end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/factories/cache/review_stats.rb
spec/factories/cache/review_stats.rb
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :cache_review_stat, :class => 'Cache::ReviewStat' do organization_id 1 num_reviews 1 avg_review 1.5 condition_id 1 end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/factories/relationships/organization_users.rb
spec/factories/relationships/organization_users.rb
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :relationships_organization_user, :class => 'Relationships::OrganizationUser' do organization_id 1 user_id 1 end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/controllers/organizations_controller_spec.rb
spec/controllers/organizations_controller_spec.rb
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold # generator. If you are using any extension libraries to generate different # controller code, this generated spec may or may not pass. # # It only uses APIs available in rails and/or rspec-rails. There are a number # of tools you can use to make these specs even more expressive, but we're # sticking to rails and rspec-rails APIs to keep things simple and stable. # # Compared to earlier versions of this generator, there is very limited use of # stubs and message expectations in this spec. Stubs are only used when there # is no simpler way to get a handle on the object needed for the example. # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. describe OrganizationsController, :type => :controller do render_views # This should return the minimal set of attributes required to create a valid # Organization. As you add validations to Organization, be sure to # update the return value of this method accordingly. def valid_attributes { "name" => "MyString", "url" => "http://yelp.com/biz/1", "category_id" => "1", "address" => "500 college ave., Swarthmore PA 19081" } end # This should return the minimal set of values that should be in the session # in order to pass any filters (e.g. authentication) defined in # OrganizationsController. Be sure to keep this updated too. # def valid_session # {} # end describe "GET index" do it "assigns all organizations as @organizations" do organization = FactoryGirl.create(:organization) get :index, {} expect(assigns(:organizations)).to eq([organization]) end it "should not show the organization because of the filter" do organization = FactoryGirl.create(:organization) get :index, { :category => organization.category_id + 1 } expect(assigns(:organizations)).to eq([]) end end describe "GET show" do before(:each) do @organization = FactoryGirl.create(:organization) end it "assigns the requested organization as @organization" do get :show, {:id => @organization.to_param} expect(assigns(:organization)).to eq(@organization) end it "should assign a new review to review" do get :show, {:id => @organization.to_param} expect(assigns(:review).organization).to eq(@organization) expect(assigns(:review)).to be_new_record end it "should assign the reviews" do prev_review = FactoryGirl.create(:review, :organization => @organization) get :show, {:id => @organization.to_param} expect(assigns(:reviews)).to eq([prev_review]) end end describe "CRUD actions" do before(:each) do @user = FactoryGirl.create(:user, :admin => true) sign_in @user end describe "GET new" do it "assigns a new organization as @organization" do get :new, {} expect(assigns(:organization)).to be_a_new(Organization) end it "should set name, url, homepage_url, and address from url parameters" do name = "Woot" url = "http://www.yelp.com/biz/123" homepage_url = "http://www.google.com" address = "500 College Ave, Swarthmore Pa, 19081" get :new, { :name => name, :url => url, :homepage_url => homepage_url, :address => address } expect(assigns(:organization).name).to eq(name) expect(assigns(:organization).url).to eq(url) expect(assigns(:organization).homepage_url).to eq(homepage_url) expect(assigns(:organization).address).to eq(address) end end describe "GET edit" do it "assigns the requested organization as @organization" do organization = FactoryGirl.create(:organization) get :edit, {:id => organization.to_param} expect(assigns(:organization)).to eq(organization) end end describe "POST create" do describe "with valid params" do it "creates a new Organization" do expect { post :create, {:organization => valid_attributes} }.to change(Organization, :count).by(1) end it "assigns a newly created organization as @organization" do post :create, {:organization => valid_attributes} expect(assigns(:organization)).to be_a(Organization) expect(assigns(:organization)).to be_persisted end it "redirects to the created organization" do post :create, {:organization => valid_attributes} expect(response).to redirect_to(Organization.last) end end describe "with invalid params" do it "assigns a newly created but unsaved organization as @organization" do # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Organization).to receive(:save).and_return(false) post :create, {:organization => { "name" => "invalid value" }} expect(assigns(:organization)).to be_a_new(Organization) end it "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Organization).to receive(:save).and_return(false) post :create, {:organization => { "name" => "invalid value" }} expect(response).to render_template("new") end end describe "organization with that url already exists" do it "should redirect to that organization" do organization = FactoryGirl.create(:organization) post :create, { :organization => valid_attributes.merge(:url => organization.url) } expect(response).to redirect_to(organization) end it "should not create a new organization" do organization = FactoryGirl.create(:organization) expect { post :create, { :organization => valid_attributes.merge(:url => organization.url) } }.to_not change(Organization, :count) end end end describe "PUT update" do describe "with valid params" do it "updates the requested organization" do organization = FactoryGirl.create(:organization) # Assuming there are no other organizations in the database, this # specifies that the Organization created on the previous line # receives the :update_attributes message with whatever params are # submitted in the request. expect_any_instance_of(Organization).to receive(:update_attributes).with({ "name" => "MyString" }) put :update, {:id => organization.to_param, :organization => { "name" => "MyString" }} end it "assigns the requested organization as @organization" do organization = FactoryGirl.create(:organization) put :update, {:id => organization.to_param, :organization => valid_attributes} expect(assigns(:organization)).to eq(organization) end it "redirects to the organization" do organization = FactoryGirl.create(:organization) put :update, {:id => organization.to_param, :organization => valid_attributes} expect(response).to redirect_to(organization) end end describe "with invalid params" do it "assigns the organization as @organization" do organization = FactoryGirl.create(:organization) # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Organization).to receive(:save).and_return(false) put :update, {:id => organization.to_param, :organization => { "name" => "invalid value" }} expect(assigns(:organization)).to eq(organization) end it "re-renders the 'edit' template" do organization = FactoryGirl.create(:organization) # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Organization).to receive(:save).and_return(false) put :update, {:id => organization.to_param, :organization => { "name" => "invalid value" }} expect(response).to render_template("edit") end end end describe "DELETE destroy" do it "destroys the requested organization" do organization = FactoryGirl.create(:organization) expect { delete :destroy, {:id => organization.to_param} }.to change(Organization, :count).by(-1) end it "redirects to the organizations list" do organization = FactoryGirl.create(:organization) delete :destroy, {:id => organization.to_param} expect(response).to redirect_to(organizations_url) end end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/controllers/reviews_controller_spec.rb
spec/controllers/reviews_controller_spec.rb
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold # generator. If you are using any extension libraries to generate different # controller code, this generated spec may or may not pass. # # It only uses APIs available in rails and/or rspec-rails. There are a number # of tools you can use to make these specs even more expressive, but we're # sticking to rails and rspec-rails APIs to keep things simple and stable. # # Compared to earlier versions of this generator, there is very limited use of # stubs and message expectations in this spec. Stubs are only used when there # is no simpler way to get a handle on the object needed for the example. # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. describe ReviewsController, :type => :controller do render_views # This should return the minimal set of attributes required to create a valid # Review. As you add validations to Review, be sure to # update the return value of this method accordingly. def valid_attributes { "rating" => "1", "content" => "blah", "condition_id" => "1" } end # This should return the minimal set of values that should be in the session # in order to pass any filters (e.g. authentication) defined in # ReviewsController. Be sure to keep this updated too. def valid_session {} end describe "GET index" do it "assigns all reviews as @reviews" do review = FactoryGirl.create(:review) get :index, {} expect(assigns(:reviews)).to eq([review]) end end describe "GET show" do it "assigns the requested review as @review" do review = FactoryGirl.create(:review) get :show, {:id => review.to_param} expect(assigns(:review)).to eq(review) end end describe "CRUD actions" do before(:each) do @user = FactoryGirl.create(:user, :admin => true) sign_in @user end describe "GET new" do it "assigns a new review as @review" do get :new, {} expect(assigns(:review)).to be_a_new(Review) expect(assigns(:review).organization).to be_nil expect(assigns(:review).user).to eq(@user) end it "should connect an organization to the new review" do organization = FactoryGirl.create(:organization) get :new, { :o_id => organization.to_param } expect(assigns(:review).organization).to eq(organization) end end describe "GET edit" do it "assigns the requested review as @review" do review = FactoryGirl.create(:review) get :edit, {:id => review.to_param} expect(assigns(:review)).to eq(review) end end describe "POST create" do describe "with valid params" do before(:each) do @organization = FactoryGirl.create(:organization) end it "creates a new Review" do expect { post :create, {:review => valid_attributes.merge({"organization_id" => @organization.to_param })} }.to change(Review, :count).by(1) end it "assigns a newly created review as @review" do post :create, {:review => valid_attributes.merge({"organization_id" => @organization.to_param })} expect(assigns(:review)).to be_a(Review) expect(assigns(:review)).to be_persisted end it "assigns the user_id to the signed in user even if another user_id is provided" do post :create, {:review => valid_attributes.merge({"user_id" => @user.id + 1 })} expect(assigns(:review).user_id).to eq(@user.id) end it "redirects to the created review" do post :create, {:review => valid_attributes.merge({"organization_id" => @organization.to_param })} expect(response).to redirect_to(Review.last.organization) end it "redirects to the root_path" do post :create, {:review => valid_attributes.merge({"organization_id" => -1 })} expect(response).to redirect_to(root_path) end end describe "with invalid params" do it "assigns a newly created but unsaved review as @review" do # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Review).to receive(:save).and_return(false) post :create, {:review => { "rating" => "invalid value" }} expect(assigns(:review)).to be_a_new(Review) end it "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Review).to receive(:save).and_return(false) post :create, {:review => { "rating" => "invalid value" }} expect(response).to render_template("new") end end end describe "PUT update" do describe "with valid params" do it "updates the requested review" do review = FactoryGirl.create(:review) # Assuming there are no other reviews in the database, this # specifies that the Review created on the previous line # receives the :update_attributes message with whatever params are # submitted in the request. expect_any_instance_of(Review).to receive(:update_attributes).with({ "rating" => "1" }) put :update, {:id => review.to_param, :review => { "rating" => "1" }} end it "assigns the requested review as @review" do review = FactoryGirl.create(:review) put :update, {:id => review.to_param, :review => valid_attributes} expect(assigns(:review)).to eq(review) end it "redirects to the review" do review = FactoryGirl.create(:review) put :update, {:id => review.to_param, :review => valid_attributes} expect(response).to redirect_to(review) end it "should redirect to the organization" do organization = FactoryGirl.create(:organization) review = FactoryGirl.create(:review, :organization => organization) put :update, {:id => review.to_param, :review => valid_attributes} expect(response).to redirect_to(organization) end end describe "with invalid params" do it "assigns the review as @review" do review = FactoryGirl.create(:review) # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Review).to receive(:save).and_return(false) put :update, {:id => review.to_param, :review => { "rating" => "invalid value" }} expect(assigns(:review)).to eq(review) end it "re-renders the 'edit' template" do review = FactoryGirl.create(:review) # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Review).to receive(:save).and_return(false) put :update, {:id => review.to_param, :review => { "rating" => "invalid value" }} expect(response).to render_template("edit") end end end describe "DELETE destroy" do it "destroys the requested review" do review = FactoryGirl.create(:review) expect { delete :destroy, {:id => review.to_param} }.to change(Review, :count).by(-1) end it "redirects to the organization" do organization = FactoryGirl.create(:organization) review = FactoryGirl.create(:review, :organization => organization) delete :destroy, {:id => review.to_param} expect(response).to redirect_to(organization) end it "redirects to the root_path" do review = FactoryGirl.create(:review) delete :destroy, {:id => review.to_param} expect(response).to redirect_to(root_path) end end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/controllers/pages_controller_spec.rb
spec/controllers/pages_controller_spec.rb
require 'rails_helper' describe PagesController, :type => :controller do render_views describe "GET 'about'" do it "returns http success" do get 'about' expect(response).to be_success end end describe "GET 'bookmarklet'" do it "returns http success" do get 'bookmarklet' expect(response).to be_success end describe "js" do it "should return the yelp bookmarklet" do get 'bookmarklet', :format => :js, :service => "Yelp" expect(response).to render_template("pages/bookmarklets/yelp_bookmarklet") end it "should set @new_window to false" do get 'bookmarklet', :format => :js, :service => "Yelp" expect(assigns(:new_window)).to eq(false) end it "should set @new_window to true" do get 'bookmarklet', :format => :js, :service => "Yelp", :new_window => "true" expect(assigns(:new_window)).to eq("true") end it "should render the error bookmarklet if the service is no good" do get 'bookmarklet', :format => :js expect(response).to render_template("pages/bookmarklets/error_bookmarklet") end end end describe "GET 'favorites'" do before(:each) do @user = FactoryGirl.create(:user) sign_in @user end it "should redirect to root_path" do get 'favorites' expect(response).to redirect_to(root_path) end it "should be successful" do @organization = FactoryGirl.create(:organization) @user.favorite!(@organization) get 'favorites' expect(response).to be_successful end end describe "GET 'press'" do it "returns http success" do get 'press' expect(response).to be_success end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/controllers/relationships/organization_users_controller_spec.rb
spec/controllers/relationships/organization_users_controller_spec.rb
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold # generator. If you are using any extension libraries to generate different # controller code, this generated spec may or may not pass. # # It only uses APIs available in rails and/or rspec-rails. There are a number # of tools you can use to make these specs even more expressive, but we're # sticking to rails and rspec-rails APIs to keep things simple and stable. # # Compared to earlier versions of this generator, there is very limited use of # stubs and message expectations in this spec. Stubs are only used when there # is no simpler way to get a handle on the object needed for the example. # Message expectations are only used when there is no simpler way to specify # that an instance is receiving a specific message. describe Relationships::OrganizationUsersController, :type => :controller do render_views # This should return the minimal set of attributes required to create a valid # Relationships::OrganizationUser. As you add validations to Relationships::OrganizationUser, be sure to # update the return value of this method accordingly. def valid_attributes { "organization_id" => "1", "user_id" => "2" } end # This should return the minimal set of values that should be in the session # in order to pass any filters (e.g. authentication) defined in # Relationships::OrganizationUsersController. Be sure to keep this updated too. # def valid_session # {} # end before(:each) do @user = FactoryGirl.create(:user, :admin => true) sign_in @user end describe "GET index" do it "assigns all relationships_organization_users as @relationships_organization_users" do organization_user = FactoryGirl.create(:relationships_organization_user) get :index, {} expect(assigns(:relationships_organization_users)).to eq([organization_user]) end end describe "GET show" do it "assigns the requested relationships_organization_user as @relationships_organization_user" do organization_user = FactoryGirl.create(:relationships_organization_user) get :show, {:id => organization_user.to_param} expect(assigns(:relationships_organization_user)).to eq(organization_user) end end describe "GET new" do it "assigns a new relationships_organization_user as @relationships_organization_user" do get :new, {} expect(assigns(:relationships_organization_user)).to be_a_new(Relationships::OrganizationUser) end end describe "GET edit" do it "assigns the requested relationships_organization_user as @relationships_organization_user" do organization_user = FactoryGirl.create(:relationships_organization_user) get :edit, {:id => organization_user.to_param} expect(assigns(:relationships_organization_user)).to eq(organization_user) end end describe "POST create" do describe "with valid params" do it "creates a new Relationships::OrganizationUser" do expect { post :create, {:relationships_organization_user => valid_attributes} }.to change(Relationships::OrganizationUser, :count).by(1) end it "assigns a newly created relationships_organization_user as @relationships_organization_user" do post :create, {:relationships_organization_user => valid_attributes} expect(assigns(:relationships_organization_user)).to be_a(Relationships::OrganizationUser) expect(assigns(:relationships_organization_user)).to be_persisted end it "redirects to the created relationships_organization_user" do post :create, {:relationships_organization_user => valid_attributes} expect(response).to redirect_to(Relationships::OrganizationUser.last) end end describe "with invalid params" do it "assigns a newly created but unsaved relationships_organization_user as @relationships_organization_user" do # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Relationships::OrganizationUser).to receive(:save).and_return(false) post :create, {:relationships_organization_user => { "organization_id" => "invalid value" }} expect(assigns(:relationships_organization_user)).to be_a_new(Relationships::OrganizationUser) end it "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Relationships::OrganizationUser).to receive(:save).and_return(false) post :create, {:relationships_organization_user => { "organization_id" => "invalid value" }} expect(response).to render_template("new") end end end describe "PUT update" do describe "with valid params" do it "updates the requested relationships_organization_user" do organization_user = FactoryGirl.create(:relationships_organization_user) # Assuming there are no other relationships_organization_users in the database, this # specifies that the Relationships::OrganizationUser created on the previous line # receives the :update_attributes message with whatever params are # submitted in the request. expect_any_instance_of(Relationships::OrganizationUser).to receive(:update_attributes).with({ "organization_id" => "1" }) put :update, {:id => organization_user.to_param, :relationships_organization_user => { "organization_id" => "1" }} end it "assigns the requested relationships_organization_user as @relationships_organization_user" do organization_user = FactoryGirl.create(:relationships_organization_user) put :update, {:id => organization_user.to_param, :relationships_organization_user => valid_attributes} expect(assigns(:relationships_organization_user)).to eq(organization_user) end it "redirects to the relationships_organization_user" do organization_user = FactoryGirl.create(:relationships_organization_user) put :update, {:id => organization_user.to_param, :relationships_organization_user => valid_attributes} expect(response).to redirect_to(organization_user) end end describe "with invalid params" do it "assigns the relationships_organization_user as @relationships_organization_user" do organization_user = FactoryGirl.create(:relationships_organization_user) # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Relationships::OrganizationUser).to receive(:save).and_return(false) put :update, {:id => organization_user.to_param, :relationships_organization_user => { "organization_id" => "invalid value" }} expect(assigns(:relationships_organization_user)).to eq(organization_user) end it "re-renders the 'edit' template" do organization_user = FactoryGirl.create(:relationships_organization_user) # Trigger the behavior that occurs when invalid params are submitted allow_any_instance_of(Relationships::OrganizationUser).to receive(:save).and_return(false) put :update, {:id => organization_user.to_param, :relationships_organization_user => { "organization_id" => "invalid value" }} expect(response).to render_template("edit") end end end describe "DELETE destroy" do it "destroys the requested relationships_organization_user" do organization_user = FactoryGirl.create(:relationships_organization_user) expect { delete :destroy, {:id => organization_user.to_param} }.to change(Relationships::OrganizationUser, :count).by(-1) end it "redirects to the relationships_organization_users list" do organization_user = FactoryGirl.create(:relationships_organization_user) delete :destroy, {:id => organization_user.to_param} expect(response).to redirect_to(relationships_organization_users_url) end end describe "POST favorite" do before(:each) do @organization = FactoryGirl.create(:organization) end it "adds a relationships_organization_user" do expect { post :favorite, { :organization_id => @organization.to_param } }.to change(Relationships::OrganizationUser, :count).by(1) end it "should call favorite! on the user model" do expect_any_instance_of(User).to receive(:favorite!).with(@organization) post :favorite, { :organization_id => @organization.to_param } end it "should redirect to the organization" do post :favorite, { :organization_id => @organization.to_param } expect(response).to redirect_to(@organization) end it "should be successful when given a js call" do post :favorite, { :organization_id => @organization.to_param, :format => :js } expect(response).to be_successful end end describe "DELETE unfavorite" do before(:each) do @organization = FactoryGirl.create(:organization) end it "remove a relationships_organization_user" do @user.favorite!(@organization) expect { delete :unfavorite, { :organization_id => @organization.to_param } }.to change(Relationships::OrganizationUser, :count).by(-1) end it "should call favorite! on the user model" do expect_any_instance_of(User).to receive(:unfavorite!).with(@organization) delete :unfavorite, { :organization_id => @organization.to_param } end it "should redirect to the organization" do delete :unfavorite, { :organization_id => @organization.to_param } expect(response).to redirect_to(@organization) end it "should be successful when given a js call" do delete :unfavorite, { :organization_id => @organization.to_param, :format => :js } expect(response).to be_successful end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/controllers/api/v1/organizations_controller_spec.rb
spec/controllers/api/v1/organizations_controller_spec.rb
require 'rails_helper' describe Api::V1::OrganizationsController, :type => :controller do render_views describe "GET 'index'" do before(:each) do @organization = FactoryGirl.create(:organization) end it "returns http success" do get 'index', :format => :json expect(response).to be_success end it "should return 500 if only latitude, longitude and no radius" do get 'index', :latitude => @organization.latitude, :longitude => @organization.longitude, :format => :json expect(response).not_to be_success expect(response.status).to eq(500) end it "should be successful if given all of latitude, longitude, and radius" do get 'index', :latitude => @organization.latitude, :longitude => @organization.longitude, :radius => 20, :format => :json expect(response).to be_success expect(assigns(:organizations)).to include(@organization) end end describe "GET 'show'" do it "returns http success" do organization = FactoryGirl.create(:organization) get 'show', :id => organization.to_param, :format => :json expect(response).to be_success end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/controllers/api/v1/pages_controller_spec.rb
spec/controllers/api/v1/pages_controller_spec.rb
require 'rails_helper' describe Api::V1::PagesController, :type => :controller do render_views describe "GET 'documentation'" do it "returns http success" do get 'documentation' expect(response).to be_success end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/models/review_spec.rb
spec/models/review_spec.rb
# == Schema Information # Schema version: 20130424042424 # # Table name: reviews # # id :integer not null, primary key # rating :integer # content :text # user_id :integer # condition_id :integer # organization_id :integer # created_at :datetime not null # updated_at :datetime not null # require 'rails_helper' describe Review, :type => :model do describe "validations" do it "should be valid" do expect(FactoryGirl.build(:review)).to be_valid end it "should not be valid without content" do expect(FactoryGirl.build(:review, :content => nil)).not_to be_valid end it "should not be valid without a rating" do expect(FactoryGirl.build(:review, :rating => nil)).not_to be_valid end it "should not be valid without a user_id" do expect(FactoryGirl.build(:review, :user_id => nil)).not_to be_valid end it "should not be valid without a condition_id" do expect(FactoryGirl.build(:review, :condition_id => nil)).not_to be_valid end it "should not be valid without an organization_id" do expect(FactoryGirl.build(:review, :organization_id => nil)).not_to be_valid end end describe "database relationships" do it "should respond to user" do expect(FactoryGirl.build(:review)).to respond_to(:user) end it "should respond to organization" do expect(FactoryGirl.build(:review)).to respond_to(:organization) end end describe "scopes" do it "should respond to with_condition" do expect(Review).to respond_to(:with_condition) end it "should respond to reverse_chronological" do expect(Review).to respond_to(:reverse_chronological) end it "should return only the Cache::ReviewStat with that condition" do r1 = FactoryGirl.create(:review, :condition_id => 1) r2 = FactoryGirl.create(:review, :condition_id => 2) expect(Review.with_condition(1)).to eq([r1]) end end describe "callbacks" do describe "update_cache!" do before(:each) do @organization = FactoryGirl.create(:organization) end it "should send update_cache to the organization model" do condition_id = 1 expect(@organization).to receive(:update_cache!).with(condition_id).once FactoryGirl.create(:review, :organization => @organization, :condition_id => condition_id) end it "should send update_cache to the organization model on an update" do condition_id = 1 review = FactoryGirl.create(:review, :organization => @organization, :condition_id => condition_id) expect(@organization).to receive(:update_cache!).with(condition_id).once review.rating = 2 review.save! end it "should not send update_cache to the organization model on an update if the rating didn't change" do condition_id = 1 review = FactoryGirl.create(:review, :organization => @organization, :condition_id => condition_id) expect(@organization).not_to receive(:update_cache!).with(condition_id) review.content = "foo" review.save! end it "should send update_cache to the organization model on destroy" do condition_id = 1 review = FactoryGirl.create(:review, :organization => @organization, :condition_id => condition_id) expect(@organization).to receive(:update_cache!).with(condition_id).once review.destroy end it "should send update_cahce to the organization model twice if the condition_id is changed" do condition_id = 1 new_condition_id = 2 review = FactoryGirl.create(:review, :organization => @organization, :condition_id => condition_id) expect(@organization).to receive(:update_cache!).with(condition_id) expect(@organization).to receive(:update_cache!).with(new_condition_id) review.condition_id = new_condition_id review.save! end end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/models/organization_spec.rb
spec/models/organization_spec.rb
# == Schema Information # Schema version: 20130501180835 # # Table name: organizations # # id :integer not null, primary key # name :string(255) # url :string(255) # url_type :string(255) # latitude :float # longitude :float # created_at :datetime not null # updated_at :datetime not null # category_id :integer # address :string(255) # display_location :string(255) # homepage_url :string(255) # require 'rails_helper' describe Organization, :type => :model do describe "validation" do it "should be valid" do expect(FactoryGirl.build(:organization)).to be_valid end it "should not be valid without a category_id" do expect(FactoryGirl.build(:organization, :category_id => nil)).not_to be_valid end it "should not be valid without a name" do expect(FactoryGirl.build(:organization, :name => nil)).not_to be_valid end it "should not be valid without a url" do expect(FactoryGirl.build(:organization, :url => nil)).not_to be_valid end it "should not be valid with the smae url" do organization = FactoryGirl.create(:organization) expect(FactoryGirl.build(:organization, :url => organization.url)).not_to be_valid end it "should be valid with a homepage_url" do expect(FactoryGirl.build(:organization, :homepage_url => "http://www.google.com")).to be_valid end it "should be valid without a homepage_url" do expect(FactoryGirl.build(:organization, :homepage_url => nil)).to be_valid end it "should be valid with a homepage_url sans http" do organization = FactoryGirl.build(:organization, :homepage_url => "www.google.com") expect(organization).to be_valid expect(organization.homepage_url).to eq("http://www.google.com") end it "should not be valid with an invaid homepage_url" do expect(FactoryGirl.build(:organization, :homepage_url => "foo")).not_to be_valid end end describe "database relationships" do it "should respond to organization_user_relationships" do expect(FactoryGirl.build(:organization)).to respond_to(:organization_user_relationships) end it "should respond to reviews" do expect(FactoryGirl.build(:organization)).to respond_to(:reviews) end it "should respond to users" do expect(FactoryGirl.build(:organization)).to respond_to(:users) end it "should respond to cache_review_stats" do expect(FactoryGirl.build(:organization)).to respond_to(:cache_review_stats) end end describe "geocoder" do it "should set the lat/lon" do organization = FactoryGirl.create(:organization, :address => "19081", :latitude => nil, :longitude => nil) expect(organization.latitude).to eq(40.7143528) expect(organization.longitude).to eq(-74.0059731) end end describe "clean_url" do describe "yelp" do it "should remove the url_params" do organization = FactoryGirl.create(:organization, :url => "http://www.yelp.com/biz/12?a=b") expect(organization.url_type).to eq("yelp") expect(organization.url).to eq("http://www.yelp.com/biz/12") end it "should remove the url_params without http://" do organization = FactoryGirl.create(:organization, :url => "www.yelp.com/biz/12?a=b") expect(organization.url_type).to eq("yelp") expect(organization.url).to eq("http://www.yelp.com/biz/12") end end describe "non-yelp" do it "should not be valid" do organization = FactoryGirl.build(:organization, :url => "http://www.yelp.com/bz/12?a=b") expect(organization).not_to be_valid end end end describe "class methods" do describe "with_url" do it "should return the organization with the same url" do organization = FactoryGirl.create(:organization) expect(Organization.with_url(organization.url)).to eq(organization) end it "should return nil if there is no organization with that url" do organization = FactoryGirl.create(:organization) expect(Organization.with_url(organization.url[0..-2])).to be_nil end end describe "category_text" do it "should return 'other'" do expect(Organization.category_text(0)).to eq("other") end end end describe "instance methods" do describe "update_cache!" do it "should respond_to update_cache!" do expect(FactoryGirl.build(:organization)).to respond_to(:update_cache!) end it "should create a new Cache::ReviewStat" do organization = FactoryGirl.create(:organization) condition_id = 1 expect { organization.update_cache!(condition_id) }.to change(Cache::ReviewStat, :count).by(1) expect(Cache::ReviewStat.last.condition_id).to eq(condition_id) end it "should not create a new Cache::ReviewStat if it already exists" do organization = FactoryGirl.create(:organization) condition_id = 1 review_cache = FactoryGirl.create(:cache_review_stat, :organization => organization, :condition_id => condition_id) expect { organization.update_cache!(condition_id) }.to_not change(Cache::ReviewStat, :count) end it "should set the num_reviews and average review" do organization = FactoryGirl.create(:organization) condition_id = 1 review_cache = FactoryGirl.create(:cache_review_stat, :organization => organization, :condition_id => condition_id) review1 = FactoryGirl.create(:review, :organization => organization, :condition_id => condition_id, :rating => 3) review2 = FactoryGirl.create(:review, :organization => organization, :condition_id => condition_id, :rating => 2) organization.update_cache!(condition_id) review_cache.reload expect(review_cache.num_reviews).to eq(2) expect(review_cache.avg_review).to eq(2.5) end it "should not set the avg_review to nil when there are no reviews" do organization = FactoryGirl.create(:organization) condition_id = 1 review_cache = FactoryGirl.create(:cache_review_stat, :organization => organization, :condition_id => condition_id) organization.update_cache!(condition_id) review_cache.reload expect(review_cache.num_reviews).to eq(0) expect(review_cache.avg_review).to eq(0) end end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/models/user_spec.rb
spec/models/user_spec.rb
# == Schema Information # Schema version: 20130424193539 # # Table name: users # # id :integer not null, primary key # email :string(255) default(""), not null # encrypted_password :string(255) default(""), not null # reset_password_token :string(255) # reset_password_sent_at :datetime # remember_created_at :datetime # sign_in_count :integer default(0) # current_sign_in_at :datetime # last_sign_in_at :datetime # current_sign_in_ip :string(255) # last_sign_in_ip :string(255) # authentication_token :string(255) # username :string(255) default(""), not null # created_at :datetime not null # updated_at :datetime not null # admin :boolean default(FALSE) # require 'rails_helper' describe User, :type => :model do describe "validations" do it "should be valid" do expect(FactoryGirl.build(:user)).to be_valid end it "should not be valid without an email" do expect(FactoryGirl.build(:user, :email => nil)).not_to be_valid end it "should not be valid without a username" do expect(FactoryGirl.build(:user, :username => nil)).not_to be_valid end it "should not be valid with a username that has already been taken" do user1 = FactoryGirl.create(:user) expect(FactoryGirl.build(:user, :username => user1.username)).not_to be_valid end it "should not be valid with a username that has whitespace" do expect(FactoryGirl.build(:user, :username => "be cool")).not_to be_valid end end describe "database relationships" do it "should respond to organization_user_relationships" do expect(FactoryGirl.build(:user)).to respond_to(:organization_user_relationships) end it "should respond to favorite_organizations" do expect(FactoryGirl.build(:user)).to respond_to(:favorite_organizations) end end describe "instance methods" do describe "favorite organizations" do describe "method existance" do it "should respond to favorite!" do expect(FactoryGirl.build(:user)).to respond_to(:favorite!) end it "should respond to unfavorite!" do expect(FactoryGirl.build(:user)).to respond_to(:unfavorite!) end it "should respond to favorited?" do expect(FactoryGirl.build(:user)).to respond_to(:favorited?) end end describe "relationship changes" do before(:each) do @user = FactoryGirl.create(:user) @organization = FactoryGirl.create(:organization) end it "should create a Relationships::OrganizationUser" do expect { @user.favorite!(@organization) }.to change(Relationships::OrganizationUser, :count).by(1) end it "should not create a Relationships::OrganizationUser" do @user.favorite!(@organization) expect { @user.favorite!(@organization) }.to_not change(Relationships::OrganizationUser, :count) end it "should destroy a Relationships::OrganizationUser" do @user.favorite!(@organization) expect { @user.unfavorite!(@organization) }.to change(Relationships::OrganizationUser, :count).by(-1) end it "should not destroy a Relationships::OrganizationUser" do expect { @user.unfavorite!(@organization) }.to_not change(Relationships::OrganizationUser, :count) end it "should return true if the user has favorited an @organization" do @user.favorite!(@organization) res = @user.favorited?(@organization) expect(!!res).to eq(true) end it "should return false if the user has not favorited an @organization" do res = @user.favorited?(@organization) expect(!!res).to eq(false) end end end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/models/cache/review_stat_spec.rb
spec/models/cache/review_stat_spec.rb
# == Schema Information # Schema version: 20130501214342 # # Table name: cache_review_stats # # id :integer not null, primary key # organization_id :integer # num_reviews :integer default(0) # avg_review :float default(0.0) # condition_id :integer # created_at :datetime not null # updated_at :datetime not null # require 'rails_helper' describe Cache::ReviewStat, :type => :model do describe "validations" do it "should be valid" do expect(FactoryGirl.build(:cache_review_stat)).to be_valid end it "should not be valid without an organization_id" do expect(FactoryGirl.build(:cache_review_stat, :organization_id => nil)).not_to be_valid end it "should not be valid without a condition_id" do expect(FactoryGirl.build(:cache_review_stat, :condition_id => nil)).not_to be_valid end end describe "database relationships" do it "should respond to organization" do expect(FactoryGirl.build(:cache_review_stat)).to respond_to(:organization) end end describe "scopes" do it "should respond to with_condition" do expect(Cache::ReviewStat).to respond_to(:with_condition) end it "should return only the Cache::ReviewStat with that condition" do rc1 = FactoryGirl.create(:cache_review_stat, :condition_id => 1) rc2 = FactoryGirl.create(:cache_review_stat, :condition_id => 2) expect(Cache::ReviewStat.with_condition(1)).to eq([rc1]) end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/spec/models/relationships/organization_user_spec.rb
spec/models/relationships/organization_user_spec.rb
# == Schema Information # Schema version: 20130423230554 # # Table name: relationships_organization_users # # id :integer not null, primary key # organization_id :integer # user_id :integer # created_at :datetime not null # updated_at :datetime not null # require 'rails_helper' describe Relationships::OrganizationUser, :type => :model do describe "validations" do it "should be valid" do expect(FactoryGirl.build(:relationships_organization_user)).to be_valid end it "should not be valid without an organization_id" do expect(FactoryGirl.build(:relationships_organization_user, :organization_id => nil)).not_to be_valid end it "should not be valid without a user_id" do expect(FactoryGirl.build(:relationships_organization_user, :user_id => nil)).not_to be_valid end end describe "database relationships" do it "should respond_to :organization" do expect(FactoryGirl.build(:relationships_organization_user)).to respond_to(:organization) end it "should respond_to :user" do expect(FactoryGirl.build(:relationships_organization_user)).to respond_to(:user) end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/lib/development_mail_interceptor.rb
lib/development_mail_interceptor.rb
class DevelopmentMailInterceptor def self.delivering_email(message) message.subject = "#{message.to} #{message.subject}" message.to = ENV["SMTP_DEV_EMAIL"] end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/lib/capistrano/tasks/helper.rb
lib/capistrano/tasks/helper.rb
def template(filename) File.read(File.expand_path("../../templates/#{filename}", __FILE__)) end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/application.rb
config/application.rb
require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "sprockets/railtie" # require "rails/test_unit/railtie" Bundler.require(:default, Rails.env) module RevTilt class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. # config.autoload_paths += %W(#{config.root}/extras) # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Activate observers that should always be running. # config.active_record.observers = :cacher, :garbage_collector, :forum_observer # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de config.i18n.enforce_available_locales = true # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] # Enable escaping HTML in JSON. config.active_support.escape_html_entities_in_json = true # Use SQL instead of Active Record's schema dumper when creating the database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql # Enforce whitelist mode for mass assignment. # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. # config.active_record.whitelist_attributes = true # Enable the asset pipeline # config.assets.enabled = true # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' config.assets.initialize_on_precompile = false ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe # add nokogiri gem to Gemfile elements = Nokogiri::HTML::DocumentFragment.parse(html_tag).css "label, input, textarea" elements.each do |e| if e.node_name.eql? 'label' e["data-error"] = "true" html = %(#{e}).html_safe elsif e.node_name.eql? 'input' or e.node_name.eql? 'textarea' if instance.error_message.kind_of?(Array) e["data-error"] = %(#{instance.error_message.join(',')}) html = %(#{e}).html_safe else e["data-error"] = %(#{instance.error_message}) html = %(#{e}).html_safe end end end html end end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/environment.rb
config/environment.rb
# Load the rails application require File.expand_path('../application', __FILE__) APP_CONFIG = YAML.load_file("#{Rails.root.to_s}/config/config.yml") # To prevent log buffering $stdout.sync = true # Initialize the rails application RevTilt::Application.initialize!
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/routes.rb
config/routes.rb
RevTilt::Application.routes.draw do root :to => "pages#about" devise_for :users get "/about" => "pages#about" get "/bookmarklet" => "pages#bookmarklet" get "/favorites" => "pages#favorites" get "/press" => "pages#press" resources :organizations resources :reviews namespace :relationships do resources :organization_users do collection do post :favorite delete :unfavorite end end end namespace :api do namespace :v1 do get "/documentation" => "pages#documentation" resources :organizations, :only => [:index, :show] end end # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase # This route can be invoked with purchase_url(:id => product.id) # Sample resource route (maps HTTP verbs to controller actions automatically): # resources :products # Sample resource route with options: # resources :products do # member do # get 'short' # post 'toggle' # end # # collection do # get 'sold' # end # end # Sample resource route with sub-resources: # resources :products do # resources :comments, :sales # resource :seller # end # Sample resource route with more complex sub-resources # resources :products do # resources :comments # resources :sales do # get 'recent', :on => :collection # end # end # Sample resource route within a namespace: # namespace :admin do # # Directs /admin/products/* to Admin::ProductsController # # (app/controllers/admin/products_controller.rb) # resources :products # end # You can have the root of your site routed with "root" # just remember to delete public/index.html. # root :to => 'welcome#index' # See how all your routes lay out with "rake routes" # This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. # match ':controller(/:action(/:id))(.:format)' end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/deploy.rb
config/deploy.rb
set :application, 'revtilt' set :repo_url, 'git@github.com:cyrusstoller/RevTilt.git' # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } set :branch, proc { ENV["REVISION"] || ENV["BRANCH_NAME"] || "master" } set :deploy_to, '/var/www/revtilt' set :scm, :git set :format, :pretty set :log_level, :debug set :pty, true set :linked_files, %w{config/database.yml .env} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/assets public/system} # set :default_env, { path: "/opt/ruby/bin:$PATH" } set :keep_releases, 10 set :rbenv_type, :user set :rbenv_ruby, '2.1.2' set :bundle_flags, "--deployment" # removing the --quiet flag set :nginx_conf_path, -> { shared_path.join("config/nginx.conf") } namespace :deploy do desc "Restart application" task :restart do invoke "unicorn:restart" end after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # Here we can do anything such as: # within release_path do # execute :rake, 'cache:clear' # end end end after :publishing, :restart after :finishing, 'deploy:cleanup' end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/unicorn.rb
config/unicorn.rb
if ENV["RAILS_ENV"] == "development" worker_processes 1 else worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) end timeout 15 # recommended by Heroku https://devcenter.heroku.com/articles/rails-unicorn preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/boot.rb
config/boot.rb
# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/filter_parameter_logging.rb
config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password, :password_confirmation]
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/geocoder.rb
config/initializers/geocoder.rb
Geocoder::Configuration.lookup = :bing Geocoder::Configuration.api_key = ENV["BING_MAPS_API_KEY"] if Rails.env.test? Geocoder.configure(:lookup => :test) Geocoder::Lookup::Test.set_default_stub( [ { 'latitude' => 40.7143528, 'longitude' => -74.0059731, 'address' => 'New York, NY, USA', 'state' => 'New York', 'state_code' => 'NY', 'country' => 'United States', 'country_code' => 'US', 'postal_code' => '10038' } ] ) end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/quiet_assets.rb
config/initializers/quiet_assets.rb
if Rails.env.development? Rails.application.assets.logger = Logger.new('/dev/null') Rails::Rack::Logger.class_eval do def call_with_quiet_assets(env) previous_level = Rails.logger.level Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/} call_without_quiet_assets(env) ensure Rails.logger.level = previous_level end alias_method_chain :call, :quiet_assets end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/session_store.rb
config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. RevTilt::Application.config.session_store :cookie_store, key: '_RevTilt_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") # RevTilt::Application.config.session_store :active_record_store
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/devise.rb
config/initializers/devise.rb
# Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. config.mailer_sender = "revtilt@gmail.com" config.secret_key = ENV["DEVISE_SECRET_TOKEN"] || '20c1671c51213190e074a9063c175066dda98fa21cbe027154e01921001f9f7939b96f0bdcfd7edcbd39d6c9f6bc9b8ccc18b2bacde171276c5ae11a7fa7740a' # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. require 'devise/orm/active_record' # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating a user. The default is # just :email. You can configure it to use [:username, :subdomain], so for # authenticating a user, both parameters are required. Remember that those # parameters are used only when authenticating and not when retrieving from # session. If you need permissions, you should implement that in a before filter. # You can also supply a hash where the value is a boolean determining whether # or not authentication should be aborted when the value is not present. # config.authentication_keys = [ :email ] # Configure parameters from the request object used for authentication. Each entry # given should be a request method and it will automatically be passed to the # find_for_authentication method and considered in your model lookup. For instance, # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. # The same considerations mentioned for authentication_keys also apply to request_keys. # config.request_keys = [] # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. config.case_insensitive_keys = [ :email ] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. config.strip_whitespace_keys = [ :email, :username ] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the # given strategies, for example, `config.params_authenticatable = [:database]` will # enable it only for database (email + password) authentication. # config.params_authenticatable = true # Tell if authentication through HTTP Basic Auth is enabled. False by default. # It can be set to an array that will enable http authentication only for the # given strategies, for example, `config.http_authenticatable = [:token]` will # enable it only for token authentication. # config.http_authenticatable = false # If http headers should be returned for AJAX requests. True by default. # config.http_authenticatable_on_xhr = true # The realm used in Http Basic Authentication. "Application" by default. # config.http_authentication_realm = "Application" # It will change confirmation, password recovery and other workflows # to behave the same regardless if the e-mail provided was right or wrong. # Does not affect registerable. # config.paranoid = true # By default Devise will store the user in session. You can skip storage for # :http_auth and :token_auth by adding those symbols to the array below. # Notice that if you are skipping storage for all authentication paths, you # may want to disable generating routes to Devise's sessions controller by # passing :skip => :sessions to `devise_for` in your config/routes.rb config.skip_session_storage = [:http_auth] # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. # # Limiting the stretches to just one in testing will increase the performance of # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use # a value less than 10 in other environments. config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. # config.pepper = "dd00fa61dc79c032aa096b315ccbb6d9c6c18d7c7ae7694744e8907241bba408b7f2292222d01588ba44734e37371e6834f46fe90cafa936304fac1bb719e794" # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without # confirming his account. For instance, if set to 2.days, the user will be # able to access the website for two days without confirming his account, # access will be blocked just in the third day. Default is 0.days, meaning # the user cannot access the website without confirming his account. # config.allow_unconfirmed_access_for = 2.days # A period that the user is allowed to confirm their account before their # token becomes invalid. For example, if set to 3.days, the user can confirm # their account within 3 days after the mail was sent, but on the fourth day # their account can't be confirmed with the token any more. # Default is nil, meaning there is no restriction on how long a user can take # before confirming their account. # config.confirm_within = 3.days # If true, requires any email changes to be confirmed (exactly the same way as # initial account confirmation) to be applied. Requires additional unconfirmed_email # db field (see migrations). Until confirmed new email is stored in # unconfirmed email column, and copied to email column on successful confirmation. config.reconfirmable = true # Defines which key will be used when confirming an account # config.confirmation_keys = [ :email ] # ==> Configuration for :rememberable # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false # Options to be passed to the created cookie. For instance, you can set # :secure => true in order to force SSL only cookies. # config.rememberable_options = {} # ==> Configuration for :validatable # Range for password length. Default is 8..128. config.password_length = 8..128 # Email regex used to validate email formats. It simply asserts that # an one (and only one) @ exists in the given string. This is mainly # to give user feedback and not to assert the e-mail validity. # config.email_regexp = /\A[^@]+@[^@]+\z/ # ==> Configuration for :timeoutable # The time you want to timeout the user session without activity. After this # time the user will be asked for credentials again. Default is 30 minutes. # config.timeout_in = 30.minutes # If true, expires auth token on session timeout. # config.expire_auth_token_on_timeout = false # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. # :failed_attempts = Locks an account after a number of failed attempts to sign in. # :none = No lock strategy. You should handle locking by yourself. # config.lock_strategy = :failed_attempts # Defines which key will be used when locking and unlocking an account # config.unlock_keys = [ :email ] # Defines which strategy will be used to unlock an account. # :email = Sends an unlock link to the user email # :time = Re-enables login after a certain amount of time (see :unlock_in below) # :both = Enables both strategies # :none = No unlock strategy. You should handle unlocking by yourself. # config.unlock_strategy = :both # Number of authentication tries before locking an account if lock_strategy # is failed attempts. # config.maximum_attempts = 20 # Time interval to unlock the account if :time is enabled as unlock_strategy. # config.unlock_in = 1.hour # ==> Configuration for :recoverable # # Defines which key will be used when recovering the password for an account # config.reset_password_keys = [ :email ] # Time interval you can reset your password with a reset password key. # Don't put a too small interval or your users won't have the time to # change their passwords. config.reset_password_within = 6.hours # ==> Configuration for :encryptable # Allow you to use another encryption algorithm besides bcrypt (default). You can use # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) # and :restful_authentication_sha1 (then you should set stretches to 10, and copy # REST_AUTH_SITE_KEY to pepper) # config.encryptor = :sha512 # ==> Configuration for :token_authenticatable # Defines name of the authentication token params key # config.token_authentication_key = :auth_token # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you # are using only default views. # config.scoped_views = false # Configure the default scope given to Warden. By default it's the first # devise role declared in your routes (usually :user). # config.default_scope = :user # Set this configuration to false if you want /users/sign_out to sign out # only the current scope. By default, Devise signs out all scopes. # config.sign_out_all_scopes = true # ==> Navigation configuration # Lists the formats that should be treated as navigational. Formats like # :html, should redirect to the sign in page when the user does not have # access, but formats like :xml or :json, should return 401. # # If you have any extra navigational formats, like :iphone or :mobile, you # should add them to the navigational formats lists. # # The "*/*" below is required to match Internet Explorer requests. # config.navigational_formats = ["*/*", :html] # The default HTTP method used to sign out a resource. Default is :delete. config.sign_out_via = :delete # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or # change the failure app, you can configure them inside the config.warden block. # # config.warden do |manager| # manager.intercept_401 = false # manager.default_strategies(:scope => :user).unshift :some_external_strategy # end # ==> Mountable engine configurations # When using Devise inside an engine, let's call it `MyEngine`, and this engine # is mountable, there are some extra configurations to be taken into account. # The following options are available, assuming the engine is mounted as: # # mount MyEngine, at: "/my_engine" # # The router that invoked `devise_for`, in the example above, would be: # config.router_name = :my_engine # # When using omniauth, Devise cannot automatically set Omniauth path, # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = "/my_engine/users/auth" end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/wrap_parameters.rb
config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end # Disable root element in JSON by default. ActiveSupport.on_load(:active_record) do self.include_root_in_json = false end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/inflections.rb
config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections do |inflect| # inflect.acronym 'RESTful' # end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/setup_mail.rb
config/initializers/setup_mail.rb
require 'mail' ActionMailer::Base.smtp_settings = { :address => ENV["SMTP_ADDRESS"], :port => 587, :domain => ENV['SMTP_DOMAIN'], :authentication => :plain, :user_name => ENV['SMTP_USERNAME'], :password => ENV['SMTP_PASSWORD'], :enable_starttls_auto => true } require File.join( Rails.root, 'lib', 'development_mail_interceptor') Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/backtrace_silencers.rb
config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/mime_types.rb
config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/initializers/secret_token.rb
config/initializers/secret_token.rb
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. RevTilt::Application.config.secret_token = ENV["SECRET_TOKEN"] || 'd6a6b620234550a82ec820e7842ca296937a10c1bc8054ba9684bc771d4919055a19a6e96155f7b16838d1e1e4e62f71478ab7e75c33767998c8fb791034254f' # will be removed shortly RevTilt::Application.config.secret_key_base = ENV["SECRET_TOKEN"] || 'd6a6b620234550a82ec820e7842ca296937a10c1bc8054ba9684bc771d4919055a19a6e96155f7b16838d1e1e4e62f71478ab7e75c33767998c8fb791034254f'
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/deploy/production.rb
config/deploy/production.rb
set :stage, :production # Simple Role Syntax # ================== # Supports bulk-adding hosts to roles, the primary # server in each group is considered to be the first # unless any hosts have the primary property set. role :app, %w{deployer@alpha.revtilt.com} role :web, %w{deployer@alpha.revtilt.com} role :db, %w{deployer@alpha.revtilt.com} set :rails_env, :production # Extended Server Syntax # ====================== # This can be used to drop a more detailed server # definition into the server list. The second argument # something that quacks like a hash can be used to set # extended properties on the server. # server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value # you can set custom ssh options # it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options # you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start) # set it globally # set :ssh_options, { # keys: %w(/home/rlisowski/.ssh/id_rsa), # forward_agent: false, # auth_methods: %w(password) # } # and/or per server # server 'example.com', # user: 'user_name', # roles: %w{web app}, # ssh_options: { # user: 'user_name', # overrides user setting above # keys: %w(/home/user_name/.ssh/id_rsa), # forward_agent: false, # auth_methods: %w(publickey password) # # password: 'please use keys' # } # setting per server overrides global ssh_options fetch(:default_env).merge!(rails_env: :production)
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/deploy/vagrant.rb
config/deploy/vagrant.rb
set :stage, :vagrant # Simple Role Syntax # ================== # Supports bulk-adding hosts to roles, the primary # server in each group is considered to be the first # unless any hosts have the primary property set. role :app, %w{deployer@192.168.33.11} role :web, %w{deployer@192.168.33.11} role :db, %w{deployer@192.168.33.11} set :rails_env, :production # Extended Server Syntax # ====================== # This can be used to drop a more detailed server # definition into the server list. The second argument # something that quacks like a hash can be used to set # extended properties on the server. # server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value # you can set custom ssh options # it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options # you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start) # set it globally # set :ssh_options, { # keys: %w(/home/rlisowski/.ssh/id_rsa), # forward_agent: false, # auth_methods: %w(password) # } # and/or per server # server 'example.com', # user: 'user_name', # roles: %w{web app}, # ssh_options: { # user: 'user_name', # overrides user setting above # keys: %w(/home/user_name/.ssh/id_rsa), # forward_agent: false, # auth_methods: %w(publickey password) # # password: 'please use keys' # } # setting per server overrides global ssh_options fetch(:default_env).merge!(rails_env: :production)
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/environments/test.rb
config/environments/test.rb
RevTilt::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure static asset server for tests with Cache-Control for performance config.serve_static_files = true config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Don't actually send emails config.action_mailer.perform_deliveries = false # ActionMailer config.action_mailer.default_url_options = { :host => 'test.host' } # Print deprecation notices to the stderr config.active_support.deprecation = :stderr end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/environments/development.rb
config/environments/development.rb
RevTilt::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # # Log error messages when you accidentally call methods on nil. # config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false # Actually send emails config.action_mailer.perform_deliveries = true # Print deprecation notices to the Rails logger config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations config.active_record.migration_error = :page_load # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin # Do not compress assets config.assets.compress = false # Expands the lines which load the assets config.assets.debug = true # Devise config.action_mailer.default_url_options = { :host => 'localhost:5000' } # Unicorn logging - based on http://dave.is/unicorn.html # config.logger = Logger.new(STDOUT) # config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'DEBUG') config.middleware.insert_after(Rails::Rack::Logger, Rails::Rack::LogTailer, "log/development.log") end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/environments/staging.rb
config/environments/staging.rb
RevTilt::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both thread web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. # config.action_dispatch.rack_cache = true # Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_files = false # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Generate digests for assets URLs. config.assets.digest = true # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' # Defaults to nil and saved in location specified by config.assets.prefix # config.assets.manifest = YOUR_PATH # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Set to :debug to see everything in the log. config.log_level = :debug # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true # Send deprecation notices to registered listeners config.active_support.deprecation = :notify # Disable automatic flushing of the log to improve performance. # config.autoflush_log = false # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Devise config.action_mailer.default_url_options = { :host => 'staging.revtilt.com' } # Actually send emails config.action_mailer.perform_deliveries = true # # Unicorn logging on Heroku - http://help.papertrailapp.com/discussions/questions/116-logging-from-heroku-apps-using-unicorn # config.logger = Logger.new(STDOUT) # config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO') config.middleware.insert_after(::ActionDispatch::Static, "::Rack::Auth::Basic", "Not for public eyes") do |u, p| u == ENV["admin_user"] && p == ENV["admin_password"] end end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
cyrusstoller/RevTilt
https://github.com/cyrusstoller/RevTilt/blob/c3fd80e411c3de72e9c9479474774d6cdcab888d/config/environments/production.rb
config/environments/production.rb
RevTilt::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both thread web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. # config.action_dispatch.rack_cache = true # Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_files = false # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Generate digests for assets URLs. config.assets.digest = true # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' # Defaults to nil and saved in location specified by config.assets.prefix # config.assets.manifest = YOUR_PATH # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Set to :debug to see everything in the log. config.log_level = :info # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true # Send deprecation notices to registered listeners config.active_support.deprecation = :notify # Disable automatic flushing of the log to improve performance. # config.autoflush_log = false # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Devise config.action_mailer.default_url_options = { :host => 'revtilt.com' } # Actually send emails config.action_mailer.perform_deliveries = true # # Unicorn logging on Heroku - http://help.papertrailapp.com/discussions/questions/116-logging-from-heroku-apps-using-unicorn # config.logger = Logger.new(STDOUT) # config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO') end
ruby
MIT
c3fd80e411c3de72e9c9479474774d6cdcab888d
2026-01-04T17:44:55.378213Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/spec_helper.rb
spec/spec_helper.rb
# This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause this # file to always be loaded, without a need to explicitly require it in any files. # # Given that it is always loaded, you are encouraged to keep this file as # light-weight as possible. Requiring heavyweight dependencies from this file # will add to the boot time of your test suite on EVERY test run, even for an # individual file that may not need all of that loaded. Instead, make a # separate helper file that requires this one and then use it only in the specs # that actually need it. # # The `.rspec` file also contains a few flags that are not defaults but that # users commonly want. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration if ENV["CI"] require "simplecov" require "coveralls" SimpleCov.formatter = Coveralls::SimpleCov::Formatter SimpleCov.start do %w[spec].each do |ignore_path| add_filter(ignore_path) end end end $LOAD_PATH.unshift File.expand_path("../lib", __dir__) # FIXME: NameError: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger when activesupport < 7.1 require "logger" require "rubicure" require "rspec" require "rspec-parameterized" require "rspec/its" require "rspec/collection_matchers" require "delorean" require "tempfile" # NOTE: requires minimum dependencies require "active_support/core_ext/string/filters" require "active_support/core_ext/time/zones" # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir["#{__dir__}/support/**/*.rb"].sort.each {|f| require f } Time.zone = "Tokyo" RSpec.configure do |config| # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. # # These two settings work together to allow you to limit a spec run # # to individual examples or groups you care about by tagging them with # # `:focus` metadata. When nothing is tagged with `:focus`, all examples # # get run. # config.filter_run :focus # config.run_all_when_everything_filtered = true # # # Many RSpec users commonly either run the entire suite or an individual # # file, and it's useful to allow more verbose output when running an # # individual spec file. # if config.files_to_run.one? # # RSpec filters the backtrace by default so as not to be so noisy. # # This causes the full backtrace to be printed when running a single # # spec file (e.g. to troubleshoot a particular spec failure). # config.full_backtrace = true # # # Use the documentation formatter for detailed output, # # unless a formatter has already been configured # # (e.g. via a command-line flag). # config.default_formatter = 'doc' # end # # # Print the 10 slowest examples and example groups at the # # end of the spec run, to help surface which specs are running # # particularly slow. # config.profile_examples = 10 # # # Run specs in random order to surface order dependencies. If you find an # # order dependency and want to debug it, you can fix the order by providing # # the seed, which is printed after each run. # # --seed 1234 # config.order = :random # # # Seed global randomization in this process using the `--seed` CLI option. # # Setting this allows you to use `--seed` to deterministically reproduce # # test failures related to randomization by passing the same `--seed` value # # as the one that triggered the failure. # Kernel.srand config.seed # # # rspec-expectations config goes here. You can use an alternate # # assertion/expectation library such as wrong or the stdlib/minitest # # assertions if you prefer. # config.expect_with :rspec do |expectations| # # Enable only the newer, non-monkey-patching expect syntax. # # For more details, see: # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax # expectations.syntax = :expect # end # # # rspec-mocks config goes here. You can use an alternate test double # # library (such as bogus or mocha) by changing the `mock_with` option here. # config.mock_with :rspec do |mocks| # # Enable only the newer, non-monkey-patching expect syntax. # # For more details, see: # # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ # mocks.syntax = :expect # # # Prevents you from mocking or stubbing a method that does not exist on # # a real object. This is generally recommended. # mocks.verify_partial_doubles = true # end config.order = :random config.include Delorean config.include TestUtil config.before do Rubicure::Girl.sleep_sec = 0 end config.after do back_to_the_present end end def spec_dir Pathname(__dir__) end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/support/util/test_util.rb
spec/support/util/test_util.rb
module TestUtil def time(str) Time.zone.parse(str) end def date(str) Date.parse(str) end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/config/series_checker_spec.rb
spec/config/series_checker_spec.rb
describe "config/series.yml" do # rubocop:disable RSpec/DescribeClass series = Rubicure::Concerns::Util.load_yaml_file("#{spec_dir}/../config/series.yml") series.values.uniq {|attributes| attributes["series_name"] }.each do |attributes| context attributes["title"] do describe "started_date" do subject { attributes["started_date"] } it { should be_sunday } end describe "ended_date", if: attributes["ended_date"] do subject { attributes["ended_date"] } it { should be_sunday } end end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/config/girls_checker_spec.rb
spec/config/girls_checker_spec.rb
describe "girls_checker" do # rubocop:disable RSpec/DescribeClass config_files = Pathname.glob("#{spec_dir}/../config/girls/*.yml") config_files.each do |config_file| describe "config/girls/#{config_file.basename}" do girls = Rubicure::Concerns::Util.load_yaml_file(config_file) girls.each do |girl_name, girl| describe girl_name do describe "#transform_message" do subject { girl["transform_message"] } it { should_not end_with("\n") } end describe "#attack_messages" do it "does not all end with(\\n)" do aggregate_failures do Array(girl["attack_messages"]).each do |attack_message| # NOTE: `expect().not_to all( matcher )` is not supported. expect(attack_message).not_to end_with("\n") end end end end describe "#birthday" do context "has birthday", if: girl.has_key?("birthday") do birthday = girl["birthday"] it { expect(birthday).not_to be_blank } it "'#{birthday}' is valid date" do ymd = "#{Date.today.year}/#{birthday}" expect(Date.parse(ymd)).to be_a Date end end end transform_calls = Array(girl["transform_calls"]) describe "#transform_calls", unless: transform_calls.empty? do subject { transform_calls } transform_calls.count.times do |n| its([n]) { should_not start_with "precure_" } its([n]) { should_not end_with "_precure" } its([n]) { should_not end_with "!" } end end end end end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/cure_scarlet_spec.rb
spec/rubicure/cure_scarlet_spec.rb
describe "Cure.scarlet" do # rubocop:disable RSpec/DescribeClass describe "!" do subject { !Cure.scarlet } let(:girl) { Cure.scarlet } after do girl.rollback girl.humanize! end context "called once" do it { expect { subject }.to change { girl.name }.from("紅城トワ").to("トワイライト") } end context "called twice" do before do !Cure.scarlet end it { expect { subject }.to change { girl.name }.from("トワイライト").to("紅城トワ") } end context "after transform" do before do girl.transform! end it { expect { subject }.to change { girl.name }.from("キュアスカーレット").to("トワイライト") } end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/series_spec.rb
spec/rubicure/series_spec.rb
describe Rubicure::Series do let(:series_names) do [ :unmarked, :max_heart, :splash_star, :yes, :yes_gogo, :fresh, :heart_catch, :suite, :smile, :dokidoki, :happiness_charge, :go_princess, :maho_girls, :a_la_mode, :hugtto, :star_twinkle, :healingood, :tropical_rouge, :delicious_party, :hirogaru_sky, :wonderful, :you_and_idol, ] end describe "#on_air?" do subject { series.on_air?(date) } context "when ended title" do let(:series) do Rubicure::Series[ started_date: Date.parse("2012-02-05"), ended_date: Date.parse("2013-01-27"), ] end context "when Date arg" do let(:date) { Date.parse("2013-01-01") } it { should be true } end context "when date like String arg" do let(:date) { "2013-01-01" } it { should be true } end end context "when live title" do let(:series) do Rubicure::Series[ started_date: Date.parse("2013-02-03"), ] end let(:date) { Date.parse("2013-12-01") } it { should be true } end end describe "#girls" do subject { series.girls } let(:series) do Rubicure::Series[ girls: %w[cure_happy cure_sunny cure_peace cure_march cure_beauty] ] end it { should have_exactly(5).girls } it { should all(be_instance_of Rubicure::Girl) } end # rubocop:disable Style/CaseEquality, Style/NilComparison describe "#===" do let(:series) { Rubicure::Series.find(series_name) } let(:series_name) { :smile } let(:girl) { Rubicure::Girl.find(girl_name) } let(:girl_name) { :peace } context "same series" do let(:same_series) { Rubicure::Series.find(series_name) } it { expect(series === same_series).to be true } it { expect(series === girl).to be true } end context "other series" do let(:other_series) { Rubicure::Series.find(:dokidoki) } let(:other_girl) { Rubicure::Girl.find(:passion) } it { expect(series === other_series).to be false } it { expect(series === other_girl).to be false } end context "other ruby object" do it { expect(series === Module).to be false } it { expect(series === Object.new).to be false } it { expect(series === :smile).to be false } it { expect(series === true).to be false } it { expect(series === nil).to be false } end end # rubocop:enable Style/CaseEquality, Style/NilComparison describe "#names" do subject { Rubicure::Series.names } it { should include(*series_names) } end describe "#uniq_names" do subject { Rubicure::Series.uniq_names } it { should include(*series_names) } its(:count) { should == series_names.count } end describe "#find" do subject { Rubicure::Series.find(series_name) } context "when exists" do let(:series_name) { :smile } its(:title) { should == "スマイルプリキュア!" } its(:girls) { should have_exactly(5).girls } its(:series_name) { should eq series_name.to_s } end context "when not exists" do let(:series_name) { :ashita_no_nadja } it { expect { subject }.to raise_error Rubicure::UnknownSeriesError } end end describe "#each" do subject { series.each } let(:series) { Rubicure::Series.find(series_name) } let(:series_name) { :splash_star } it { expect {|b| series.each(&b) }.to yield_successive_args(Rubicure::Girl, Rubicure::Girl) } end describe "#to_json" do subject { series.to_json } let(:series) { Rubicure::Series.find(series_name) } let(:series_name) { :splash_star } let(:json) do <<~JSON {"series_name":"splash_star","title":"ふたりはプリキュア Splash☆Star","started_date":"2006-02-05","ended_date":"2007-01-28","girls":["cure_bloom","cure_egret"]} JSON end it { should eq json.squish } end describe "#heisei?" do subject { series.heisei? } using RSpec::Parameterized::TableSyntax let(:series) { Rubicure::Series.find(series_name) } where(:series_name, :expected) do :hugtto | true :star_twinkle | true end with_them do it { should eq expected } end end describe "#reiwa?" do subject { series.reiwa? } using RSpec::Parameterized::TableSyntax let(:series) { Rubicure::Series.find(series_name) } where(:series_name, :expected) do :hugtto | false :star_twinkle | true end with_them do it { should eq expected } end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/cure_cosmo_spec.rb
spec/rubicure/cure_cosmo_spec.rb
describe "Cure.cosmo" do # rubocop:disable RSpec/DescribeClass let(:girl) { Cure.cosmo } after do girl.rollback end describe "#transform!" do context "with :rainbow_perfume" do subject { girl.transform!(:rainbow_perfume) } it "change to either マオ, ブルーキャット or バケニャーン" do subject expect(girl.name).to match(/^(マオ|ブルーキャット|バケニャーン)$/) end end context "without arg" do subject { girl.transform! } it { expect { subject }.to change { girl.name }.from("ユニ").to("キュアコスモ") } end end describe "#rollback" do subject { girl.rollback } it "rollback to ユニ" do girl.transform!(:rainbow_perfume) subject expect(girl.name).to eq "ユニ" end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/cure_passion_spec.rb
spec/rubicure/cure_passion_spec.rb
describe "Cure.passion" do # rubocop:disable RSpec/DescribeClass describe "!" do subject { !Cure.passion } let(:girl) { Cure.passion } after do girl.rollback girl.humanize! end context "called once" do it { expect { subject }.to change { girl.name }.from("東せつな").to("イース") } end context "called twice" do before do !Cure.passion end it { expect { subject }.to change { girl.name }.from("イース").to("東せつな") } end context "after transform" do before do girl.transform! end it { expect { subject }.to change { girl.name }.from("キュアパッション").to("イース") } end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/core_spec.rb
spec/rubicure/core_spec.rb
describe Rubicure::Core do let(:instance) { Rubicure::Core.instance } describe "#now" do subject { instance.now } context "when on air" do before do time_travel_to "2013-01-01" end its(:title) { should == "スマイルプリキュア!" } end context "when not on air" do before do time_travel_to "2013-02-01" end it { expect { subject }.to raise_error Rubicure::NotOnAirError } end end describe "#each_with_series" do it "enumerate order by series_name" do actual = [] instance.each_with_series do |series| actual << series.series_name end expect(actual).to eq Rubicure::Series.uniq_names.map(&:to_s) end end describe "#all_stars" do context "Without arg" do subject { instance.all_stars } let(:precure_count) { 43 } its(:count) { should == precure_count } end context "With arg" do subject { instance.all_stars(arg) } using RSpec::Parameterized::TableSyntax where(:arg, :expected_count, :include_cure_echo) do "2009-03-20" | 14 | false "2017-01-17" | 43 | false Date.parse("2010-03-20") | 17 | false Time.parse("2011-03-19") | 21 | false :dx | 14 | false :dx1 | 14 | false :dx2 | 17 | false :dx3 | 21 | false :ns | 29 | true :ns1 | 29 | true :new_stage | 29 | true :new_stage1 | 29 | true :ns2 | 32 | false :new_stage2 | 32 | false :ns3 | 37 | true :new_stage3 | 37 | true :sc | 40 | false :spring_carnival | 40 | false :stmm | 44 | true :sing_together_miracle_magic | 44 | true :memories | 55 | false # NOTE: キュアエコーを含めると79人なのだが、公式や各種メディアが78人と言っているのでキュアエコーは含めていない # c.f. https://twitter.com/precure_movie/status/1704691931094384957 :f | 78 | false end with_them do its(:count) { should == expected_count } it { expect(subject.include?(Cure.echo)).to be include_cure_echo } end end end describe "#all_girls" do context "Without arg" do subject { instance.all_girls } let(:precure_count) { 88 } its(:count) { should == precure_count } it { should include Cure.echo } end context "With arg" do subject { instance.all_girls(arg) } using RSpec::Parameterized::TableSyntax where(:arg, :expected_count, :include_cure_echo) do "2009-03-20" | 14 | false "2017-01-17" | 45 | true Date.parse("2010-03-20") | 17 | false Time.parse("2011-03-19") | 21 | false end with_them do its(:count) { should == expected_count } it { expect(subject.include?(Cure.echo)).to be include_cure_echo } end end end describe "#dream_stars" do subject { Precure.dream_stars.map(&:girl_name) } let(:dream_stars_girl_names) do [ Cure.flora, Cure.mermaid, Cure.twinkle, Cure.scarlet, Cure.miracle, Cure.magical, Cure.felice, Cure.whip, Cure.custard, Cure.gelato, Cure.macaron, Cure.chocolat, ].map(&:girl_name) end it { should match_array(dream_stars_girl_names) } end describe "#super_stars" do subject { Precure.super_stars.map(&:girl_name) } let(:super_stars_girl_names) do [ Cure.miracle, Cure.magical, Cure.felice, Cure.whip, Cure.custard, Cure.gelato, Cure.macaron, Cure.chocolat, Cure.parfait, Cure.yell, Cure.ange, Cure.etoile, ].map(&:girl_name) end it { should match_array(super_stars_girl_names) } end describe "#miracle_universe" do subject { Precure.miracle_universe.map(&:girl_name) } let(:miracle_universe_girl_names) do [ Cure.whip, Cure.custard, Cure.gelato, Cure.macaron, Cure.chocolat, Cure.parfait, Cure.yell, Cure.ange, Cure.etoile, Cure.macherie, Cure.amour, Cure.star, Cure.milky, Cure.soleil, Cure.selene, ].map(&:girl_name) end it { should match_array(miracle_universe_girl_names) } end describe "#miracle_leap" do subject { Precure.miracle_leap.map(&:girl_name) } let(:miracle_leap_girl_names) do [ Cure.yell, Cure.ange, Cure.etoile, Cure.macherie, Cure.amour, Cure.star, Cure.milky, Cure.soleil, Cure.selene, Cure.cosmo, Cure.grace, Cure.fontaine, Cure.sparkle, ].map(&:girl_name) end it { should match_array(miracle_leap_girl_names) } end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/cure_peace_spec.rb
spec/rubicure/cure_peace_spec.rb
describe "Cure.peace" do # rubocop:disable RSpec/DescribeClass describe "#pikarin_janken" do subject { girl.pikarin_janken } shared_examples :do_janken do it { should match(/ピカピカピカリン\nジャンケンポン!\n(.+)/) } end context "When peace" do let(:girl) { Cure.peace } it_behaves_like :do_janken end context "When cure_peace" do let(:girl) { Cure.cure_peace } it_behaves_like :do_janken end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/movie_spec.rb
spec/rubicure/movie_spec.rb
describe Rubicure::Movie do let(:movie_names) do [ :dx1, :dx2, :dx3, :ns1, :ns2, :ns3, :sc, :stmm, :dream_stars, :super_stars, :memories, :miracle_universe, :miracle_leap, :f, ] end describe "#names" do subject { Rubicure::Movie.names } it { should include(*movie_names) } end describe "#uniq_names" do subject { Rubicure::Movie.uniq_names } it { should include(*movie_names) } its(:count) { should == movie_names.count } end describe "#find" do subject { Rubicure::Movie.find(movie_name) } context "when exists" do let(:movie_name) { :dx } its(:title) { should == "映画 プリキュアオールスターズDX みんなともだちっ☆奇跡の全員大集合!" } end context "when not exists" do let(:movie_name) { :ashita_no_nadja } it { expect { subject }.to raise_error Rubicure::UnknownMovieError } end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/cure_beat_spec.rb
spec/rubicure/cure_beat_spec.rb
describe "Cure.beat" do # rubocop:disable RSpec/DescribeClass describe "!" do subject { !Cure.beat } let(:girl) { Cure.beat } after do girl.rollback girl.humanize! end context "called once" do it { expect { subject }.to change { girl.name }.from("黒川エレン").to("セイレーン") } end context "called twice" do before do !Cure.beat end it { expect { subject }.to change { girl.name }.from("セイレーン").to("黒川エレン") } end context "after transform" do before do girl.transform! end it { expect { subject }.to change { girl.name }.from("キュアビート").to("セイレーン") } end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/rubicure_spec.rb
spec/rubicure/rubicure_spec.rb
require "spec_helper" describe Rubicure do it "has a version number" do expect(Rubicure::VERSION).not_to be_nil end describe "Precure." do context "When Precure.#<title>" do where(:title) do [ [:unmarked], [:futari_wa_pretty_cure], [:max_heart], [:futari_wa_pretty_cure_max_heart], [:splash_star], [:futari_wa_pretty_cure_splash_star], [:yes], [:yes_precure_five], [:yes_precure5], [:yes_gogo], [:yes_precure_five_gogo], [:yes_precure5_gogo], [:fresh], [:fresh_precure], [:heart_catch], [:heart_catch_precure], [:suite], [:suite_precure], [:smile], [:smile_precure], [:dokidoki], [:dokidoki_precure], [:happiness_charge], [:happiness_charge_precure], ] end with_them do it { expect { Precure.send(title) }.not_to raise_error } it { expect { Precure.send(title).girls }.not_to raise_error } end end context "When Precure#<unmarked_precure_method>" do let(:futari_wa_pretty_cure) { Rubicure::Series.find(:unmarked) } it { expect(Precure.title).to eq futari_wa_pretty_cure.title } it { expect(Precure.girls.count).to eq futari_wa_pretty_cure.girls.count } end end describe "Cure." do context "When precure who starting 'cure'" do where(:name) do [ [:black], [:white], [:bloom], [:egret], [:dream], [:rouge], [:lemonade], [:mint], [:aqua], [:peach], [:berry], [:pine], [:passion], [:melody], [:rhythm], [:beat], [:muse], [:happy], [:sunny], [:peace], [:march], [:beauty], [:heart], [:diamond], [:rosetta], [:sword], [:ace], [:lovely], [:princess], [:honey], [:fortune], ] end with_them do it { expect(Cure.send(name)).to be_an_instance_of Rubicure::Girl } it { expect(Cure.send(name).precure_name).to start_with "キュア" } end end context "When precure who not starting 'cure'" do it { expect(Shiny.luminous.precure_name).to eq "シャイニールミナス" } it { expect(Milky.rose.precure_name).to eq "ミルキィローズ" } end end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false
sue445/rubicure
https://github.com/sue445/rubicure/blob/07d85d753c2572af29d9a630eb8f0af8ab9e2c3e/spec/rubicure/girl_spec.rb
spec/rubicure/girl_spec.rb
describe Rubicure::Girl do let(:girl) do Rubicure::Girl[ girl_name: girl_name, human_name: human_name, precure_name: precure_name, cast_name: cast_name, created_date: created_date, extra_names: extra_names, transform_message: transform_message, attack_messages: attack_messages, transform_calls: transform_calls, color: color, random_transform_words: random_transform_words, ] end let(:girl_name) { "cure_peace" } let(:human_name) { "黄瀬やよい" } let(:precure_name) { "キュアピース" } let(:cast_name) { "金元寿子" } let(:created_date) { date("2012-02-19") } let(:extra_names) { %w[プリンセスピース ウルトラピース] } let(:color) { "yellow" } let(:transform_message) do <<~JANKEN プリキュアスマイルチャージ! GO! GO! Let's GO ピース! ピカピカピカリンジャンケンポン! キュアピース! JANKEN end let(:attack_messages) do [ "プリキュアピースサンダー!", "プリキュアピースサンダーハリケーン!", ] end let(:transform_calls) { %w[smile_charge] } let(:random_transform_words) { nil } describe "#name" do context "when before transform" do it { expect(girl.name).to eq human_name } end context "when after 1st transform" do it "transform to Precure" do expect { girl.transform! }.to output(transform_message).to_stdout expect(girl.name).to eq precure_name end end context "when after 2nd transform" do before do girl.transform! girl.transform! end it { expect(girl.name).to eq extra_names[0] } end context "when after 3nd transform" do before do girl.transform! girl.transform! girl.transform! end it { expect(girl.name).to eq extra_names[1] } end context "when after final transform" do before do girl.transform! girl.transform! girl.transform! girl.transform! end # return to human it { expect(girl.name).to eq human_name } end end describe "transform!" do context "when Cure miracle" do let(:girl) do Rubicure::Girl[ girl_name: "cure_miracle", human_name: "朝日奈みらい", precure_name: "キュアミラクル", cast_name: "高橋李依", created_date: "2016-02-07", extra_names: nil, transform_message: nil, attack_messages: nil, transform_calls: ["cure_up_rapapa"], color: "pink", birthday: "6/12", transform_styles: { diamond: { precure_name: "キュアミラクル(ダイヤスタイル)", transform_message: "", }, ruby: { precure_name: "キュアミラクル(ルビースタイル)", transform_message: "", }, }, ] end context "transform! with diamond" do before do girl.transform!(:diamond) end it { expect(girl.name).to eq "キュアミラクル(ダイヤスタイル)" } it { expect(girl.state_names).to eq ["朝日奈みらい", "キュアミラクル(ダイヤスタイル)"] } end context "transform! with ruby" do before do girl.transform!(:ruby) end it { expect(girl.name).to eq "キュアミラクル(ルビースタイル)" } it { expect(girl.state_names).to eq ["朝日奈みらい", "キュアミラクル(ルビースタイル)"] } end context "cure_up_rapapa! with diamond" do before do girl.cure_up_rapapa!(:diamond) end it { expect(girl.name).to eq "キュアミラクル(ダイヤスタイル)" } it { expect(girl.state_names).to eq ["朝日奈みらい", "キュアミラクル(ダイヤスタイル)"] } end end context "when Cure summer" do let(:girl_name) { "cure_summer" } let(:human_name) { "夏海まなつ" } let(:precure_name) { "キュアサマー" } let(:cast_name) { "ファイルーズあい" } let(:created_date) { date("2021-02-28") } let(:transform_calls) { %w[precure_tropical_change] } let(:color) { "white" } let(:transform_message) do <<~MSG プリキュア!トロピカルチェンジ! レッツメイク!キャッチ! チーク! アイズ! ヘアー! リップ! ドレス! ときめく常夏!キュアサマー! はぁー! ${random_transform_word} トロピカル~ジュ!プリキュア! MSG end let(:random_transform_words) do %w[ 4人揃って! 今日も元気だ! ] end it "stdout includes one of random_transform_words" do expect { girl.transform! }.to output(/4人揃って!|今日も元気だ!/).to_stdout end end end describe "#==" do subject { girl == other_girl } context "same object" do let(:other_girl) { girl } it { should be true } end context "copied object" do let(:other_girl) { girl.dup } it { should be true } end context "precure and human" do let(:transformed_girl) { girl.dup.transform! } let(:other_girl) { transformed_girl } it { expect(girl.name).not_to eq transformed_girl.name } it { should be true } end context "other precure" do let(:other_girl) { Rubicure::Girl.find(:passion) } it { should be false } end end describe "#find" do subject { Rubicure::Girl.find(girl_name) } let(:girl_name) { :peace } it { should be_an_instance_of Rubicure::Girl } its(:precure_name) { should == "キュアピース" } its(:girl_name) { should == "cure_peace" } end describe "#uniq_names" do subject { Rubicure::Girl.uniq_names } let(:containing_name_alias_count) { Rubicure::Girl.names.count } its(:count) { should < containing_name_alias_count } end describe "#attack!" do subject { girl.attack! } context "When human" do it { expect { subject }.to raise_error Rubicure::RequireTransformError } end context "When precure" do before do girl.transform! end it { should eq "プリキュアピースサンダー!" } end end describe "#method_missing" do subject { girl.send(transform_call) } before do girl.humanize! end context "When Cure Lemonade calls metamorphose" do let(:girl) { Cure.lemonade } let(:transform_call) { "metamorphose" } it { expect { subject }.not_to raise_error } end context "When Milkey Rose calls sky_rose_translate!" do let(:girl) { Milky.rose } let(:transform_call) { "sky_rose_translate!" } it { expect { subject }.not_to raise_error } end context "When Milky Rose calls metamorphose" do let(:girl) { Milky.rose } let(:transform_call) { "metamorphose" } it { expect { subject }.to raise_error NameError } end end shared_examples :a_humanize_method do it { should be_an_instance_of Rubicure::Girl } it { expect(girl.current_state).to eq 0 } end describe "humanize!" do let(:humanize!) { girl.humanize! } context "When not transformed" do subject! { humanize! } it_behaves_like :a_humanize_method end context "When after transformed" do before do girl.transform! end subject! { humanize! } # rubocop:disable RSpec/LeadingSubject it_behaves_like :a_humanize_method end end describe "#colors" do subject { Rubicure::Girl.colors } let(:expected) do %i[ black blue gold green orange pink purple rainbow red white yellow ] end it { should match_array(expected) } end describe "dynamic color methods" do # NOTE: cure peace is yellow it { expect(girl).to be_yellow } it { expect(girl).not_to be_pink } end describe "birthday?" do subject { girl.birthday?(curent_date) } let(:curent_date) { Date.today } context "has birthday" do let(:girl) { Cure.flora } context "curent_time is birthday" do let(:curent_date) { date("2015-04-10") } it { should be true } end context "curent_time is not birthday" do let(:curent_date) { date("2015-04-11") } it { should be false } end end context "don't have birthday" do let(:girl) { Cure.peace } it { should be false } end end describe "#full_name" do subject { girl.full_name } context "has human_full_name" do let(:girl) { Cure.scarlet } it { should eq "プリンセス・ホープ・ディライト・トワ" } end context "don't have human_full_name" do it { should eq "黄瀬やよい" } end end describe "#heisei?" do subject { girl.heisei? } it { should be true } end describe "#reiwa?" do subject { girl.reiwa? } # TODO: Add reiwa precure test after cure cosmo is added it { should be false } end end
ruby
MIT
07d85d753c2572af29d9a630eb8f0af8ab9e2c3e
2026-01-04T17:44:56.245530Z
false