source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/profiles_helper_spec.rb
Ruby
mit
92
master
355
require 'spec_helper' # Specs in this file have access to a helper object that includes # the ProfilesHelper. For example: # # describe ProfilesHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/signatures_controller_helpers_spec.rb
Ruby
mit
92
master
1,053
describe SignaturesControllerHelpers do describe "#guess_names" do it "guess lastname from beginning TUPAS name 'lastname firstname'" do helper.guess_names("Knuth Donald", "", "Knuth").should == ["Donald", "Knuth"] end it "guess lastname from end of TUPAS name 'lastname firstname'" do helper.g...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/conversations_helper_spec.rb
Ruby
mit
92
master
427
require 'spec_helper' # Specs in this file have access to a helper object that includes # the ConversationsHelper. For example: # # describe ConversationsHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/comments_helper_spec.rb
Ruby
mit
92
master
355
require 'spec_helper' # Specs in this file have access to a helper object that includes # the CommentsHelper. For example: # # describe CommentsHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/expert_suggestions_helper_spec.rb
Ruby
mit
92
master
382
require 'spec_helper' # Specs in this file have access to a helper object that includes # the ExpertSuggestionsHelper. For example: # # describe ExpertSuggestionsHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/pages_helper_spec.rb
Ruby
mit
92
master
346
require 'spec_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 de...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/admin/changelogs_helper_spec.rb
Ruby
mit
92
master
2,968
# encoding: UTF-8 require 'spec_helper' describe Admin::ChangelogsHelper do describe "#short_diff" do it "should shorten the diff for a change" do original = <<-EOS Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/helpers/admin/admin_helper_spec.rb
Ruby
mit
92
master
271
# encoding: UTF-8 require 'spec_helper' describe Admin::AdminHelper do describe "#classes_for_nav" do it "does something" do helper.stub(:controller_name).and_return("ideas") helper.classes_for_nav("ideas").should == "active" end end end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/routing/articles_routes_spec.rb
Ruby
mit
92
master
655
require 'spec_helper' describe "articles resource routes" do describe "#show" do it "routes /artikkelit/:article.slug to ArticlesController#show" do { get: 'http://localhost/artikkelit/uusi-artikkeli' }.should route_to( locale: 'fi', controller: 'articles', action: 'show', i...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/routing/expert_suggestions_routing_spec.rb
Ruby
mit
92
master
616
require "spec_helper" describe ExpertSuggestionsController do describe "routing" do it "routes to #new" do { get: '/ideat/123-paras-idea/asiantuntijaehdotukset/uusi' }.should route_to( controller: 'expert_suggestions', action: 'new', locale: 'fi', idea_id: '123-paras...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/routing/comments_routes_spec.rb
Ruby
mit
92
master
767
require 'spec_helper' describe "comments resource routes" do describe "#create" do it "routes /ideat/:idea.id-:idea.slug/kommentit to CommentsController#create" do { post: 'http://localhost/ideat/123-allow-citizen-initiatives/kommentit' }.should route_to( locale: 'fi', controller: 'comments...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/routing/ideas_routes_spec.rb
Ruby
mit
92
master
659
require 'spec_helper' describe "ideas resource routes" do describe "#show" do it "routes /ideat/:idea.slug to IdeasController#show" do { get: 'http://localhost/ideat/allow-citizen-initiatives' }.should route_to( locale: 'fi', controller: 'ideas', action: 'show', id: 'allow-c...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/modules/changelogger_spec.rb
Ruby
mit
92
master
2,036
require 'spec_helper' describe Changelogger do class CreateChangeloggableItems < ActiveRecord::Migration def up create_table :changeloggable_items do |t| t.string :title t.timestamps end end def down drop_table :changeloggable_items end end class ChangeloggableI...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/modules/publishing_actions_spec.rb
Ruby
mit
92
master
1,199
require 'spec_helper' describe Admin::PublishingActions do class PublishingController attr_accessor :resource def resource @resource ||= PublishingClass.new end def redirect_to(target) true end end class PublishingClass attr_accessor :message def publish!...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/pages_controller_spec.rb
Ruby
mit
92
master
4,263
# encoding: utf-8 require 'spec_helper' describe PagesController do describe "#home" do it "should be successful" do get :home response.should be_success end describe "drafts section" do before :each do @recent_draft = FactoryGirl.create(:idea, state: 'draft') @recent_i...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/articles_controller_spec.rb
Ruby
mit
92
master
686
require 'spec_helper' describe ArticlesController do render_views describe "#show" do before :each do @article = FactoryGirl.create :article end it "should show an article" do get :show, id: @article.id response.body.should include(@article.title) response.body.should include(...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/expert_suggestions_controller_spec.rb
Ruby
mit
92
master
2,105
require 'spec_helper' describe ExpertSuggestionsController do before :each do @citizen = FactoryGirl.create :citizen sign_in @citizen @idea = FactoryGirl.create :idea @valid_attributes = { firstname: 'Erkki', lastname: 'Esimerkki', email: 'erkki@asiantuntija.fi', jobt...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/profiles_controller_spec.rb
Ruby
mit
92
master
3,156
require 'spec_helper' describe ProfilesController do let (:citizen) { FactoryGirl.create :citizen } get :edit do before do sign_in citizen end action! do it "assigns the profile as @profile" do assigns(:profile).should == citizen.profile end end end get :show...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/ideas_controller_spec.rb
Ruby
mit
92
master
3,532
# encoding: UTF-8 require 'spec_helper' describe IdeasController do include Devise::TestHelpers # remove when helpers are globally included include ActionView::Helpers::UrlHelper render_views let (:citizen) { FactoryGirl.create :citizen } describe "#index" do it "should be successful" do ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/signatures_controller_spec.rb
Ruby
mit
92
master
1,117
require 'spec_helper' describe SignaturesController do let (:citizen) { FactoryGirl.create :citizen } let (:idea) { FactoryGirl.create :idea } before do sign_in citizen end describe "GET introduction" do it "renders introduction view" do get :introduction, :id => idea.id response.should...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/citizens_controller_spec.rb
Ruby
mit
92
master
1,438
require 'spec_helper' describe CitizensController do let (:citizen) { FactoryGirl.create :citizen } get :edit do before do sign_in citizen end action! do it "assigns the citizen as @citizen" do assigns(:citizen).should == citizen end end end post :update do ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/admin/comments_controller_spec.rb
Ruby
mit
92
master
316
require 'spec_helper' describe Admin::CommentsController do before :each do @administrator = FactoryGirl.create :administrator sign_in :administrator, @administrator end describe "GET 'index'" do it "returns http success" do get 'index' response.should be_success end end end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/admin/changelogs_controller_spec.rb
Ruby
mit
92
master
1,780
require 'spec_helper' describe Admin::ChangelogsController do before :each do @administrator = FactoryGirl.create :administrator sign_in :administrator, @administrator end describe "GET 'index'" do render_views it "returns http success" do get 'index' response.should be_success ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/admin/ideas_controller_spec.rb
Ruby
mit
92
master
313
require 'spec_helper' describe Admin::IdeasController do before :each do @administrator = FactoryGirl.create :administrator sign_in :administrator, @administrator end describe "GET 'index'" do it "returns http success" do get 'index' response.should be_success end end end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/admin/articles_controller_spec.rb
Ruby
mit
92
master
4,552
require 'spec_helper' RSpec::Matchers.define :have_an_article_written_by do |citizen| match do |idea| for article in idea.articles if article.author == citizen return true end end return false end end describe Admin::ArticlesController do let (:administrator) { FactoryGirl.cr...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/controllers/citizens/omniauth_callbacks_controller_spec.rb
Ruby
mit
92
master
1,318
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper') describe Citizens::OmniauthCallbacksController do describe 'facebook' do it "should authenticate successfully" do @citizen = FactoryGirl.create :facebookin_erkki request.env['omniauth.auth'] = auth_hash request.env["devise.ma...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
spec/mailers/citizen_mailer_spec.rb
Ruby
mit
92
master
401
require "spec_helper" describe CitizenMailer do describe 'welcome_email' do it "should send deliver an email" do citizen = Factory.build(:citizen) CitizenMailer.welcome_email(citizen, [], []).deliver sent_email = ActionMailer::Base.deliveries.last sent_email.subject.should == "Welcome to...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/helpers/ideas_helper.rb
Ruby
mit
92
master
3,211
# encoding: utf-8 require "cgi" module IdeasHelper def idea_state_image(idea) filename = { idea: "state_1_idea.png", draft: "state_2_draft.png", proposal: "state_3_proposal.png", law: "state_4_law.png", }[idea.state.to_sym] image_tag(filename, width: 954, height:...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/helpers/signatures_controller_helpers.rb
Ruby
mit
92
master
7,883
# encoding: UTF-8 module SignaturesControllerHelpers # def SignaturesControllerHelpers.guess_names(names, firstnames, lastname) def guess_names(names, firstnames, lastname) # let's make sure lastname is just characters before interpolating it into regexp unless justNameCharacters(lastname) Logger.erro...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/helpers/application_helper.rb
Ruby
mit
92
master
5,053
# TUPAS requests require SHA256 MAC calculations require 'digest/sha2' module ApplicationHelper def markdown(text) renderer = Redcarpet::Render::HTML.new(filter_html: true, hard_wrap: true, with_toc_data: true) Redcarpet::Markdown.new(renderer, { autolink: true, tables: true }).render(text).html_safe end ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/helpers/admin/changelogs_helper.rb
Ruby
mit
92
master
1,603
module Admin::ChangelogsHelper CHARACTERS_AROUND_DIFF = 40 def changelogged_link_for(changelog) link_text = "#{I18n.t('activerecord.models.'+changelog.changelogged_type.downcase)} ##{changelog.changelogged_id}" if changelog.changelogged.class == Comment comment = changelog.changelogged if comme...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/concerns/publishing_state_machine.rb
Ruby
mit
92
master
607
module PublishingStateMachine extend ActiveSupport::Concern included do state_machine :publish_state, initial: :published do event :publish do transition [ :in_moderation, :unpublished ] => :published end event :unpublish do transition [ :published ] => :unpublished end...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/concerns/changelogger.rb
Ruby
mit
92
master
598
module Changelogger extend ActiveSupport::Concern included do has_many :changelogs, as: :changelogged after_create { changelog_for!(:create) } before_update { changelog_for!(:update) } before_destroy { changelog_for!(:destroy) } def changelog_for!(action) self.changelogs.create!( ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/changelog.rb
Ruby
mit
92
master
242
class Changelog < ActiveRecord::Base belongs_to :changer, polymorphic: true belongs_to :changelogged, polymorphic: true def self.per_page 50 end def attribute_changes YAML.load read_attribute(:attribute_changes) end end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/comment.rb
Ruby
mit
92
master
1,438
class Comment < ActiveRecord::Base include PublishingStateMachine include Changelogger include Concerns::Indexing include Tanker attr_accessible :body belongs_to :author, class_name: "Citizen", foreign_key: "author_id" belongs_to :commentable, polymorphic: true default_scope order("created_at DESC") ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/signature.rb
Ruby
mit
92
master
2,035
class Signature < ActiveRecord::Base VALID_STATES = %w(init query returned cancelled rejected) # TODO: these are invalid at the moment, it's just initial, authenticated, and the last will be saved or error VALID_PUBLICITY_OPTIONS = %w(Normal Immediately) attr_accessible :state, :firstnames, :lastname, :birth_da...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/vote.rb
Ruby
mit
92
master
260
class Vote < ActiveRecord::Base belongs_to :idea belongs_to :citizen def self.by(citizen) where(citizen_id: citizen && citizen.id || nil) end def self.in_favor where(option: 1) end def self.against where(option: 0) end end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/citizen.rb
Ruby
mit
92
master
4,367
class Citizen < ActiveRecord::Base include Concerns::Indexing include Tanker # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :remem...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/location.rb
Ruby
mit
92
master
272
class Location < ActiveRecord::Base attr_accessible :address, :name, :latitude, :longitude geocoded_by :address after_validation :geocode, :if => :address_changed? KM_PER_MILE = 1.609344 def self.m2km(miles) (miles.to_f * KM_PER_MILE).round(1) end end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/citizen_observer.rb
Ruby
mit
92
master
543
class CitizenObserver < ActiveRecord::Observer def after_create(citizen) famous_ideas = Idea.find(:all, :conditions => ["collecting_started='true' and collecting_ended='false' and (state='proposal' OR state='idea')"], :limit => 3, :order => "vote_for_count DESC") ideas = Idea.find(:all, :conditions => ["state...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/expert_suggestion.rb
Ruby
mit
92
master
312
class ExpertSuggestion < ActiveRecord::Base belongs_to :idea belongs_to :supporter, class_name: "Citizen", foreign_key: "citizen_id" validates_presence_of :idea validates_presence_of :supporter attr_accessible :firstname, :lastname, :email, :jobtitle, :organisation, :expertise, :recommendation end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/idea.rb
Ruby
mit
92
master
4,494
class Idea < ActiveRecord::Base include PublishingStateMachine include Changelogger include Concerns::Indexing include Tanker extend FriendlyId VALID_STATES = %w(idea draft proposal law) MAX_FB_TITLE_LENGTH = 100 MAX_FB_DESCRIPTION_LENGTH = 500 friendly_id :title, use: :slugged attr_accessible ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/article.rb
Ruby
mit
92
master
899
class Article < ActiveRecord::Base include PublishingStateMachine include Changelogger include Concerns::Indexing include Tanker extend FriendlyId VALID_ARTICLE_TYPES = %w(blog footer statement) friendly_id :title, use: :slugged belongs_to :idea belongs_to :author, class_name: "Citizen", foreign_ke...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/administrator.rb
Ruby
mit
92
master
437
class Administrator < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (o...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/question.rb
Ruby
mit
92
master
674
class Question < ActiveRecord::Base include Surveyor::Models::QuestionMethods def get_question_number return reference_identifier unless reference_identifier.nil? #Following code is deprecated only required for older survey versions #Which didn't have reference_identifiers @@question_number ||= dis...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/profile.rb
Ruby
mit
92
master
404
class Profile < ActiveRecord::Base belongs_to :citizen attr_accessible :first_name, :last_name, :image, :receive_newsletter, :receive_other_announcements, :receive_weekletter, :first_names, :accept_science, :accept_terms_of_use, :receive_messaging_notifications validates :first_names, :first_name, :la...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/models/concerns/indexing_wrapper.rb
Ruby
mit
92
master
452
class Concerns::IndexingWrapper def after_save(record) begin record.send :update_tank_indexes rescue IndexTank::HttpCodeException => e Rails.logger.warn "Failed to index a document: #{e.message}" end end def after_destroy(record) begin record.send :delete_tank_indexes resc...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/articles_controller.rb
Ruby
mit
92
master
813
class ArticlesController < ApplicationController before_filter :authenticate_citizen!, except: [ :index, :show ] respond_to :html def index article_type = params[:article_type] || "blog" @article_type_heading = { "blog" => "Blogikirjoitukset", "statement" => "Lausunnot", ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/surveyor_controller.rb
Ruby
mit
92
master
2,249
# encoding: UTF-8 module SurveyorControllerCustomMethods def self.included(base) # base.send :before_filter, :require_user # AuthLogic # base.send :before_filter, :login_required # Restful Authentication base.send :layout, 'application' end # Actions def new super # @title = "You can tak...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/ideas_controller.rb
Ruby
mit
92
master
14,116
#encoding: UTF-8 require 'will_paginate/array' class IdeasController < ApplicationController before_filter :authenticate_citizen!, except: [ :index, :show, :search ] impressionist :actions => [:show] respond_to :html # should be implemented instead with counter_caches and also vote_pro (and vote_even_ab...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/citizens_controller.rb
Ruby
mit
92
master
557
class CitizensController < ApplicationController before_filter :authenticate_citizen! before_filter :fetch_citizen def edit end def after_sign_up end # based on https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-password def update if @citizen.update_with_password(...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/pages_controller.rb
Ruby
mit
92
master
4,475
#encoding: UTF-8 class PagesController < ApplicationController def load(state) if state == "proposal" items = Idea.published.where(state: "proposal", collecting_started: true). sort_by{|idea| [idea.collecting_ended ? 0 : 1, (idea.signatures....
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/vote_controller.rb
Ruby
mit
92
master
897
class VoteController < ApplicationController before_filter :setup_objects before_filter :authenticate_citizen! def vote KM.identify(current_citizen) KM.push("record", "voted", {option: params[:vote], idea: @idea.id}) vote = @idea.votes.by(current_citizen).first if vote KM.push("record", "...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/application_controller.rb
Ruby
mit
92
master
1,780
class ApplicationController < ActionController::Base protect_from_forgery before_filter :set_locale before_filter :set_locale_from_url before_filter :set_changer def after_sign_in_path_for(resource) KM.identify(current_citizen) KM.push("record", "signed in") return request.env['omniauth.or...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/comments_controller.rb
Ruby
mit
92
master
563
class CommentsController < ApplicationController respond_to :js before_filter :authenticate_citizen! before_filter :load_resource def create @comment = @idea.comments.build(params[:comment]) @comment.author = current_citizen if @comment.save flash[:notice] = I18n.t("comments.create") ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/conversations_controller.rb
Ruby
mit
92
master
2,031
require 'will_paginate/array' class ConversationsController < ApplicationController before_filter :authenticate_citizen! helper_method :mailbox, :conversation def create recipient = Citizen.find(conversation_params(:recipients)) conversation = current_citizen.send_message(recipient, *conversation_para...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/expert_suggestions_controller.rb
Ruby
mit
92
master
921
class ExpertSuggestionsController < ApplicationController before_filter :authenticate_citizen! respond_to :html def new @idea = Idea.find(params[:idea_id]) @expert_suggestion = ExpertSuggestion.new respond_with @ideas end def create @idea = Idea.find(params[:idea_id]) @expert_suggest...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/signatures_controller.rb
Ruby
mit
92
master
42,367
# #encoding: UTF-8 require 'date' require 'signatures_controller_helpers' $ALLOW_SIGNING_MULTIPLE_TIMES = ENV['ALLOW_SIGNING_MULTIPLE_TIMES'] class SignaturesController < ApplicationController include SignaturesControllerHelpers # For Sampo case skip_before_filter :verify_authenticity_token, only: [:paid_re...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/profiles_controller.rb
Ruby
mit
92
master
739
class ProfilesController < ApplicationController before_filter :authenticate_citizen! before_filter :fetch_objects def show end def edit end def update if @profile.update_attributes(params[:profile]) flash[:notice] = I18n.t("settings.updated") end if current_citizen...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/locations_controller.rb
Ruby
mit
92
master
3,018
require 'will_paginate/array' class LocationsController < ApplicationController def new @location = Location.new respond_to do |format| format.html # new.html.erb format.json { render json: @location } end end def map @cloudmade_api_key = ENV['CLOUDMADE_API_KEY'] #To prevent ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/comments_controller.rb
Ruby
mit
92
master
463
class Admin::CommentsController < Admin::AdminController include Admin::PublishingActions respond_to :html def index @comments = resource_scope.paginate(page: params[:page]) end def show respond_with resource end private def resource @comment ||= resource_scope.find(params[:...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/expert_suggestions_controller.rb
Ruby
mit
92
master
337
class Admin::ExpertSuggestionsController < Admin::AdminController respond_to :html def index respond_with @expert_suggestions = ExpertSuggestion.paginate(page: params[:page]) end def show respond_with resource end private def resource @expert_suggestion ||= ExpertSuggestion.find(params...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/publishing_actions.rb
Ruby
mit
92
master
419
module Admin::PublishingActions def publish resource.publish! redirect_to :back end def unpublish resource.respond_to?(:prepare_for_unpublishing) and resource.prepare_for_unpublishing resource.unpublish! redirect_to :back end def moderate resource.respond_to?(:prepare_for_unpubli...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/articles_controller.rb
Ruby
mit
92
master
2,344
class Admin::ArticlesController < Admin::AdminController include Admin::PublishingActions respond_to :html def index @parent = parent_resource @blogs = resource_scope.where(article_type: "blog").all @statements = resource_scope.where(article_type: "statement").all @footers = resource_s...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/changelogs_controller.rb
Ruby
mit
92
master
238
require 'differ/string' class Admin::ChangelogsController < Admin::AdminController respond_to :html def index @changelogs = Changelog.paginate(page: params[:page]).order('created_at DESC') respond_with @changelogs end end
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/locations_controller.rb
Ruby
mit
92
master
761
class Admin::LocationsController < Admin::AdminController include Admin::PublishingActions respond_to :html def index respond_with @locations = Location.order(:name).paginate(page: params[:page], per_page: 500) end def edit @location = Location.find(params[:id]) end def update @location ...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/citizens_controller.rb
Ruby
mit
92
master
1,973
class Admin::CitizensController < Admin::AdminController respond_to :html before_filter :build_resource, except: [ :index ] def index respond_to do |wants| wants.html do @citizens = Citizen.paginate(page: params[:page]) end wants.csv do date = Date.parse(param...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/admin/ideas_controller.rb
Ruby
mit
92
master
724
class Admin::IdeasController < Admin::AdminController include Admin::PublishingActions respond_to :html def index respond_with @ideas = Idea.paginate(page: params[:page]) end def show respond_with resource end def edit @idea = Idea.find(params[:id]) respond_with @idea end de...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/citizens/omniauth_callbacks_controller.rb
Ruby
mit
92
master
789
class Citizens::OmniauthCallbacksController < Devise::OmniauthCallbacksController def facebook @citizen = Citizen.find_for_facebook_auth(request.env["omniauth.auth"]) unless @citizen @citizen = Citizen.build_from_auth_hash(request.env["omniauth.auth"]) sign_up = true end if @citizen.pers...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/citizens/sessions_controller.rb
Ruby
mit
92
master
550
class Citizens::SessionsController < Devise::SessionsController def new super KM.identify(current_citizen) KM.push("record", "View log in") Rails.logger.info "########### View Sign in" end def create super if current_citizen.present? KM.identify(current_citizen) KM.push("recor...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/controllers/citizens/registrations_controller.rb
Ruby
mit
92
master
664
class Citizens::RegistrationsController < Devise::RegistrationsController def new super KM.identify(current_citizen) KM.push("record", "View Sign up") Rails.logger.info "########### View Sign up" end def create super if resource.valid? && resource.persisted? KM.identify(current_citi...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/mailers/notification_mailer.rb
Ruby
mit
92
master
876
class NotificationMailer < ActionMailer::Base default :from => Mailboxer.default_from #Sends and email for indicating a new notification to a receiver. #It calls new_notification_email. def send_email(notification,receiver) if Profile.find(receiver).receive_messaging_notifications new_notification_ema...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/mailers/message_mailer.rb
Ruby
mit
92
master
1,513
class MessageMailer < ActionMailer::Base default :from => Mailboxer.default_from #Sends and email for indicating a new message or a reply to a receiver. #It calls new_message_email if notifing a new message and reply_message_email #when indicating a reply to an already created conversation. def send_email(me...
github
avoinministerio/avoinministerio
https://github.com/avoinministerio/avoinministerio
app/mailers/citizen_mailer.rb
Ruby
mit
92
master
386
class CitizenMailer < ActionMailer::Base default from: "avointesting@gmail.com" def welcome_email(user, proposals, famous_ideas) @f_ideas = famous_ideas @user = user @proposals = proposals attachments.inline['email_logo.png'] = File.read("#{Rails.root}/app/assets/images/logo.png") mail(:to =>...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
Rakefile
Ruby
mit
92
master
914
require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run all tests.' task :default => :test desc "Test has_messages." Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.test_files = Dir['test/**/*_test.rb'] t.verbose = true end begin require 'rcov/rcovtask' names...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
has_messages.gemspec
Ruby
mit
92
master
992
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) require 'has_messages/version' Gem::Specification.new do |s| s.name = "has_messages" s.version = HasMessages::VERSION s.authors = ["Aaron Pfeifer"] s.email = "aaron@pluginaweek.org" s.homepage = "htt...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
app/models/message.rb
Ruby
mit
92
master
4,883
# Represents a message sent from one user to one or more others. # # == States # # Messages can be in 1 of 3 states: # * +unsent+ - The message has not yet been sent. This is the *initial* state. # * +queued+ - The message has been queued for future delivery. # * +sent+ - The message has been sent. # # == Interacti...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
app/models/message_recipient.rb
Ruby
mit
92
master
4,102
# Represents a recipient on a message. The kind of recipient (to, cc, or bcc) is # determined by the +kind+ attribute. # # == States # # Recipients can be in 1 of 2 states: # * +unread+ - The message has been sent, but not yet read by the recipient. This is the *initial* state. # * +read+ - The message has been read...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
lib/has_messages.rb
Ruby
mit
92
master
2,426
require 'state_machine' # Adds a generic implementation for sending messages between users module HasMessages module MacroMethods # Creates the following message associations: # * +messages+ - Messages that were composed and are visible to the owner. # Mesages may have been sent or unsent. # * +rec...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
test/test_helper.rb
Ruby
mit
92
master
381
# Load the plugin testing framework $:.unshift("#{File.dirname(__FILE__)}/../../plugin_test_helper/lib") require 'rubygems' require 'plugin_test_helper' # Run the migrations ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate") # Mixin the factory helper require File.expand_path("#{File.dirname(__FILE__)}/factor...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
test/factory.rb
Ruby
mit
92
master
1,909
module Factory # Build actions for the model def self.build(model, &block) name = model.to_s.underscore define_method("#{name}_attributes", block) define_method("valid_#{name}_attributes") {|*args| valid_attributes_for(model, *args)} define_method("new_#{name}") {|*args| new_record...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
test/unit/message_test.rb
Ruby
mit
92
master
10,674
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') class MessageByDefaultTest < ActiveSupport::TestCase def setup @message = Message.new end def test_should_not_have_a_sender assert_nil @message.sender end def test_should_not_have_a_subject assert @message.subject.blank? ...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
test/unit/message_recipient_test.rb
Ruby
mit
92
master
11,226
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') class MessageRecipientByDefaultTest < ActiveSupport::TestCase def setup @recipient = MessageRecipient.new end def test_should_not_have_a_message assert_nil @recipient.message_id end def test_should_not_have_a_receiver_id a...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
test/functional/has_messages_test.rb
Ruby
mit
92
master
4,188
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') class UserByDefaultTest < ActiveSupport::TestCase def setup @user = create_user end def test_should_not_have_any_messages assert @user.messages.empty? end def test_should_not_have_any_unsent_messages assert @user.unsent_me...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
test/app_root/db/migrate/002_migrate_has_messages_to_version_2.rb
Ruby
mit
92
master
442
class MigrateHasMessagesToVersion2 < ActiveRecord::Migration def self.up ActiveRecord::Migrator.new(:up, "#{Rails.root}/../../generators/has_messages/templates", 0).migrations.each do |migration| migration.migrate(:up) end end def self.down ActiveRecord::Migrator.new(:down, "#{Rails.root}/../...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
test/app_root/config/environment.rb
Ruby
mit
92
master
308
require 'config/boot' Rails::Initializer.run do |config| config.plugin_paths << '..' config.plugins = %w(state_machine has_messages) config.cache_classes = false config.whiny_nils = true config.action_controller.session = {:key => 'rails_session', :secret => 'd229e4d22437432705ab3985d4d246'} end
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
generators/has_messages/has_messages_generator.rb
Ruby
mit
92
master
357
class HasMessagesGenerator < Rails::Generator::Base def manifest record do |m| m.migration_template '001_create_messages.rb', 'db/migrate', :migration_file_name => 'create_messages' m.sleep 1 m.migration_template '002_create_message_recipients.rb', 'db/migrate', :migration_file_name => 'create_m...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
generators/has_messages/templates/001_create_messages.rb
Ruby
mit
92
master
361
class CreateMessages < ActiveRecord::Migration def self.up create_table :messages do |t| t.references :sender, :polymorphic => true, :null => false t.text :subject, :body t.string :state, :null => false t.datetime :hidden_at t.string :type t.timestamps end end def self...
github
pluginaweek/has_messages
https://github.com/pluginaweek/has_messages
generators/has_messages/templates/002_create_message_recipients.rb
Ruby
mit
92
master
516
class CreateMessageRecipients < ActiveRecord::Migration def self.up create_table :message_recipients do |t| t.references :message, :null => false t.references :receiver, :polymorphic => true, :null => false t.string :kind, :null => false t.integer :position t.string :state, :null => ...
github
maca/scruby
https://github.com/maca/scruby
scruby.gemspec
Ruby
mit
92
main
1,731
lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "scruby/version" Gem::Specification.new do |spec| spec.name = "scruby" spec.version = Scruby::VERSION spec.authors = [ "Macario" ] spec.email = [ "maca@aelita.io" ] spec.summary...
github
maca/scruby
https://github.com/maca/scruby
spec/attributes_spec.rb
Ruby
mit
92
main
1,063
RSpec.describe Attributes do let(:extended_class) do Class.new do extend Attributes attributes do attribute :foo attribute :bar, nil attribute :baz, false attribute :qux, :hello end end end describe "initialize with no attributes" do subject(:instanc...
github
maca/scruby
https://github.com/maca/scruby
spec/spec_helper.rb
Ruby
mit
92
main
627
require "bundler/setup" require "byebug" require "scruby" require "rantly" require "rantly/rspec_extensions" require "rantly/shrinks" Dir.glob(File.join(__dir__, "support/**/*.rb")).each { |f| load f } include Scruby::Helpers RSpec.configure do |config| # Enable flags like --only-failures and --next-failure c...
github
maca/scruby
https://github.com/maca/scruby
spec/buffer_spec.rb
Ruby
mit
92
main
5,676
RSpec.describe Buffer do let(:server) do instance_double("Server", next_buffer_id: 10, sample_rate: 48_000) end before { allow(server).to receive(:send_msg) { server } } let(:buffer) do described_class.new(server) end describe "instantiation" do it { expect(buffer.id).to be 10 } end des...
github
maca/scruby
https://github.com/maca/scruby
spec/synth_def_spec.rb
Ruby
mit
92
main
1,483
RSpec.describe Scruby::SynthDef do describe "building a synth def" do context "synth def with no controls" do subject(:synth_def) do SynthDef.new(:simple) do Out.ar(0, SinOsc.ar(400) * 0.5) end end let(:graph) do UgenGraph.new(Out.ar(0, SinOsc.ar(400) * 0.5), :...
github
maca/scruby
https://github.com/maca/scruby
spec/group_spec.rb
Ruby
mit
92
main
3,424
RSpec.describe Group do let(:server) { instance_double("Server", next_node_id: 16) } subject(:group) do Group.new(server, 16) end it_behaves_like "performs node actions" do let(:node) { group } end describe "move node" do let(:node) { spy instance_double("Node") } describe "move to head"...
github
maca/scruby
https://github.com/maca/scruby
spec/env_spec.rb
Ruby
mit
92
main
7,021
RSpec.describe Env do subject(:env) { Env.new(levels: [ 0, 1 ].cycle(4), times: [ 0.1 ], release_at: 3, loop_at: 4) } describe "initialize" do context "levels are smaller than times array" do subject(:env) { Env.new(levels: (1..4), times: (1..8)) } it { expect(env.levels...
github
maca/scruby
https://github.com/maca/scruby
spec/in_out_spec.rb
Ruby
mit
92
main
2,758
# include Scruby # include Ugens # class SinOsc < Ugen # # not interested in muladd # def self.ar(freq = 440.0, phase = 0.0) # new :audio, freq, phase # end # end # class MockUgen < Ugen # class << self; public :new; end # end # RSpec.describe In do # before do # @sdef = double("ugen", children: []...
github
maca/scruby
https://github.com/maca/scruby
spec/graph_spec.rb
Ruby
mit
92
main
1,501
RSpec.describe Scruby::Graph do let(:zero) { instance_double("Graph::Node", id: 0, parent: nil) } let(:one) { instance_double("Graph::Node", id: 1, parent: zero) } let(:two) { instance_double("Graph::Node", id: 2, parent: zero) } let(:three) { instance_double("Graph::Node", id: 3, parent: one) } let(:four) {...
github
maca/scruby
https://github.com/maca/scruby
spec/synth_spec.rb
Ruby
mit
92
main
2,938
RSpec.describe Synth do let(:server) { instance_double("Server", next_node_id: 16) } it_behaves_like "performs node actions" do let(:node) { Synth.new(server) } end before do allow(server).to receive(:node).with(1) do instance_double("Node", server: server, id: 1) end end describe "init...
github
maca/scruby
https://github.com/maca/scruby
spec/equatable_spec.rb
Ruby
mit
92
main
442
RSpec.describe Equatable do include Scruby let(:equatable_class) do Class.new do include Equatable def initialize(value) @value = value end end end describe "equality" do let(:value) { 440 } it { expect(equatable_class.new(value)) .to eq equatable_class.n...