Skip to content

Commit

Permalink
Update remotes and redis fixtures (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
epistrephein authored Dec 6, 2023
1 parent a071365 commit ba317b8
Show file tree
Hide file tree
Showing 7 changed files with 471 additions and 114 deletions.
2 changes: 1 addition & 1 deletion lib/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def valid?(remote)
# Decode and parse a data file
def parse(content)
decoded = Base64.decode64(content)
YAML.safe_load(decoded, [Date])
YAML.safe_load(decoded, permitted_classes: [Date])
end

# Fetch a remote data file
Expand Down
26 changes: 13 additions & 13 deletions spec/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,43 @@

expect(json).to eq({
'status' => 'normal',
'branches' => ['2.7', '2.6'],
'latest' => ['2.7.2', '2.6.6']
'branches' => ['3.2', '3.1'],
'latest' => ['3.2.2', '3.1.4']
})
end
end

describe 'branch endpoint' do
let(:endpoint) { '/api/2.7' }
let(:endpoint) { '/api/3.2' }

it 'returns the branch info' do
get endpoint

expect(json).to eq({
'branch' => '2.7',
'branch' => '3.2',
'status' => 'normal',
'release_date' => '2019-12-25',
'release_date' => '2022-12-25',
'eol_date' => nil,
'latest' => '2.7.2',
'latest' => '3.2.2',
'releases' => [
'2.7.2', '2.7.1', '2.7.0', '2.7.0-rc2', '2.7.0-rc1',
'2.7.0-preview3', '2.7.0-preview2', '2.7.0-preview1'
'3.2.2', '3.2.1', '3.2.0', '3.2.0-rc1',
'3.2.0-preview3', '3.2.0-preview2', '3.2.0-preview1'
]
})
end
end

describe 'release endpoint' do
let(:endpoint) { '/api/2.7.0' }
let(:endpoint) { '/api/3.2.0' }

it 'returns the release info' do
get endpoint

expect(json).to eq({
'release' => '2.7.0',
'branch' => '2.7',
'release' => '3.2.0',
'branch' => '3.2',
'status' => 'normal',
'release_date' => '2019-12-25',
'release_date' => '2022-12-25',
'latest' => false,
'prerelease' => false
})
Expand All @@ -113,7 +113,7 @@
get endpoint

expect(json).to eq({
'last_update' => '2020-10-24 07:30:00 +0000'
'last_update' => '2023-12-03 11:23:35 +0000'
})
end
end
Expand Down
38 changes: 19 additions & 19 deletions spec/branch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Branch, :github do
subject(:branch) { described_class['2.5'] }
subject(:branch) { described_class['3.0'] }

before(:each) do
Branch.build!
Expand All @@ -11,7 +11,7 @@
describe '#latest' do
it 'returns the latest version of the branch' do
expect(branch.latest).to be_a(Release)
expect(branch.latest.to_s).to eq('2.5.8')
expect(branch.latest.to_s).to eq('3.0.6')
end
end

Expand All @@ -23,47 +23,47 @@

describe '#to_s' do
it 'returns the branch name as string' do
expect(branch.to_s).to eq('2.5')
expect(branch.to_s).to eq('3.0')
end
end

describe '#to_json' do
it 'returns the branch attributes as JSON' do
expect(branch.to_json).to eq(
'{"branch":"2.5","status":"security","release_date":"2017-12-25",' \
'"eol_date":"2021-03-31","latest":"2.5.8","releases":["2.5.8","2.5.7",' \
'"2.5.6","2.5.5","2.5.4","2.5.3","2.5.2","2.5.1","2.5.0","2.5.0-rc1","2.5.0-preview1"]}'
'{"branch":"3.0","status":"security","release_date":"2020-12-25",' \
'"eol_date":null,"latest":"3.0.6","releases":["3.0.6","3.0.5",' \
'"3.0.4","3.0.3","3.0.2","3.0.1","3.0.0","3.0.0-rc1","3.0.0-preview2","3.0.0-preview1"]}'
)
end
end

describe '#attributes' do
it 'returns the branch attributes as hash' do
expect(branch.attributes).to eq({
branch: '2.5',
branch: '3.0',
status: 'security',
release_date: Date.new(2017, 12, 25),
eol_date: Date.new(2021, 3, 31),
latest: '2.5.8',
release_date: Date.new(2020, 12, 25),
eol_date: nil,
latest: '3.0.6',
releases: [
'2.5.8', '2.5.7', '2.5.6', '2.5.5', '2.5.4', '2.5.3',
'2.5.2', '2.5.1', '2.5.0', '2.5.0-rc1', '2.5.0-preview1'
'3.0.6', '3.0.5', '3.0.4', '3.0.3', '3.0.2', '3.0.1',
'3.0.0', '3.0.0-rc1', '3.0.0-preview2', '3.0.0-preview1'
]
})
end
end

describe '.[]' do
it 'returns the branch with the matching name' do
expect(described_class['2.5']).to be_a(described_class)
expect(described_class['2.5'].to_s).to eq('2.5')
expect(described_class['3.0']).to be_a(described_class)
expect(described_class['3.0'].to_s).to eq('3.0')
end
end

describe '.status' do
it 'returns the branches with the matching status' do
expect(described_class.status('security')).to all(be_a(described_class))
expect(described_class.status('security').first.to_s).to eq('2.5')
expect(described_class.status('security').first.to_s).to eq('3.0')
end
end

Expand All @@ -85,7 +85,7 @@
it 'returns the latest 4 branches as string' do
expect(described_class.examples_branches).to all(be_a String)
expect(described_class.examples_branches).to eq([
'3.0', '2.7', '2.6', '2.5'
'3.3', '3.2', '3.1', '3.0'
])
end
end
Expand All @@ -103,21 +103,21 @@
it 'returns 6 releases of the 4 most recent branches as string' do
expect(described_class.examples_releases).to all(be_a String)
expect(described_class.examples_releases).to eq([
'3.0.0-preview1', '2.7.2', '2.7.1', '2.6.6', '2.5.8', '2.4.10'
'3.3.0-preview3', '3.3.0-preview2', '3.2.2', '3.2.1', '3.1.4', '3.0.6'
])
end
end

describe '.sha' do
it 'returns the commit sha of the data' do
expect(described_class.sha).to eq('8c7d486e4ac97fc2aa31db3f16881e438b4cd863')
expect(described_class.sha).to eq('54cfc1f1332e0e7888c9266fcb0c351b3534a661')
end
end

describe '.all' do
it 'returns all branches' do
expect(described_class.all).to all(be_a(described_class))
expect(described_class.all.first.to_s).to eq('3.0')
expect(described_class.all.first.to_s).to eq('3.3')
expect(described_class.all.last.to_s).to eq('1.9')
end

Expand Down
10 changes: 5 additions & 5 deletions spec/fixtures/branches.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "branches.yml",
"path": "_data/branches.yml",
"sha": "8c7d486e4ac97fc2aa31db3f16881e438b4cd863",
"size": 1049,
"sha": "54cfc1f1332e0e7888c9266fcb0c351b3534a661",
"size": 1801,
"url": "https://api.github.com/repos/ruby/www.ruby-lang.org/contents/_data/branches.yml?ref=master",
"html_url": "https://github.com/ruby/www.ruby-lang.org/blob/master/_data/branches.yml",
"git_url": "https://api.github.com/repos/ruby/www.ruby-lang.org/git/blobs/8c7d486e4ac97fc2aa31db3f16881e438b4cd863",
"git_url": "https://api.github.com/repos/ruby/www.ruby-lang.org/git/blobs/54cfc1f1332e0e7888c9266fcb0c351b3534a661",
"download_url": "https://raw.githubusercontent.com/ruby/www.ruby-lang.org/master/_data/branches.yml",
"type": "file",
"content": "IyBUaGlzIGZpbGUgcHJvdmlkZXMgZGV0YWlscyBvbiB0aGUgdmFyaW91cyBS\ndWJ5IGJyYW5jaGVzCiMgYW5kIHRoZWlyIG1haW50ZW5hbmNlIHN0YXR1cy4K\nIwojIEVhY2ggZW50cnkgaGFzIHRoZSBmb2xsb3dpbmcgZm9ybToKIwojIC0g\nbmFtZTogICAgIGJyYW5jaCBuYW1lIChNQUpPUi5NSU5PUiBzaW5jZSAyLjEp\nCiMgICBzdGF0dXM6ICAgbm9ybWFsIG1haW50ZW5hbmNlIHwgc2VjdXJpdHkg\nbWFpbnRlbmFuY2UgfCBlb2wgfCBwcmV2aWV3CiMgICBkYXRlOiAgICAgZGF0\nZSBvZiBmaXJzdCBzdGFibGUgcmVsZWFzZSAoWVlZWS1NTS1ERCkKIyAgIGVv\nbF9kYXRlOiBkYXRlIG9mIEVPTCAoWVlZWS1NTS1ERCkKCi0gbmFtZTogMy4w\nCiAgc3RhdHVzOiBwcmV2aWV3CiAgZGF0ZToKICBlb2xfZGF0ZToKCi0gbmFt\nZTogMi43CiAgc3RhdHVzOiBub3JtYWwgbWFpbnRlbmFuY2UKICBkYXRlOiAy\nMDE5LTEyLTI1CiAgZW9sX2RhdGU6CgotIG5hbWU6IDIuNgogIHN0YXR1czog\nbm9ybWFsIG1haW50ZW5hbmNlCiAgZGF0ZTogMjAxOC0xMi0yNQogIGVvbF9k\nYXRlOgoKLSBuYW1lOiAyLjUKICBzdGF0dXM6IHNlY3VyaXR5I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by/www.ruby-lang.org/contents/_data/branches.yml?ref=master",
"git": "https://api.github.com/repos/ruby/www.ruby-lang.org/git/blobs/8c7d486e4ac97fc2aa31db3f16881e438b4cd863",
"git": "https://api.github.com/repos/ruby/www.ruby-lang.org/git/blobs/54cfc1f1332e0e7888c9266fcb0c351b3534a661",
"html": "https://github.com/ruby/www.ruby-lang.org/blob/master/_data/branches.yml"
}
}
Loading

0 comments on commit ba317b8

Please sign in to comment.