This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
include SessionsHelper | |
RSpec.describe CommentsController, type: :controller do | |
let(:my_user) { User.create!(name: 'Bloccit User', email: '[email protected]', 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) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |