-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update README.md (#45) * Move github release info to helper * Added new placeholder translation * Removed view typo * Update Octokit credentials * Improve/octokit caching (#51) * Improve Octokit error handling (#50) * Update README.md (#45) * Move github release info to helper * Added new placeholder translation * Removed view typo * Update Octokit credentials * Octokit caching
- Loading branch information
Showing
4 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'support/devise' | ||
|
||
RSpec.describe Octokit, type: :model do | ||
describe 'configuration' do | ||
it 'should have a login' do | ||
expect(Octokit.login).to eq(ENV['GITHUB_USERNAME']) | ||
end | ||
|
||
it 'should have an access token' do | ||
expect(Octokit.access_token).to eq(ENV['GITHUB_PERSONAL_ACCESS_TOKEN']) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'support/devise' | ||
|
||
RSpec.describe ApplicationHelper, type: :helper do | ||
describe '#octokit_request' do | ||
it 'should be a hash' do | ||
expect(helper.octokit_request).to be_a(Hash) | ||
end | ||
|
||
it 'should have a latest_release key' do | ||
expect(helper.octokit_request).to have_key(:latest_release) | ||
end | ||
|
||
it 'should have a latest_deploy key' do | ||
expect(helper.octokit_request).to have_key(:latest_deploy) | ||
end | ||
|
||
it 'should have a latest_release value' do | ||
expect(helper.octokit_request[:latest_release]).to be_present | ||
end | ||
|
||
it 'should store the request in cache' do | ||
expect(Rails.cache).to receive(:fetch).with('octokit_request', expires_in: 12.hours) | ||
helper.octokit_request | ||
end | ||
|
||
it 'should raise an error if the latest release request fails' do | ||
allow(Octokit).to receive(:latest_release).and_raise(Octokit::Unauthorized) | ||
end | ||
|
||
it 'should raise an error if the deployments request fails' do | ||
allow(Octokit).to receive(:deployments).and_raise(Octokit::Unauthorized) | ||
end | ||
end | ||
end |