repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
twei55/simple-bookshelf
db/migrate/20120323161737_create_books_tags_join_table.rb
<filename>db/migrate/20120323161737_create_books_tags_join_table.rb class CreateBooksTagsJoinTable < ActiveRecord::Migration def up create_table :books_nested_tags, :id => false, :force => true do |t| t.column :book_id, :integer t.column :nested_tag_id, :integer t.timestamps end ...
twei55/simple-bookshelf
app/models/book_author.rb
<gh_stars>0 class BookAuthor < ActiveRecord::Base belongs_to :book belongs_to :author end
twei55/simple-bookshelf
db/migrate/20120622213029_create_entries.rb
class CreateEntries < ActiveRecord::Migration def up create_table :entries, :force => true do |t| t.integer :book_id t.integer :group_id t.timestamps end end def down drop_table :entries end end
twei55/simple-bookshelf
spec/controllers/books_controller_spec.rb
<gh_stars>0 require 'spec_helper' describe BooksController do context "unauthorized" do context "GET index" do it "redirects to login page" do get :index response.should be_redirect end end end context "admin" do login_admin context "GET index" do it "renders index page" do get...
twei55/simple-bookshelf
spec/factories/authors.rb
# encoding: utf-8 # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :author do first_name "Vorname" last_name "Nachname" factory :rowohlt do first_name "Harry" last_name "Rowohlt" end factory :timm do first_name "Uwe" la...
twei55/simple-bookshelf
app/models/group.rb
class Group < ActiveRecord::Base has_many :users has_one :admin has_many :entries has_many :books, :through => :entries validates_presence_of :name end
twei55/simple-bookshelf
spec/requests/query_books_spec.rb
# encoding: utf-8 require 'spec_helper' describe "query" do let(:admin) { FactoryGirl.create(:admin, :group => Group.first) } let(:user) { FactoryGirl.create(:user, :group => Group.first) } before(:each) do visit new_user_session_path fill_in("user_email", :with => admin.email) fill_in("user_password", :w...
twei55/simple-bookshelf
spec/controllers/nested_tags_controller_spec.rb
<reponame>twei55/simple-bookshelf require 'spec_helper' describe NestedTagsController do end
twei55/simple-bookshelf
spec/models/user_spec.rb
require 'spec_helper' describe User do describe '.add_to_group' do let(:group) {FactoryGirl.create(:group1)} let(:user) {FactoryGirl.build(:user)} context "group name given" do it "creates a new group and adds user to it" do params = {"group" => {"id" => "", "name" => "Neue Gruppe"}} user.add_to_...
twei55/simple-bookshelf
db/migrate/20120623134237_drop_admins_table.rb
class DropAdminsTable < ActiveRecord::Migration def up drop_table :admins end def down end end
twei55/simple-bookshelf
spec/models/author_spec.rb
<filename>spec/models/author_spec.rb require 'spec_helper' describe Author do describe "#full_name" do end describe ".find_or_create" do end end
twei55/simple-bookshelf
spec/factories/nested_tags.rb
<reponame>twei55/simple-bookshelf # encoding: utf-8 # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :tag1, :class => NestedTag do name "Alleinerziehende" parent_id 0 end factory :tag2, :class => NestedTag do name "Bildung" parent_id 0 end factory :...
twei55/simple-bookshelf
app/models/nested_tag.rb
class NestedTag < ActiveRecord::Base acts_as_tree :order => "name" ################################ ### ActiveRecord Associations ## ################################ has_and_belongs_to_many :books, :join_table => "books_nested_tags" validates_presence_of :name scope :root, :conditions => ["par...
twei55/simple-bookshelf
spec/factories/users.rb
# encoding: utf-8 # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :user do sequence(:email) {|n| "<EMAIL>" } password "<PASSWORD>" password_confirmation "<PASSWORD>" confirmed_at Time.now end factory :admin, :class => User do sequence(:email) {|n...
twei55/simple-bookshelf
spec/requests/keywords_spec.rb
# encoding: utf-8 require 'spec_helper' describe "create, update, delete keywords" do let(:admin) { FactoryGirl.create(:admin, :group => Group.first) } let(:user) { FactoryGirl.create(:user, :group => Group.first) } before(:each) do visit new_user_session_path fill_in("user_email", :with => admin.email) ...
twei55/simple-bookshelf
db/migrate/20120623134029_add_admin_flag_to_users.rb
class AddAdminFlagToUsers < ActiveRecord::Migration def up add_column :users, :admin, :boolean, :default => false end def down remove_column :users, :admin end end
twei55/simple-bookshelf
spec/spec_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' require 'capybara/rspec' require 'thinking_sphinx/test' # Requires supporting ruby files with custom match...
twei55/simple-bookshelf
spec/factories/formats.rb
<filename>spec/factories/formats.rb # encoding: utf-8 # Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :dossier, :class => Format do name "Dossier" end factory :studie, :class => Format do name "Studie" end factory :gesetz, :class => Format do name "...
twei55/simple-bookshelf
spec/models/nested_tag_spec.rb
<reponame>twei55/simple-bookshelf<filename>spec/models/nested_tag_spec.rb<gh_stars>0 require 'spec_helper' describe NestedTag do end
twei55/simple-bookshelf
app/models/book.rb
<reponame>twei55/simple-bookshelf # encoding: utf-8 class Book < ActiveRecord::Base ################################ ### ActiveRecord Associations ## ################################ has_many :book_authors has_many :authors, :through => :book_authors has_many :entries has_many :groups, :through => :ent...
twei55/simple-bookshelf
spec/models/book_author_spec.rb
<reponame>twei55/simple-bookshelf require 'spec_helper' describe BookAuthor do end
twei55/simple-bookshelf
app/models/format.rb
<reponame>twei55/simple-bookshelf class Format < ActiveRecord::Base ################################ ### ActiveRecord Associations ## ################################ has_and_belongs_to_many :books attr_accessible :name validates_presence_of :name end
twei55/simple-bookshelf
app/controllers/formats_controller.rb
<reponame>twei55/simple-bookshelf<gh_stars>0 # encoding: utf-8 class FormatsController < ApplicationController before_filter :authenticate_admin def index @format = Format.new end def create @format = Format.new(params[:format]) if Format.find_by_name(params[:format][:name]).nil? if (!@format.nil? && @fo...
lfu/ansible_tower_client_ruby
spec/api_spec.rb
<reponame>lfu/ansible_tower_client_ruby describe AnsibleTowerClient::Api do let(:faraday_connection) { AnsibleTowerClient::MockApi.new(:api_version => api_version) } let(:api_version) { 1 } subject { described_class.new(faraday_connection, api_version) } it "#instance returns an existing instance" do ...
lfu/ansible_tower_client_ruby
spec/support/mock_api.rb
module AnsibleTowerClient class MockApi class Response attr_reader :body, :api_version def initialize(body) @body = body end end def initialize(version = nil, api_version: 2) @awx_version = version @api_version = api_version end def get(path, get_options = n...
lfu/ansible_tower_client_ruby
spec/job_template_v2_spec.rb
describe AnsibleTowerClient::JobTemplateV2 do let(:url) { "example.com/api/v1/job_templates" } let(:api) { AnsibleTowerClient::Api.new(connection, 1) } let(:connection) { AnsibleTowerClient::MockApi.new("2.1") } let(:raw_instance) { bui...
lfu/ansible_tower_client_ruby
lib/ansible_tower_client/base_models/workflow_job_node.rb
<reponame>lfu/ansible_tower_client_ruby module AnsibleTowerClient class WorkflowJobNode < BaseModel def workflow_job api.workflow_jobs.find(workflow_job_id) end def job job_id.nil? ? nil : api.jobs.find(job_id) end end end
lfu/ansible_tower_client_ruby
spec/support/mock_api/v2/credential.rb
module AnsibleTowerClient class MockApi module CredentialV2 def self.collection [ { :id => 2, :type => "credential", :url => "/api/v2/credentials/2/", :related => { :created_by =>...
lfu/ansible_tower_client_ruby
spec/project_spec.rb
<gh_stars>0 describe AnsibleTowerClient::Project do let(:url) { "example.com/api/v1/projects" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:raw_instance) { build(:response_instance, :project, :klass => described_class) } include_examples "Api Methods" ...
lfu/ansible_tower_client_ruby
spec/system_job_template_spec.rb
describe AnsibleTowerClient::SystemJobTemplate do let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:raw_instance) { build(:response_instance, :system_job_template, :klass => described_class) } describe "#launch" do let(:post_result_body) { {:system_job => 123} } ...
lfu/ansible_tower_client_ruby
spec/workflow_job_template_spec.rb
<filename>spec/workflow_job_template_spec.rb describe AnsibleTowerClient::WorkflowJobTemplate do let(:url) { "example.com/api/v1/workflow_job_templates" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new("1.1"), 1) } let(:raw_instance) ...
lfu/ansible_tower_client_ruby
lib/ansible_tower_client/v2/credential_type_v2.rb
<reponame>lfu/ansible_tower_client_ruby module AnsibleTowerClient class CredentialTypeV2 < BaseModel class Inputs < BaseModel; end def self.endpoint 'credential_types' end end end
lfu/ansible_tower_client_ruby
lib/ansible_tower_client/connection.rb
module AnsibleTowerClient class Connection attr_reader :options # Options: # - base_url: you have two options here: # a) pass in only scheme and hostname e.g. 'https://localhost:54321' to allow client to connect to both api v1 # and v2 versions like this: `client.api(:version => 1)` and `c...
lfu/ansible_tower_client_ruby
spec/connection_spec.rb
<gh_stars>0 describe AnsibleTowerClient::Connection do let(:logger) { double } let(:base_options) { {:base_url => "https://example1.com", :username => "admin", :password => "<PASSWORD>", :verify_ssl => OpenSSL::SSL::VERIFY_NONE, :logger => logger} } subject { described_class.new(base_options) } it "#ini...
lfu/ansible_tower_client_ruby
lib/ansible_tower_client/version.rb
<filename>lib/ansible_tower_client/version.rb module AnsibleTowerClient VERSION = "0.15.0".freeze end
lfu/ansible_tower_client_ruby
spec/support/mock_api/v2/credential_type.rb
module AnsibleTowerClient class MockApi module CredentialTypeV2 def self.collection [ { :id => 16, :type => "credential_type", :url => "/api/v2/credential_types/16/", :related => { ...
lfu/ansible_tower_client_ruby
spec/workflow_job_node_spec.rb
describe AnsibleTowerClient::WorkflowJobNode do let(:url) { "example.com/api/v1/workflow_job_nodes" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:raw_instance) { build(:response_instance, :workflow_job_node, :klass ...
lfu/ansible_tower_client_ruby
spec/workflow_job_spec.rb
<reponame>lfu/ansible_tower_client_ruby describe AnsibleTowerClient::WorkflowJob do let(:url) { "example.com/api/v1/workflow_jobs" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:raw_instance) { build(:response_instan...
lfu/ansible_tower_client_ruby
spec/inventory_spec.rb
<gh_stars>0 describe AnsibleTowerClient::Inventory do let(:url) { "example.com/api/v1/inventories" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:inventory_source) { build(:response_url_collection, :klass => AnsibleTowerClient::InventorySource) } l...
lfu/ansible_tower_client_ruby
spec/v2/credential_type_spec.rb
describe AnsibleTowerClient::CredentialTypeV2 do let(:api) { AnsibleTowerClient::Api.new(connection, 2) } let(:connection) { AnsibleTowerClient::MockApi.new } let(:raw_instance) { build(:response_instance, :credential_type, :klass => described_class) } inclu...
lfu/ansible_tower_client_ruby
lib/ansible_tower_client/base_models/workflow_job.rb
<gh_stars>0 module AnsibleTowerClient class WorkflowJob < BaseModel def workflow_job_nodes # this is where Ansible API deviates from other part by using `workflow_nodes` Collection.new(api).find_all_by_url(related['workflow_nodes']) end end end
lfu/ansible_tower_client_ruby
spec/job_spec.rb
describe AnsibleTowerClient::Job do let(:url) { "example.com/api/v1/jobs" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:raw_instance) { build(:response_instance, :job, :klass => described_class) } let(:raw_instanc...
lfu/ansible_tower_client_ruby
lib/ansible_tower_client/v2/credential_v2.rb
<gh_stars>0 module AnsibleTowerClient class CredentialV2 < Credential class Inputs < BaseModel def size @raw_hash.keys.size end end def self.endpoint 'credentials' end end end
lfu/ansible_tower_client_ruby
spec/job_event_spec.rb
<gh_stars>0 describe AnsibleTowerClient::JobEvent do let(:url) { "example.com/api/v1/job_events" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } include_examples "Api Methods" end
lfu/ansible_tower_client_ruby
spec/host_spec.rb
<gh_stars>0 describe AnsibleTowerClient::Host do let(:url) { "example.com/api/v1/hosts" } let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:raw_instance) { build(:response_instance, :host, :klass => described_class) } include_examples "Api Methods" include_e...
lfu/ansible_tower_client_ruby
spec/organization_spec.rb
<filename>spec/organization_spec.rb describe AnsibleTowerClient::Organization do let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new, 1) } let(:raw_instance) { build(:response_instance, :organization, :klass => described_class, :description => "The Organization", :name => "MyOrg") } ...
diverse-inc/rsolr-ext
lib/rsolr-ext/response.rb
module RSolr::Ext::Response autoload :Docs, 'rsolr-ext/response/docs' autoload :Facets, 'rsolr-ext/response/facets' autoload :Spelling, 'rsolr-ext/response/spelling' class Base < Mash attr :original_hash attr_reader :request_path, :request_params def initialize hash, handler, request...
Kelthagas/mr_sorty_batallones
lib/mr_sorty/heapsort_min.rb
module HeapsortMin class HeapsortMin def initialize arr @minheap = [] @minheap = arr end def get_array return @minheap end def return_heap arr = [] @minheap.each do |node| arr.push(remove_node) end return arr end def insert_node ...
Kelthagas/mr_sorty_batallones
spec/mr_sorty_spec.rb
<gh_stars>0 RSpec.describe MrSorty do it "has a version number" do expect(MrSorty::VERSION).not_to be nil end it "does something useful" do sort = HeapsortMin::HeapsortMin.new [1, 2, 3] expect(sort.return_heap).to eq([0, 0, 0]) end end
Kelthagas/mr_sorty_batallones
lib/mr_sorty.rb
<filename>lib/mr_sorty.rb require "mr_sorty/version" require "mr_sorty/heapsort_min" module MrSorty end
soichikamiya/sample-app2
spec/system/following_spec.rb
require 'rails_helper' RSpec.describe 'フォローページ', type: :system do context "" do # Applicationヘルパーを読み込むと full_titleヘルパー が利用できる include ApplicationHelper let(:login_method) do post login_url, params: { session: { email: @user.email, password: "password" } } expect(session[:user_id]).to eq(@use...
soichikamiya/sample-app2
spec/models/relationship_spec.rb
require 'rails_helper' RSpec.describe Relationship, type: :model do context 'Relationship作成の確認' do before do 2.times { create(:user) } @relationship = Relationship.new(follower_id: User.first.id, followed_id: User.second.id) end it "有効かどうか" do ex...
soichikamiya/sample-app2
spec/controllers/relationships_controller_spec.rb
<filename>spec/controllers/relationships_controller_spec.rb require 'rails_helper' RSpec.describe RelationshipsController, type: :controller do context "Relationshipsアクション確認" do it "作成する際ログインが必要" do expect { post :create }.not_to change(Relationship, :count) assert_redirected_to login_url end ...
soichikamiya/sample-app2
spec/system/static_pages_controller_spec.rb
require 'rails_helper' RSpec.describe '静的ページ確認', type: :system do describe '各画面の表示確認' do let(:url_root) { visit root_path } let(:help_url) { visit help_path } let(:about_url) { visit about_path } let(:contact_url) { visit contact_path } before do @base_title = "Ruby on Rails Tu...
soichikamiya/sample-app2
spec/system/users_index_spec.rb
require 'rails_helper' RSpec.describe 'ユーザー一覧', type: :system do describe '一覧ページ' do before do # @user = create(:testuser) # FactoryBot.create(:testuser)を短縮 buildだとDB登録されない @user = create(:testuser) 31.times { create(:user) } end it 'ページネーションが含まれているかどうか' do visit login_path ...
soichikamiya/sample-app2
spec/system/users_edit_spec.rb
require 'rails_helper' RSpec.describe 'ユーザーの編集', type: :system do describe 'flashメッセージの確認' do context "編集が失敗する事" do before do # @user = create(:testuser) # FactoryBot.create(:testuser)を短縮 buildだとDB登録されない @user = create(:testuser, name: "SoichiKamiya") end it '名前を空欄にすると画面遷移しな...
soichikamiya/sample-app2
spec/factories/users.rb
FactoryBot.define do factory :user do # データを生成する毎に通し番号をふってユニークな値を作る sequence(:name) { |n| "TestName-#{n}"} sequence(:email) { |n| "<EMAIL>"} sequence(:password) { |n| "<PASSWORD>}"} sequence(:password_confirmation) { |n| "<PASSWORD>}"} activated { true } activated_at { Time.zone.now } en...
soichikamiya/sample-app2
spec/system/microposts_interface_test.rb
<reponame>soichikamiya/sample-app2 require 'rails_helper' RSpec.describe 'マイクロポストテスト', type: :system do context '各テスト' do before do # @user = create(:testuser) # FactoryBot.create(:testuser)を短縮 buildだとDB登録されない @user = create(:testuser, name: "SoichiKamiya") end it '' do post login_ur...
soichikamiya/sample-app2
spec/system/users_login_spec.rb
<reponame>soichikamiya/sample-app2<gh_stars>0 require 'rails_helper' RSpec.describe 'ユーザーログイン', type: :system do describe 'flashメッセージの確認' do context "サーバー側で処理" do it '無効なログインではflashが表示されページ遷移すると消える' do post login_url, params: { session: { email: "<EMAIL>", password: "<PASSWORD>" } } expect...
soichikamiya/sample-app2
spec/models/micropost_spec.rb
require 'rails_helper' RSpec.describe Micropost, type: :model do context "micropostの有効性" do before do @user = create(:user, name: "SoichiKamiya") # FactoryBot.build(:user)を短縮 createだとDB登録される # @micropost = Micropost.new(content: "Lorem ipsum", user_id: @user.id) @micropost = @user.microposts....
soichikamiya/sample-app2
spec/models/user_spec.rb
<reponame>soichikamiya/sample-app2 require 'rails_helper' RSpec.describe User, type: :model do context 'ユーザー作成の確認' do before do @user = build(:user) # FactoryBot.build(:user)を短縮 createだとDB登録される # @user = User.new(name: 'Tom', email: '<EMAIL>') end it 'validかどうか' do # trueかfalseの...
soichikamiya/sample-app2
spec/system/users_profile_spec.rb
<gh_stars>0 require 'rails_helper' RSpec.describe 'ユーザープロフィールページ', type: :system do context "プロフィールページ" do # Applicationヘルパーを読み込むと full_titleヘルパー が利用できる include ApplicationHelper before do @user = create(:testuser, name: "SoichiKamiya") 31.times { create(:microposts) } end it 'プロフィール...
soichikamiya/sample-app2
spec/system/users_signup_spec.rb
require 'rails_helper' RSpec.describe 'ユーザー登録', type: :system do context '不正なサインアップ' do it 'nameが空だと登録されない' do expect do post users_url, params: { user: { name: "", email: "<EMAIL>", password: "<PASSWORD>", password_confirmation: "<PASSWORD>" } } end....
soichikamiya/sample-app2
spec/system/password_resets_spec.rb
require 'rails_helper' RSpec.describe 'パスワード再設定', type: :system do describe 'reset_password' do let(:mail) { UserMailer.password_reset(@user) } before do ActionMailer::Base.deliveries.clear @user = create(:testuser, name: "SoichiKamiya") @user.reset_token = User.new_token # URLのhostパ...
soichikamiya/sample-app2
spec/controllers/sessions_controller_spec.rb
require 'rails_helper' RSpec.describe SessionsController, type: :controller do describe "GET #new" do it "returns http success" do get :new expect(response).to have_http_status(:success) end end describe "remember_meの確認" do before do # @user = create(:testuser) # FactoryBot.creat...
soichikamiya/sample-app2
spec/helpers/sessions_helper_spec.rb
<gh_stars>0 require 'rails_helper' RSpec.describe SessionsHelper, type: :helper do describe "SessionsHelper内の確認" do before do # @user = create(:testuser) # FactoryBot.create(:testuser)を短縮 buildだとDB登録されない @user = create(:testuser, name: "SoichiKamiya") end it "ログインしていない場合current_userがnilである...
soichikamiya/sample-app2
spec/feature_spec.rb
<gh_stars>0 # require 'rails_helper' # RSpec.describe '静的ページ確認', type: :feature do # describe '各画面の表示確認' do # let(:url_root) { visit root_url } # let(:home_url) { visit static_pages_home_url } # let(:help_url) { visit static_pages_help_url } # let(:about_url) { visit static_pages_about_url } ...
soichikamiya/sample-app2
spec/controllers/microposts_controller_spec.rb
require 'rails_helper' RSpec.describe MicropostsController, type: :controller do context "ポストチェック" do before do # @user = create(:testuser) # FactoryBot.create(:testuser)を短縮 buildだとDB登録されない @user = create(:testuser, name: "SoichiKamiya") @micropost = create(:orange) end it "ログインしていない...
soichikamiya/sample-app2
spec/controllers/users_controller_spec.rb
require 'rails_helper' RSpec.describe UsersController, type: :controller do describe "GET #new" do it "returns http success" do # get :new get :new expect(response).to have_http_status(:success) end end it "未ログインの場合、ログインページにリダイレクトされること" do get :index expect(response).to have_h...
soichikamiya/sample-app2
config/initializers/skip_image_resizing.rb
<reponame>soichikamiya/sample-app2 # /app/uploaders/picture_uploader.rb # include CarrierWave::MiniMagick # process resize_to_limit: [400, 400] # テスト時は画像のリサイズをさせない設定 if Rails.env.test? CarrierWave.configure do |config| config.enable_processing = false end end
soichikamiya/sample-app2
spec/mailers/user_mailer_spec.rb
<filename>spec/mailers/user_mailer_spec.rb require "rails_helper" RSpec.describe UserMailer, type: :mailer do describe "account_activation" do let(:mail) { UserMailer.account_activation(@user) } before do @user = create(:testuser, name: "SoichiKamiya") @user.activation_token = User.new_token ...
soichikamiya/sample-app2
config/initializers/carrier_wave.rb
<filename>config/initializers/carrier_wave.rb # 本番環境での画像アップロードを調整する # CarrierWaveを通してS3を使うように修正する # 現時点ではAWSを設定していないので下記は削除 # if Rails.env.production? # CarrierWave.configure do |config| # config.fog_credentials = { # # Amazon S3用の設定 # :provider => 'AWS', # :region =...
soichikamiya/sample-app2
spec/factories/microposts.rb
FactoryBot.define do factory :micropost do content { "MyText" } user { nil } end factory :microposts, class: Micropost do # データを生成する毎に通し番号をふってユニークな値を作る sequence(:content) { Faker::Lorem.sentence } sequence(:created_at) { 42.days.ago } sequence(:user) { User.first } end factory :orang...
soichikamiya/sample-app2
app/controllers/relationships_controller.rb
<gh_stars>0 class RelationshipsController < ApplicationController before_action :logged_in_user def create @user = User.find(params[:followed_id]) # follow.htmlで事前に current_user.active_relationships.build により # current_user の followed(following) を作成する準備(配列作成)をしていたので、 # following << user でuserへのfoll...
soichikamiya/sample-app2
spec/factories/relationships.rb
FactoryBot.define do factory :relationship do follower_id { 1 } followed_id { 2 } end factory :relationship1, class: Relationship do follower { User.first } followed { User.third } end factory :relationship2, class: Relationship do follower_id { 2 } followed_id { 1 } end factory...
soichikamiya/sample-app2
app/helpers/microposts_helper.rb
<filename>app/helpers/microposts_helper.rb module MicropostsHelper # def time_ago_in_words(created_at) # Time.zone.now.to_date - created_at.to_date # end end
lpassamano/gradebook
app/models/course.rb
class Course < ActiveRecord::Base belongs_to :instructor, class_name: "User", foreign_key: "instructor_id" has_many :user_courses has_many :users, through: :user_courses has_many :assessments extend Slugifiable::ClassMethods include Slugifiable::InstanceMethods end
lpassamano/gradebook
db/migrate/20170929153222_create_grades.rb
<reponame>lpassamano/gradebook class CreateGrades < ActiveRecord::Migration[5.1] def change create_table :grades do |t| t.string :score t.string :comment t.integer :assessment_id t.integer :student_id end end end
lpassamano/gradebook
app/models/grade.rb
<filename>app/models/grade.rb class Grade < ActiveRecord::Base belongs_to :assessment belongs_to :user end
lpassamano/gradebook
spec/01_models_spec.rb
<reponame>lpassamano/gradebook require 'spec_helper' describe User do before do @user = User.create(name: "test", email: "<EMAIL>", password: "<PASSWORD>") end it "is instantiated with a name, email, and password" do expect(@user.name).to eq("test") expect(@user.email).to eq("<EMAIL>") expect(@u...
lpassamano/gradebook
db/migrate/20171005010608_add_default_value_to_grades.rb
<filename>db/migrate/20171005010608_add_default_value_to_grades.rb class AddDefaultValueToGrades < ActiveRecord::Migration[5.1] def change change_column :grades, :score, :string, :default => "-" end end
lpassamano/gradebook
db/migrate/20170929022445_create_instructor_students.rb
class CreateInstructorStudents < ActiveRecord::Migration[5.1] def change create_table :instructor_students do |t| t.integer :instructor_id t.integer :student_id end end end
lpassamano/gradebook
app/models/assessment.rb
class Assessment < ActiveRecord::Base belongs_to :course has_many :grades has_many :users, through: :grades end
lpassamano/gradebook
spec/04_course_features_spec.rb
require 'spec_helper' describe "Course Features" do describe "Courses Index" do before do @student = Role.create(name: "Student") @instructor = Role.create(name: "Instructor") @user = User.create(name: "Leigh", email: "<EMAIL>", password: "<PASSWORD>") @user.role = @instructor cours...
lpassamano/gradebook
db/seeds.rb
<gh_stars>0 instructor = Role.create(name: "Instructor") student = Role.create(name: "Student") chaz = User.create(name: "Chaz", email: "<EMAIL>", password: "<PASSWORD>") serge = User.create(name: "Serge", email: "<EMAIL>", password: "<PASSWORD>") jessie = User.create(name: "Jessie", email: "<EMAIL>", password: "<PASS...
lpassamano/gradebook
db/migrate/20170929014530_create_course_students.rb
class CreateCourseStudents < ActiveRecord::Migration[5.1] def change create_table :course_students do |t| t.integer :course_id t.integer :student_id end end end
lpassamano/gradebook
db/migrate/20170930214659_edit_assessements.rb
class EditAssessements < ActiveRecord::Migration[5.1] def change remove_column :assessments, :grade remove_column :assessments, :comment remove_column :assessments, :student_id end end
lpassamano/gradebook
spec/03_controllers_spec.rb
<reponame>lpassamano/gradebook require 'spec_helper' describe ApplicationController do describe "Homepage" do it 'loads the homepage' do get '/' expect(last_response.status).to eq(200) expect(last_response.body).to include("Welcome!") end it 'has links to login or signup' do get ...
lpassamano/gradebook
config.ru
require_relative './config/environment' use Rack::MethodOverride use UserController use CoursesController run ApplicationController
lpassamano/gradebook
spec/02_associations_spec.rb
require 'spec_helper' describe 'User Associations' do before do @user = User.create(name: "Charles", email: "<EMAIL>", password: "<PASSWORD>") end it 'has many courses' do math = Course.create(name: "Math") chem = Course.create(name: "Chemistry") @user.courses << [math, chem] @user.save ...
lpassamano/gradebook
db/migrate/20170930214536_drop_instructor_students.rb
<filename>db/migrate/20170930214536_drop_instructor_students.rb class DropInstructorStudents < ActiveRecord::Migration[5.1] def change drop_table :instructor_students end end
lpassamano/gradebook
app/controllers/courses_controller.rb
class CoursesController < ApplicationController get '/courses' do redirect '/' if !logged_in? @user = current_user erb :"courses/index" end get '/courses/new' do if !logged_in? redirect '/' elsif current_user.instructor? erb :"courses/new" else redirect '/courses' e...
lpassamano/gradebook
app/controllers/user_controller.rb
<gh_stars>0 require 'rack-flash' class UserController < ApplicationController use Rack::Flash get '/signup' do if logged_in? redirect "/courses" else @roles = Role.all erb :"user/signup" end end post '/signup' do ## if user = User.find_by(email: params[:email]) if ...
lpassamano/gradebook
app/models/user.rb
class User < ActiveRecord::Base has_secure_password belongs_to :role has_many :user_courses has_many :courses, through: :user_courses has_many :grades has_many :assessments, through: :grades def student? self.role == Role.find_by(name: "Student") end def instructor? self.role == Role.find...
lpassamano/gradebook
db/migrate/20171001201110_delete_students_instructors.rb
class DeleteStudentsInstructors < ActiveRecord::Migration[5.1] def change drop_table :course_students remove_column :courses, :instructor_id remove_column :grades, :student_id drop_table :instructors drop_table :students end end
pjk25/cf-uaa-lib
lib/uaa/util.rb
<filename>lib/uaa/util.rb #-- # Cloud Foundry # Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved. # # This product is licensed to you under the Apache License, Version 2.0 (the "License"). # You may not use this product except in compliance with the License. # # This product includes a number of sub...
pjk25/cf-uaa-lib
spec/scim_spec.rb
#-- # Cloud Foundry # Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved. # # This product is licensed to you under the Apache License, Version 2.0 (the "License"). # You may not use this product except in compliance with the License. # # This product includes a number of subcomponents with # separate...
pjk25/cf-uaa-lib
spec/token_coder_spec.rb
<gh_stars>0 #-- # Cloud Foundry # Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved. # # This product is licensed to you under the Apache License, Version 2.0 (the "License"). # You may not use this product except in compliance with the License. # # This product includes a number of subcomponents wit...
pjk25/cf-uaa-lib
spec/info_spec.rb
#-- # Cloud Foundry # Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved. # # This product is licensed to you under the Apache License, Version 2.0 (the "License"). # You may not use this product except in compliance with the License. # # This product includes a number of subcomponents with # separate...
pjk25/cf-uaa-lib
cf-uaa-lib.gemspec
# -*- encoding: utf-8 -*- #-- # Cloud Foundry # Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved. # # This product is licensed to you under the Apache License, Version 2.0 (the "License"). # You may not use this product except in compliance with the License. # # This product includes a number of sub...