зеркало из https://github.com/github/explore.git
Test the order of collection items
This commit is contained in:
Родитель
45c0efa1ae
Коммит
8fe95bef38
2
Gemfile
2
Gemfile
|
@ -3,9 +3,11 @@ source "https://rubygems.org"
|
|||
gem "github-pages", group: :jekyll_plugins
|
||||
|
||||
group :test do
|
||||
gem "faraday"
|
||||
gem "fastimage"
|
||||
gem "minitest"
|
||||
gem "octokit"
|
||||
gem "pry", require: false
|
||||
gem "rake"
|
||||
gem "rubocop"
|
||||
gem "rubocop-performance"
|
||||
|
|
|
@ -175,6 +175,19 @@ describe "collections" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "has the same order and new items are at the end" do
|
||||
collection_items = items_for_collection(collection)
|
||||
existing_items = existing_items_for_collection(collection)
|
||||
|
||||
collection_items_minus_new_additions = collection_items[0, existing_items.length]
|
||||
|
||||
assert_equal(
|
||||
collection_items_minus_new_additions,
|
||||
existing_items,
|
||||
"expected collection changes to have been appended to the existing item list",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def repository_exists?(item)
|
||||
|
@ -184,4 +197,8 @@ describe "collections" do
|
|||
def user_exists?(item)
|
||||
client.user(item)
|
||||
end
|
||||
|
||||
def existing_items_for_collection(collection)
|
||||
existing_collection(collection)["items"]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,7 @@ require "octokit"
|
|||
IMAGE_WIDTH = 288
|
||||
IMAGE_HEIGHT = 288
|
||||
MAX_IMAGE_FILESIZE_IN_BYTES = 75_000
|
||||
EXPLORE_FEED_URL = "https://explore-feed.github.com/feed.json"
|
||||
|
||||
# See https://github.com/franklsf95/ruby-emoji-regex
|
||||
# rubocop:disable Layout/LineLength
|
||||
|
@ -58,6 +59,25 @@ def client
|
|||
@client ||= NewOctokit.new(access_token: ENV["GITHUB_TOKEN"])
|
||||
end
|
||||
|
||||
def existing_explore_feed
|
||||
@_existing_explore_feed ||= begin
|
||||
conn = Faraday.new(EXPLORE_FEED_URL) do |f|
|
||||
f.request :json
|
||||
f.response :json
|
||||
end
|
||||
|
||||
conn.get
|
||||
end
|
||||
end
|
||||
|
||||
def existing_collection(name)
|
||||
@_existing_collections ||= {}
|
||||
|
||||
@_existing_collections[name] ||= existing_explore_feed.body["collections"].find do |collection|
|
||||
collection["name"] == name
|
||||
end
|
||||
end
|
||||
|
||||
def valid_uri_scheme?(scheme)
|
||||
return false unless scheme
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче