Skip to content

Instantly share code, notes, and snippets.

View regularlady's full-sized avatar

Brittany Martin regularlady

View GitHub Profile
@regularlady
regularlady / gist:3f25cd013f79a3c3252b79d281e2b0c4
Created May 30, 2016 01:23
Octokit Public and Private Repositories
github_auth = Octokit::Client.new(access_token: current_user.token, per_page: 100, auto_paginate: true)
# public repositories
repositories = github_auth.repos || []
# loop through each org and collect repositories
github_auth.orgs.each do |org|
private_repositories = github_auth.org_repos(org[:login], {:type => 'private'})
private_repositories.each do |repository|
repositories << repository
end
end
def create
@sponsored_post = SponsoredPost.new
@sponsored_post.title = params[:sponsored_post][:title]
@sponsored_post.body = params[:sponsored_post][:body]
@sponsored_post.price = params[:sponsored_post][:price]
topic = Topic.find(params[:topic_id])
@sponsored_post.topic = topic
if @sponsored_post.save
flash[:notice] = "Sponsored post was saved."
require 'rails_helper'
include SessionsHelper
RSpec.describe CommentsController, type: :controller do
let(:my_user) { User.create!(name: 'Bloccit User', email: 'user@bloccit.com', password: 'helloworld') }
let(:other_user) { User.create!(name: RandomData.random_name, email: RandomData.random_email, password: 'helloworld', role: 'member') }
let(:my_topic) { Topic.create!(name: RandomData.random_sentence, description: RandomData.random_paragraph) }
let(:my_post) { my_topic.posts.create!(title: RandomData.random_sentence, body: RandomData.random_paragraph, user: my_user) }
let(:my_comment) { Comment.create!(body: 'Comment Body', post: my_post, topic: my_topic, user: my_user) }
@regularlady
regularlady / gist:7214b7b530c75b046dbe
Created March 3, 2016 18:20
Authorization Topic Controller Spec for Bloccit
require 'rails_helper'
include SessionsHelper
RSpec.describe TopicsController, type: :controller do
let (:my_topic) { Topic.create!(name: RandomData.random_sentence, description: RandomData.random_paragraph) }
context "guest" do
describe "GET index" do
it "returns http success" do
get :index
@regularlady
regularlady / post_controller_spec.rb
Created February 9, 2016 20:22
post_controller_spec.rb
require 'rails_helper'
include RandomData
RSpec.describe PostsController, type: :controller do
let (:my_post) { Post.create(title: RandomData.random_sentence, body: RandomData.random_paragraph) }
describe "GET #index" do
it "returns http success" do
get :index
expect(response).to have_http_status(:success)
class PostsController < ApplicationController
def show
@post = Post.find(params[:id])
end
def new
# Hannah remove please, add in next line: @topic = Topic.find(params[:id])
@topic = Topic.find(params[:topic_id])
@post = Post.new
end
@regularlady
regularlady / menu_assigment
Created January 25, 2016 23:54
20 Address Bloc: Menu Assignment
require_relative "../models/address_book"
class MenuController
attr_accessor :address_book
def initialize
@address_book = AddressBook.new
end
def main_menu