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
hamajyotan/active_record_compose
https://github.com/hamajyotan/active_record_compose
test/active_record_compose/model_test.rb
Ruby
mit
47
main
3,758
# frozen_string_literal: true require "test_helper" class ActiveRecordCompose::ModelTest < ActiveSupport::TestCase class ComposedModel < ActiveRecordCompose::Model def initialize(account = Account.new) @account = account @profile = account.then { _1.profile || _1.build_profile } super() ...
github
hamajyotan/active_record_compose
https://github.com/hamajyotan/active_record_compose
test/active_record_compose/model_callback_order_test.rb
Ruby
mit
47
main
4,365
# frozen_string_literal: true require "test_helper" class ActiveRecordCompose::ModelCallbackOrderTest < ActiveSupport::TestCase class CallbackOrder < ActiveRecordCompose::Model def initialize(tracer, persisted: false) @tracer = tracer @persisted = persisted super() end before_save { t...
github
hamajyotan/active_record_compose
https://github.com/hamajyotan/active_record_compose
test/active_record_compose/model_with_destroy_context_test.rb
Ruby
mit
47
main
4,795
# frozen_string_literal: true require "test_helper" class ActiveRecordCompose::ModelWithDestroyContextTest < ActiveSupport::TestCase class WithDestroyContext < ActiveRecordCompose::Model def initialize(account, attributes = {}) @account = account @profile = account.profile || account.build_profile ...
github
hamajyotan/active_record_compose
https://github.com/hamajyotan/active_record_compose
test/use_cases/multiple_model_creation_test.rb
Ruby
mit
47
main
5,339
# frozen_string_literal: true require "test_helper" class MultipleModelCreationTest < ActiveSupport::TestCase # Here, we are testing the batch registration of multiple models as a single model. # # As a concrete example, # we are considering an operation such as user registration for a certain service. # ...
github
hamajyotan/active_record_compose
https://github.com/hamajyotan/active_record_compose
test/use_cases/batch_update_and_delete_test.rb
Ruby
mit
47
main
4,121
# frozen_string_literal: true require "test_helper" class BatchUpdateAndDeleteTest < ActiveSupport::TestCase # Here, we are testing cases where operations such as updating a certain model and # deleting another model are performed at once. # # As a specific example, we are considering something like user with...
github
hamajyotan/active_record_compose
https://github.com/hamajyotan/active_record_compose
test/fake_app/application.rb
Ruby
mit
47
main
337
# frozen_string_literal: true require "active_record/railtie" require "active_record_compose/railtie" class FakeApp < Rails::Application config.secret_key_base = "test_secret_key_base" config.eager_load = false config.root = __dir__ config.logger = Logger.new($stdout) config.filter_parameters += %i[passwor...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
Rakefile
Ruby
mit
47
master
274
#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) SurveyWeb::Application.load_tasks
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
Guardfile
Ruby
mit
47
master
1,847
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do watch('config/application.rb') watch('config/environment.rb') watch('config/environments/test.rb') watch(%r{^config/initializers/.+\.rb$}) watch('Gemfile') watch('Gemfile.lock') watch('config/routes.rb') watch('spec/spec_helper.rb') { :rspec } en...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
Gemfile
Ruby
mit
47
master
2,146
source 'https://rubygems.org' gem 'rails', '3.2.13' gem 'date_validator', '~> 0.6.3' gem 'unicorn', '~> 4.5.0' gem 'pg', '~> 0.14.0' gem 'formtastic', '~> 2.2.1' gem 'will_paginate', '~> 3.0.3' gem 'rails-i18n', '~> 0.6.5' gem 'omniauth-oauth2', '~> 1.1.1' gem 'figaro', '~> 0.4.1' gem "rails-backbone", '~> 0.7.2' gem ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/spec_helper.rb
Ruby
mit
47
master
3,156
if ENV["ENABLE_COVERAGE"] require 'simplecov' SimpleCov.start 'rails' end ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' require 'rubygems' require 'email_spec' Fog.mock! CarrierWave.configure do |config| config.enable_pro...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/data_spec.rb
Ruby
mit
47
master
1,605
require 'spec_helper' describe Reports::Excel::Data do let(:survey) { FactoryGirl.create(:survey) } let(:metadata) { Reports::Excel::Metadata.new([], "accesstoken") } let(:server_url) { "http://example.com" } it "finds the filename from the survey" do data = Reports::Excel::Data.new(survey, [], [], server...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/mailers/privacy_mailer_spec.rb
Ruby
mit
47
master
1,258
require 'spec_helper' describe PrivacyMailer do let(:recipients) { 5.times.map { FactoryGirl.build(:user) } } let(:organization) { FactoryGirl.build(:organization) } context "when an organization is de-registered" do it "sends the deactivation mail" do expect{ PrivacyMailer.deactivation_mail(organizat...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/decorators/organization_decorator_spec.rb
Ruby
mit
47
master
7,183
require "spec_helper" describe OrganizationDecorator do it "fetches the number of surveys created by the organization" do organization = OrganizationDecorator.decorate(FactoryGirl.build(:organization)) FactoryGirl.create_list(:survey, 5, :organization_id => organization.id) organization.survey_count.shou...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/decorators/category_decorator_spec.rb
Ruby
mit
47
master
891
require 'spec_helper' describe CategoryDecorator do it "returns the correct question_number for parent categories" do survey = FactoryGirl.create(:survey) FactoryGirl.create(:question, :order_number => 1) category = FactoryGirl.create(:category, :survey => survey, :order_number => 2) category.questio...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/decorators/question_decorator_spec.rb
Ruby
mit
47
master
1,945
require 'spec_helper' describe QuestionDecorator do it "returns the correct question_number for child questions" do survey = FactoryGirl.create(:survey) FactoryGirl.create(:question, :survey => survey, :order_number => 1) parent_question = FactoryGirl.create(:question_with_options, :survey => survey, :or...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/decorators/question_with_options_decorator_spec.rb
Ruby
mit
47
master
547
require 'spec_helper' describe QuestionWithOptionsDecorator do it "fetches options in the ascending order" do question = FactoryGirl.create(:radio_question) first_option = FactoryGirl.create(:option, :question_id => question.id, :order_number => 1) third_option = FactoryGirl.create(:option, :question_id ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/decorators/users_decorator_spec.rb
Ruby
mit
47
master
269
require 'spec_helper' describe UsersDecorator do it 'should find all the users by the id' do user = FactoryGirl.build(:user) user2 = FactoryGirl.build(:user) users = UsersDecorator.new([user, user2]) users.find_by_id(user.id).should == user end end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/categories.rb
Ruby
mit
47
master
305
FactoryGirl.define do factory :category do survey content "This is a category" order_number 0 trait :finalized do finalized true end factory :multi_record_category, :parent => :category, :class => MultiRecordCategory do type 'MultiRecordCategory' end end end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/organizations.rb
Ruby
mit
47
master
261
FactoryGirl.define do factory :organization do sequence(:id) { |n| n } sequence(:name) { |n| "name_#{n}" } logos :thumb_url => "http://example.com/logo.png" initialize_with { new(id, :name => name, :logo_url => logos[:thumb_url]) } end end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/surveys.rb
Ruby
mit
47
master
885
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :survey do sequence(:name) { |n| "name_#{n}" } expiry_date Date.today + 100.days description "MyText" finalized :false trait :finalized do finalized true end trait :archived do ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/responses.rb
Ruby
mit
47
master
704
FactoryGirl.define do factory :response do survey { FactoryGirl.create(:survey) } user_id 1 organization_id 1 trait :incomplete do status 'incomplete' end trait :complete do status 'complete' end trait :clean do state 'clean' end trait :blank do blan...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/options.rb
Ruby
mit
47
master
214
FactoryGirl.define do factory :option do question sequence(:content) { |n| "This is option number #{n}" } sequence(:order_number, 1000) trait :finalized do finalized true end end end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/answers.rb
Ruby
mit
47
master
1,252
include ActionDispatch::TestProcess FactoryGirl.define do factory :answer do content "MyText" question { FactoryGirl.create(:question, :finalized) } response { FactoryGirl.create(:response, :survey => FactoryGirl.create(:survey), :organization_id => 4, :user_id => 2) } factory(:answer_with_complete_...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/users.rb
Ruby
mit
47
master
243
FactoryGirl.define do factory :user do sequence(:id) { |n| n } sequence(:name) { |n| "name_#{n}" } sequence(:email) { |n| "foo_#{n}@example.com" } role "cso_admin" initialize_with { new(id, name, role, email) } end end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/participating_organizations.rb
Ruby
mit
47
master
227
# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :participating_organization do survey { FactoryGirl.create :survey, :finalized => true } organization_id 1 end end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/factories/questions.rb
Ruby
mit
47
master
1,775
FactoryGirl.define do factory :question do content "MyText" survey_id { FactoryGirl.create(:survey).id } sequence(:order_number, 1000) trait :with_options do after(:create) do |question| create_list(:option, 5, :question => question) end end trait :mandatory do mand...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/rating_question_spec.rb
Ruby
mit
47
master
1,434
require 'spec_helper' describe RatingQuestion do it_behaves_like "a question" it_behaves_like "a question with max length" context "for report data" do let (:rating_question) { FactoryGirl.create(:rating_question, :finalized, :max_length => 10) } it "generates report data" do 5.times { FactoryGi...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/organization_spec.rb
Ruby
mit
47
master
4,506
require 'spec_helper' describe Organization do before(:each) do orgs_response = mock(OAuth2::Response) users_response = mock(OAuth2::Response) org_exists = mock(OAuth2::Response) single_organization_response = mock(OAuth2::Response) bad_response = mock(OAuth2::Response).as_null_object @access...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/question_with_options_spec.rb
Ruby
mit
47
master
4,157
require 'spec_helper' describe QuestionWithOptions do context 'when initializing answers for a response' do let(:response) { FactoryGirl.create :response } it "initializes answers for each of its sub-questions" do question = FactoryGirl.create(:radio_question, :with_options) sub_question = Facto...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/answer_spec.rb
Ruby
mit
47
master
15,242
require 'spec_helper' describe Answer do context "validations" do context "for mandatory questions" do let(:complete_response) { FactoryGirl.create(:response, :complete) } it "does not save if a mandatory question is not answered for a complete response" do question = FactoryGirl.create(:que...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/survey_spec.rb
Ruby
mit
47
master
31,249
require 'spec_helper' describe Survey do context "when validating" do it { should validate_presence_of :name } it { should validate_presence_of :expiry_date } it { should ensure_length_of(:description).is_at_most(250) } context "validates the expiry date" do it "to not be in the past when surv...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/option_spec.rb
Ruby
mit
47
master
10,637
require 'spec_helper' describe Option do it { should validate_presence_of(:content) } it { should validate_presence_of(:question_id) } context "scopes" do it "includes only finalized options" do finalized_option = FactoryGirl.create(:option, :finalized) non_finalized_option = FactoryGirl.create(...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/response_serializer_spec.rb
Ruby
mit
47
master
1,632
require 'spec_helper' describe ResponseSerializer do context "#to_json_with_answers_and_choices" do it "renders the answers" do response = (FactoryGirl.create :response_with_answers).reload response_serializer = ResponseSerializer.new(response) response_json = JSON.parse(response_serializer.to_...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/single_line_question_spec.rb
Ruby
mit
47
master
351
require 'spec_helper' describe SingleLineQuestion do it "is a question with type = 'SingleLineQuestion'" do question = FactoryGirl.create(:single_line_question) question.should be_a SingleLineQuestion question.type.should == "SingleLineQuestion" end it_behaves_like "a question with max length" it...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/response_spec.rb
Ruby
mit
47
master
25,300
require 'spec_helper' describe Response do it { should validate_presence_of(:survey_id) } it { should validate_presence_of(:organization_id) } it { should validate_presence_of(:user_id) } it "doesn't allow changing back from complete to incomplete" do response = FactoryGirl.create(:response, :complete) ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/numeric_question_spec.rb
Ruby
mit
47
master
3,578
require 'spec_helper' describe NumericQuestion do it { should validate_numericality_of :max_value } it { should validate_numericality_of :min_value } it "is a question with type = 'NumericQuestion'" do question = FactoryGirl.create(:numeric_question) question.should be_a NumericQuestion question.typ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/multi_choice_question_spec.rb
Ruby
mit
47
master
840
require 'spec_helper' describe MultiChoiceQuestion do it_behaves_like "a question" context "reports" do it "returns the number of answers grouped by option content" do question = FactoryGirl.create(:multi_choice_question, :finalized, :with_options) 5.times do response = FactoryGirl.create(...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/publisher_spec.rb
Ruby
mit
47
master
3,322
require 'spec_helper' describe Publisher do before(:each) do @params = { :expiry_date => Date.tomorrow.to_s, :user_ids => [1,2], :participating_organization_ids => [2,3]} end context "validations" do it "checks whether the users_ids are valid" do survey = FactoryGir...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/sanitizer_spec.rb
Ruby
mit
47
master
272
require 'spec_helper' describe Sanitizer do it "removes blank params" do params = ["", "1", "2"] Sanitizer.clean_params(params).should == ["1", "2"] end it "returns an empty array if params is nil" do Sanitizer.clean_params(nil).should == [] end end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/multi_record_category_spec.rb
Ruby
mit
47
master
1,845
require 'spec_helper' describe MultiRecordCategory do it { should have_many :records } it "doesn't allow nested multi-record categories" do parent_mr = FactoryGirl.create(:multi_record_category) new_category = FactoryGirl.build(:multi_record_category, :category => parent_mr) new_category.should_not be...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/question_spec.rb
Ruby
mit
47
master
23,014
require 'spec_helper' include ActionDispatch::TestProcess describe Question do context "scopes" do context "when finding non-private questions" do it "gets questions which have the private flag set to false" do question = FactoryGirl.create(:question, :private => false) Question.not_private...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/photo_question_spec.rb
Ruby
mit
47
master
652
require 'spec_helper' describe PhotoQuestion do context "when validating max length" do it { should allow_mass_assignment_of(:max_length) } it { should validate_numericality_of(:max_length) } it "doesn't allow a negative max-length" do survey = FactoryGirl.create(:survey) question = PhotoQues...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/survey_filter_spec.rb
Ruby
mit
47
master
2,199
require 'spec_helper' describe SurveyFilter do context "filters surveys" do it "returns drafts surveys if survey filter is set to 'drafts'" do survey = FactoryGirl.create(:survey, :finalized => false) another_survey = FactoryGirl.create(:survey, :finalized => true) filter_surveys = SurveyFilter...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/public_ability_spec.rb
Ruby
mit
47
master
2,332
require "cancan/matchers" describe "Abilities" do subject { ability } describe "public responses" do base_user_info = { :name => "John", :email => "john@gmail.com", :org_id => 5, :user_id => 6, :session_token => "foo" } let(:ability){ PublicAbility.new(base_user_info) } ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/survey_user_spec.rb
Ruby
mit
47
master
1,243
require 'spec_helper' describe SurveyUser do let(:draft_survey) { FactoryGirl.create(:survey) } let(:finalized_survey) { FactoryGirl.create(:survey, :finalized => true) } subject { SurveyUser.create(:survey_id => draft_survey.id, :user_id => 1) } context "when validating that the survey is finalized" do ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/date_question_spec.rb
Ruby
mit
47
master
1,068
require 'spec_helper' describe DateQuestion do it_behaves_like "a question" context "report_data" do it "generates report data" do date_question = FactoryGirl.create(:date_question, :finalized) FactoryGirl.create( :answer_with_complete_response, :content=>"2010/02/21", :question => date_question) ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/user_spec.rb
Ruby
mit
47
master
2,639
require 'spec_helper' describe User do before(:each) do orgs_response = mock(OAuth2::Response) users_response = mock(OAuth2::Response) names_response = mock(OAuth2::Response) user_exists = mock(OAuth2::Response) @access_token = mock(OAuth2::AccessToken) @access_token.stub(:get).with('/api/o...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/category_spec.rb
Ruby
mit
47
master
15,300
require 'spec_helper' describe Category do it { should validate_presence_of :content } it { should_not have_many :records } context "scopes" do it "finds the finalized categories" do finalized_category = FactoryGirl.create(:category, :finalized) non_finalized_category = FactoryGirl.create(:categ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/participating_organization_spec.rb
Ruby
mit
47
master
906
require 'spec_helper' describe ParticipatingOrganization do it { should validate_presence_of :survey_id } it { should validate_presence_of :organization_id } it "validates uniqueness of the (organization_id, survey_id) tuple" do survey = FactoryGirl.create :survey, :finalized => true ParticipatingOrgani...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/reports/excel/row_spec.rb
Ruby
mit
47
master
696
require 'spec_helper' describe Reports::Excel::Row do it "can add elements to itself" do row = Reports::Excel::Row.new row << "Foo" row << "Bar" row.elements.should == ["Foo", "Bar"] end it "can add arrays of elements to itself" do row = Reports::Excel::Row.new row << %w(Foo Bar) row...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/reports/excel/metadata_spec.rb
Ruby
mit
47
master
6,426
require 'spec_helper' describe Reports::Excel::Metadata do let(:access_token) { access_token = mock(OAuth2::AccessToken) } context "when returning the metadata for a response" do before(:each) do names_response = mock(OAuth2::Response) access_token.stub(:get).with('/api/users/users_for_ids', :para...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/reports/excel/responses_spec.rb
Ruby
mit
47
master
2,509
require "spec_helper" describe Reports::Excel::Responses do it "includes the completed responses" do complete_response = FactoryGirl.create(:response, :status => "complete") incomplete_response = FactoryGirl.create(:response, :status => "incomplete") Reports::Excel::Responses.new(Response.scoped).build.a...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/reports/excel/questions_spec.rb
Ruby
mit
47
master
2,265
require "spec_helper" describe Reports::Excel::Questions do let!(:survey) { FactoryGirl.create(:survey) } let!(:finalized_question) { FactoryGirl.create(:question, :finalized, :survey => survey) } let!(:private_question) { FactoryGirl.create(:question, :finalized, :private, :survey => survey) } let(:admin_abil...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/models/reports/excel/job_spec.rb
Ruby
mit
47
master
8,839
require 'spec_helper' describe Reports::Excel::Job do let(:survey) { FactoryGirl.create(:survey) } let(:responses) { FactoryGirl.create_list(:response, 5, :survey => survey) } let(:server_url) { "http://example.com" } let(:metadata) { Reports::Excel::Metadata.new(responses, @access_token, :disable_filtering =>...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/publications_controller_spec.rb
Ruby
mit
47
master
10,895
require 'spec_helper' describe PublicationsController do render_views let(:survey) { FactoryGirl.create(:survey, :organization_id => LOGGED_IN_ORG_ID, :finalized => true) } before(:each) do sign_in_as('cso_admin') users_response = mock(OAuth2::Response) access_token = mock(OAuth2::AccessToken) ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/responses_controller_spec.rb
Ruby
mit
47
master
27,748
require 'spec_helper' describe ResponsesController do let(:survey) { FactoryGirl.create(:survey_with_questions, :organization_id => 1) } before(:each) do sign_in_as('cso_admin') session[:user_info][:org_id] = 1 end context "POST 'create'" do let(:survey) { FactoryGirl.create(:survey, :finalized =>...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/application_controller_spec.rb
Ruby
mit
47
master
4,930
require 'spec_helper' describe ApplicationController do controller do # mocking index action for testing locale def index redirect_to root_path end # mocking create action for testing expired token def create response = RSpec::Mocks::Mock.new(:error= => :error, :parsed => nil, :body ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/organization_dashboards_controller_spec.rb
Ruby
mit
47
master
1,606
require 'spec_helper' describe OrganizationDashboardsController do context "GET index" do before(:each) do response = mock(OAuth2::Response) access_token = mock(OAuth2::AccessToken) controller.stub(:access_token).and_return(access_token) access_token.stub(:get).and_return(response) ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/sessions_controller_spec.rb
Ruby
mit
47
master
1,706
require 'spec_helper' describe SessionsController do before do @auth = request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:user_owner] end context "when creating a session" do it "assigns the user ID to the session hash" do post :create, :provider => 'user_owner' response.should redir...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/survey_dashboard_controller_spec.rb
Ruby
mit
47
master
1,779
require 'spec_helper' describe SurveyDashboardController do let(:survey) { FactoryGirl.create(:survey, :organization_id => LOGGED_IN_ORG_ID) } describe "GET 'index'" do before(:each) do sign_in_as("cso_admin") end it "renders the 'index' template" do stub_users_for_ids([]) get :inde...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/surveys_controller_spec.rb
Ruby
mit
47
master
8,858
require 'spec_helper' describe SurveysController do render_views context "GET 'index'" do before(:each) do request.env['HTTPS'] = 'on' session[:access_token] = "123" response = mock(OAuth2::Response) access_token = mock(OAuth2::AccessToken) controller.stub(:access_token).and_retu...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/records_controller_spec.rb
Ruby
mit
47
master
1,515
require 'spec_helper' describe RecordsController do describe "GET 'create'" do before(:each) { request.env["HTTP_REFERER"] = "http://example.com" } let(:category) { category = FactoryGirl.create(:category) } let(:response) { FactoryGirl.create(:response) } it "creates a new record" do expect {...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/v2_survey_builder/surveys_controller_spec.rb
Ruby
mit
47
master
9,198
require 'spec_helper' describe V2SurveyBuilder::SurveysController do render_views context "GET new" do it "assigns a survey" do sign_in_as('cso_admin') get :new assigns(:survey).should be_a Survey end end context "GET 'index'" do before(:each) do request.env['HTTPS'] = 'on...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/records_controller_spec.rb
Ruby
mit
47
master
2,200
require 'spec_helper' describe Api::V1::RecordsController do context "POST 'create'" do it "creates a record" do record_attrs = FactoryGirl.attributes_for(:record) expect { post :create, :record => record_attrs }.to change { Record.count }.by 1 end it "returns the newly created...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/responses_controller_spec.rb
Ruby
mit
47
master
15,180
require 'spec_helper' module Api::V1 describe ResponsesController do let(:organization_id) { 12 } before(:each) do sign_in_as('cso_admin') session[:user_info][:org_id] = organization_id response = double('response') parsed_response = { "email" => "admin@admin.com", ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/organizations_controller_spec.rb
Ruby
mit
47
master
1,220
require "spec_helper" module Api module V1 describe OrganizationsController do before(:each) { sign_in_as("super_admin") } context "DELETE 'destroy'" do it "kicks off a delayed job" do organization = FactoryGirl.build(:organization) expect { delete :destroy, :id => organi...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/jobs_controller_spec.rb
Ruby
mit
47
master
627
require 'spec_helper' module Api module V1 describe JobsController do context "GET 'alive'" do it "returns true (as JSON) if the given job is running" do job = Delayed::Job.enqueue(Reports::Excel::Job.new) get :alive, :id => job.id response.should be_ok JSON....
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/options_controller_spec.rb
Ruby
mit
47
master
4,826
require 'spec_helper' module Api module V1 describe OptionsController do let(:organization_id) { 12 } let(:survey) { FactoryGirl.create(:survey, :organization_id => organization_id) } let(:question) { FactoryGirl.create(:question, :survey => survey) } before(:each) do sign_in_as(...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/surveys_controller_spec.rb
Ruby
mit
47
master
5,754
require 'spec_helper' describe Api::V1::SurveysController do let(:survey) { FactoryGirl.create :survey, :organization_id => LOGGED_IN_ORG_ID, :finalized => true } before(:each) do sign_in_as('cso_admin') response = double('response') parsed_response = { "email" => "admin@admin.com", ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/deep_surveys_controller_spec.rb
Ruby
mit
47
master
3,182
require 'spec_helper' describe Api::V1::DeepSurveysController do context "GET index" do before(:each) { sign_in_as('viewer') } it "fetches active surveys"do finalized_survey = FactoryGirl.create(:survey, :finalized, :organization_id => LOGGED_IN_ORG_ID) unfinalized_survey = FactoryGirl.create(:s...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/api_application_controller_spec.rb
Ruby
mit
47
master
3,043
require 'spec_helper' module Api module V1 describe APIApplicationController do controller(APIApplicationController) do def index response = RSpec::Mocks::Mock.new(:error= => :error, :parsed => nil, :body => nil, :status => 401) raise OAuth2::Error.new(response) end ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/categories_controller_spec.rb
Ruby
mit
47
master
7,037
require 'spec_helper' describe Api::V1::CategoriesController do before(:each) do sign_in_as('super_admin') end context "POST 'create'" do let(:survey) { FactoryGirl.create(:survey) } it "creates a new category in the database" do category_hash = FactoryGirl.attributes_for(:category, :survey_i...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/auth_controller_spec.rb
Ruby
mit
47
master
1,312
require 'spec_helper' module Api module V1 describe AuthController do context "POST 'create'" do before(:each) do client = double('client') password = double('password') access_token = double('access_token') response = double('response') parsed_res...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/audits_controller_spec.rb
Ruby
mit
47
master
1,896
require 'spec_helper' module Api module V1 describe AuditsController do let(:device_id) { "fooboo400800" } let(:file) { mock('file') } let(:filename) { "#{Rails.root}/log/#{device_id}.log" } context "POST 'create'" do let(:platform_data) { {"daba" => "doo"} } it "creates...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/controllers/api/v1/questions_controller_spec.rb
Ruby
mit
47
master
10,520
require 'spec_helper' module Api module V1 describe QuestionsController do let(:organization_id) { 12 } let(:survey) { FactoryGirl.create(:survey, :organization_id => organization_id) } before(:each) do sign_in_as('super_admin') session[:user_info][:org_id] = organization_id ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/abilities/field_agent_ability_spec.rb
Ruby
mit
47
master
2,461
require "cancan/matchers" describe FieldAgentAbility do subject { ability } let(:user_info) { { :name => "John", :email => "john@gmail.com", :org_id => 5, :user_id => 6, :session_token => "rdsfgasidufyasd", :role => 'field_agent' } } let(:ability){ FieldA...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/abilities/super_admin_ability_spec.rb
Ruby
mit
47
master
636
require 'cancan/matchers' describe SuperAdminAbility do subject { ability } let(:user_info) { { :name => 'John', :email => 'john@gmail.com', :org_id => 5, :user_id => 6, :session_token => 'rdsfgasidufyas', :role => 'super_admin' } } let(:ability){ SuperAd...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/abilities/supervisor_ability_spec.rb
Ruby
mit
47
master
2,688
require 'cancan/matchers' describe SupervisorAbility do subject { ability } let(:user_info) { { :name => 'John', :email => 'john@gmail.com', :org_id => 5, :user_id => 6, :session_token => 'rdsfgasidufyas', :role => 'supervisor' } } let(:ability){ Supervis...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/abilities/viewer_ability_spec.rb
Ruby
mit
47
master
2,585
require "cancan/matchers" describe ViewerAbility do subject { ability } let(:user_info) { { :name => "John", :email => "john@gmail.com", :org_id => 5, :user_id => 6, :session_token => "rdsfgasidufyasd", :role => 'viewer' } } let(:ability){ ViewerAbility.n...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/abilities/manager_ability_spec.rb
Ruby
mit
47
master
5,037
require 'cancan/matchers' describe ManagerAbility do subject { ability } let(:user_info) { { :name => 'John', :email => 'john@gmail.com', :org_id => 5, :user_id => 6, :session_token => 'rdsfgasidufyas', :role => 'manager' } } let(:ability){ ManagerAbility...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/abilities/admin_ability_spec.rb
Ruby
mit
47
master
5,031
require 'cancan/matchers' describe AdminAbility do subject { ability } let(:user_info) { { :name => 'John', :email => 'john@gmail.com', :org_id => 5, :user_id => 6, :session_token => 'rdsfgasidufyas', :role => 'admin' } } let(:ability){ AdminAbility.new(u...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/abilities/designer_ability_spec.rb
Ruby
mit
47
master
4,288
require 'cancan/matchers' describe DesignerAbility do subject { ability } let(:user_info) { { :name => 'John', :email => 'john@gmail.com', :org_id => 5, :user_id => 6, :session_token => 'rdsfgasidufyas', :role => 'designer' } } let(:ability){ DesignerAbil...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/reporters/survey_reporter_spec.rb
Ruby
mit
47
master
5,248
require 'spec_helper' describe SurveyReporter do let(:survey) { FactoryGirl.create(:survey) } let(:user) { FactoryGirl.build(:user) } context "for incomplete responses" do it 'returns the number of incomplete responses grouped by the month it was created' do response = Timecop.freeze("2013-05-05") { F...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/reporters/multi_choice_question_reporter_spec.rb
Ruby
mit
47
master
2,925
require 'spec_helper' describe MultiChoiceQuestionReporter do let(:question) { FactoryGirl.create(:multi_choice_question, :finalized) } context "header" do it "includes a header of each of the options as well" do reporter = MultiChoiceQuestionReporter.decorate(question) option = FactoryGirl.create...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/reporters/response_counts_spec.rb
Ruby
mit
47
master
3,408
require 'spec_helper' describe ResponseCounts do it 'finds the first count matching the given month' do response_count_1 = ResponseCount.new("May 2013", 1, 1) response_count_2 = ResponseCount.new("Jun 2013", 1, 1) counts = ResponseCounts.new([response_count_2, response_count_1]) counts.find_by_month(...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/reporters/question_reporter_spec.rb
Ruby
mit
47
master
1,087
require 'spec_helper' describe QuestionReporter do context "formatted answers" do it "returns an empty string if no answers are passed in" do reporter = QuestionReporter.decorate(FactoryGirl.create(:question)) reporter.formatted_answers_for([]).should == "" end it "returns the answer's conte...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/reporters/response_count_spec.rb
Ruby
mit
47
master
846
require 'spec_helper' describe ResponseCount do context "when merging with another ResponseCount" do it "adds up the incompletes" do response_count_1 = ResponseCount.new("May 2013", 5, 5) response_count_2 = ResponseCount.new("May 2013", 6, 5) response_count_1.merge(response_count_2).incompletes...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/uploaders/image_uploader_spec.rb
Ruby
mit
47
master
1,973
require 'carrierwave/test/matchers' describe ImageUploader do include CarrierWave::Test::Matchers before do ImageUploader.enable_processing = true ImageUploader.storage = :file @question = FactoryGirl.create :question @uploader = ImageUploader.new(@question, :image) file = File.open "#{Rails....
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/support/models/shared_examples_for_question.rb
Ruby
mit
47
master
1,120
require 'spec_helper' shared_examples "a question" do let(:question) { described_class.create(:content => "foo", :survey_id => 666) } it { should respond_to :content } it { should respond_to :mandatory } it { should validate_presence_of :content } it { should respond_to(:image) } it { should belong_to :su...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/support/models/shared_examples_for_question_with_options.rb
Ruby
mit
47
master
1,323
require 'spec_helper' shared_examples "a question with options" do |question_klass| let(:factory_name) { question_klass.to_s.underscore.to_sym } context "reports" do it "counts all its answers grouped by the option's content" do question = FactoryGirl.create(factory_name, :finalized) first_option...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/support/models/shared_examples_for_question_with_max_length.rb
Ruby
mit
47
master
573
require 'spec_helper' shared_examples "a question with max length" do let(:question_with_max_length) {described_class.new(:content => "foo", :max_length => -5) } context "when validating max length" do it { should respond_to :max_length } it { should allow_mass_assignment_of(:max_length) } it { shoul...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/support/matchers/excel_matcher.rb
Ruby
mit
47
master
808
RSpec::Matchers.define :have_header_cell do |cell_value| match do |ws| ws.rows[0].cells.map(&:value).include? cell_value end end RSpec::Matchers.define :have_cell do |expected| match do |ws| ws.rows[@index].cells.map(&:value).include? expected end chain :in_row do |index| @index = index end ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/serializers/deep_option_serializer_spec.rb
Ruby
mit
47
master
288
require 'spec_helper' describe DeepOptionSerializer do subject { DeepOptionSerializer.new(FactoryGirl.create(:option)) } it { should have_json_key :order_number } it { should have_json_key :id } it { should have_json_key :content } it { should have_json_key :question_id } end
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/serializers/deep_question_serializer_spec.rb
Ruby
mit
47
master
1,829
require 'spec_helper' describe DeepQuestionSerializer do subject { DeepQuestionSerializer.new(FactoryGirl.create(:question)) } before(:each) do file = fixture_file_upload('/images/sample.jpg') Question.any_instance.stub_chain(:image, :thumb, :file).and_return(file) end it { should have_json_key :id} ...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/serializers/deep_survey_serializer_spec.rb
Ruby
mit
47
master
1,387
require 'spec_helper' describe DeepSurveySerializer do subject { DeepSurveySerializer.new(FactoryGirl.create(:survey)) } it { should have_json_key :name } it { should have_json_key :published_on } it { should have_json_key :id } it { should have_json_key :description } it { should have_json_key :expiry_da...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/serializers/deep_category_serializer_spec.rb
Ruby
mit
47
master
420
require 'spec_helper' describe DeepCategorySerializer do subject { DeepCategorySerializer.new(FactoryGirl.create(:category)) } it { should have_json_key :id} it { should have_json_key :parent_id} it { should have_json_key :type} it { should have_json_key :content} it { should have_json_key :surv...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/helpers/responses_helper_spec.rb
Ruby
mit
47
master
697
require 'spec_helper' Person = Struct.new(:name, :age) describe ResponsesHelper do context "when merging arrays" do it "removes elements whose attributes are the same" do first = [Person.new("Foo", 15), Person.new("Bar", 17)] second = [Person.new("Foo", 15), Person.new("Bar", 19)] expect(merge...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
spec/routing/routes_spec.rb
Ruby
mit
47
master
1,011
require 'spec_helper' describe "Routes" do context "when routing based on locale" do it "routes /fr/surveys to Surveys#index in French" do get("/fr/surveys").should route_to("surveys#index", :locale => 'fr') end it "routes /en/surveys to Surveys#index in English" do get("/en/surveys").should...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
script/rspec_zeus_runner_rubymine.rb
Ruby
mit
47
master
648
#!/usr/bin/env ruby # Suppress zeus' whining about how it won't use your RAILS_ENV ENV.delete('RAILS_ENV') # Zeus 0.13.2 parses options badly. RubyMine will invoke this file like this: # rspec_runner.rb spec/my_cool_file.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::...
github
nilenso/ashoka-survey-web
https://github.com/nilenso/ashoka-survey-web
app/serializers/deep_question_serializer.rb
Ruby
mit
47
master
653
class DeepQuestionSerializer < ActiveModel::Serializer attributes :id, :identifier, :parent_id, :min_value, :max_value, :type, :content, :image_in_base64, :survey_id, :max_length, :mandatory, :image_url, :order_number, :category_id # Need to do this because `option` is a reserved name in this gem's N...