docbrown/spec/requests/api/v0/github_repos_spec.rb
Abraham Williams 9cb40e546b Enables Rails cops (#2186)
* Enable Rails cops

* Fix Rails/DynamicFindBy

* Fix Rails/HttpStatus

* Fix Rails/Blank

* Fix Rails/RequestReferer

* Fix Rails/ActiveRecordAliases

* Fix Rails/FindBy

* Fix Rails/Presence

* Fix Rails/Delegate

* Fix Rails/Validation

* Fix Rails/PluralizationGrammar

* Fix Rails/Present

* Fix Rails/Output

* Fix Rails/Blank

* Fix Rails/FilePath

* Fix Rails/InverseOf

* Fix Rails/LexicallyScopedActionFilter

* Add Rails/OutputSafety to TODO

* Add Rails/HasManyOrHasOneDependent to TODO

* Add Rails/SkipsModelValidations to TODO
2019-03-25 09:25:55 -04:00

32 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe "Api::V0::GithubRepos", type: :request do
let(:user) { create(:user) }
let(:repo) { build(:github_repo, user: user) }
let(:my_ocktokit_client) { instance_double(Octokit::Client) }
let(:stubbed_github_repos) do
[OpenStruct.new(repo.attributes.merge(id: repo.github_id_code, html_url: Faker::Internet.url))]
end
before do
allow(Octokit::Client).to receive(:new).and_return(my_ocktokit_client)
allow(my_ocktokit_client).to receive(:repositories) { stubbed_github_repos }
sign_in user
end
describe "GET /api/v0/github_repos" do
it "returns 200 on success" do
get "/api/github_repos"
expect(response).to have_http_status(:ok)
end
end
describe "POST /api/v0/github_repos/update_or_create" do
it "returns 200 and json response on success" do
param = stubbed_github_repos.first.to_h.to_json
post "/api/github_repos/update_or_create", params: { github_repo: param }
expect(response).to have_http_status(:ok)
expect(response.content_type).to eq("application/json")
end
end
end