source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/lib/supermarket/fips.rb | Ruby | apache-2.0 | 214 | main | 1,668 | require "digest"
require "openssl"
module Supermarket
class Fips
# FIPS 140-2 Annex A references NIST Digital Signature Standard (DSS),
# FIPS Publication 186-4 to identify several algorithms as the
# Secure Hash Standard (SHS). Algorithms listed here are in the SHS
# and are used in various places i... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/lib/supermarket/location_storage.rb | Ruby | apache-2.0 | 214 | main | 721 | module Supermarket
module LocationStorage
#
# Stores the current request URL or the root URL
# in a session variable.
#
# @param [String] location the location to store
#
# @example
# store_location!
# store_location!(profile_path)
#
def store_location!(location = reque... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/lib/supermarket/migration/mark_bad_readme_imports_for_reimport.rb | Ruby | apache-2.0 | 214 | main | 454 | module Supermarket
module Migration
module MarkBadReadmeImportsForReimport
def self.call
CookbookVersion.where("readme like ?", "%ctime=%").each do |cv|
cv.record_timestamps = false
cv.transaction do
cv.dependencies_imported = false
cv.cookbook_dependenci... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/lib/supermarket/migration/remove_duplicate_cookbook_dependencies.rb | Ruby | apache-2.0 | 214 | main | 823 | module Supermarket
module Migration
module RemoveDuplicateCookbookDependencies
def self.call
query = %{
SELECT cookbook_version_id, name, version_constraint, count(*) as cnt
FROM cookbook_dependencies
GROUP BY cookbook_version_id, name, version_constraint
}
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/lib/extractor/base.rb | Ruby | apache-2.0 | 214 | main | 2,567 | module Extractor
class Base
class << self
#
# Finds an extractor object for the given auth hash and returns a new
# extractor instance for the auth hash.
#
# @param auth [Hash]
# the hash returned from omniauth
#
# @return [~Extractor::Base]
#
def load... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/lib/schema_definer/symbolize_struct.rb | Ruby | apache-2.0 | 214 | main | 214 | module SchemaDefiner
class SymbolizeStruct < Dry::Struct
# This will convert all attributes to symbol type
# when assigning to a class that inherits from this class
transform_keys(&:to_sym)
end
end |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/lib/authorizer/base.rb | Ruby | apache-2.0 | 214 | main | 873 | module Authorizer
class Base
# @return [User]
attr_reader :user
# @return [Object]
attr_reader :record
#
# Create a new authorizer for the given user and record.
#
# @param [User] user
# @param [Object] record
#
def initialize(user, record)
@user = user || User.new
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/habitat-web/config/unicorn.rb | Ruby | apache-2.0 | 214 | main | 783 | ##
# Unicorn config at supermarket
# Managed by Chef - Local Changes will be Nuked from Orbit (just to be sure)
##
# What ports/sockets to listen on, and what options for them.
listen "127.0.0.1:{{ cfg.app.port }}"
# What the timeout for killing busy workers is, in seconds
timeout {{ cfg.app.worker_timeout }}
# Whet... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/spec_helper.rb | Ruby | apache-2.0 | 214 | main | 6,056 | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../config/environment", __dir__)
require "rspec/rails"
require "paperclip/matchers"
require "sidekiq/testing"
require "capybara/rails"
require "capybara/rspec"
require "capybara/cuprite"
requ... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/vcr_helper.rb | Ruby | apache-2.0 | 214 | main | 1,902 | require "cgi"
require "vcr"
VCR.configure do |c|
include CustomUrlHelper
c.cassette_library_dir = "spec/vcr_cassettes"
c.hook_into :webmock
c.allow_http_connections_when_no_cassette = true
c.filter_sensitive_data("<TOKEN>") do
ENV["GITHUB_ACCESS_TOKEN"]
end
c.filter_sensitive_data("<PUBSUBHUBBUB_SEC... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/group_resource_spec.rb | Ruby | apache-2.0 | 214 | main | 1,293 | require "spec_helper"
describe GroupResource do
context "associations" do
it { should belong_to(:group) }
it { should belong_to(:resourceable) }
context "validations" do
let(:cookbook) { create(:cookbook) }
let(:group) { create(:group) }
it "requires a group id" do
group_resou... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_version_spec.rb | Ruby | apache-2.0 | 214 | main | 7,957 | require "spec_helper"
require "webmock/rspec"
describe CookbookVersion do
context "associations" do
it { should belong_to(:cookbook) }
it { should have_many(:metric_results) }
end
context "validations" do
it { should validate_presence_of(:license) }
it { should validate_presence_of(:description)... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/tool_spec.rb | Ruby | apache-2.0 | 214 | main | 3,666 | require "spec_helper"
describe Tool do
context "associations" do
it { should belong_to(:owner) }
it { should have_one(:chef_account) }
it { should have_many(:collaborators) }
it { should have_many(:collaborator_users) }
it { should have_many(:group_resources) }
end
context "validations" do
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/universe_spec.rb | Ruby | apache-2.0 | 214 | main | 1,862 | require "spec_helper"
describe Universe do
let(:cookbook) { "redis" }
let(:version) { "1.3.1" }
context "when a host is provided" do
it "allows you to customize things" do
opts = {
host: "narf.example.com",
port: 6060,
protocol: "https",
}
expect(Universe.protocol_... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/group_member_spec.rb | Ruby | apache-2.0 | 214 | main | 772 | require "spec_helper"
describe GroupMember do
context "associations" do
it { should belong_to(:group) }
it { should belong_to(:user) }
end
context "validations" do
let!(:user) { create(:user) }
let!(:group) { create(:group) }
it "requires a group id" do
group_member = GroupMember.new(... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/hit_spec.rb | Ruby | apache-2.0 | 214 | main | 221 | require "spec_helper"
describe Hit do
context "validations" do
it { should validate_presence_of(:label) }
it { should validate_presence_of(:total) }
it { should validate_numericality_of(:total) }
end
end |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/user_spec.rb | Ruby | apache-2.0 | 214 | main | 10,110 | require "spec_helper"
describe User do
context "associations" do
it { should have_many(:accounts).dependent(:destroy) }
it { should have_many(:owned_cookbooks).dependent(:restrict_with_exception) }
it { should have_many(:cookbook_versions).dependent(:nullify) }
it { should have_many(:collaborators).d... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_spec.rb | Ruby | apache-2.0 | 214 | main | 29,212 | require "spec_helper"
describe Cookbook do
context "associations" do
it { should have_many(:cookbook_versions) }
it { should have_many(:cookbook_followers) }
it { should have_many(:followers) }
it { should belong_to(:category).optional }
it { should belong_to(:owner) }
it { should have_many(:... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/quality_metric_spec.rb | Ruby | apache-2.0 | 214 | main | 2,000 | require "spec_helper"
describe QualityMetric do
it { should have_many(:metric_results) }
describe "validations" do
it "enforces unique names" do
create(:cookstyle_metric)
dup_qm = build(:cookstyle_metric)
expect(dup_qm).to_not be_valid
end
end
describe "#cookstyle metric" do
let... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_dependency_spec.rb | Ruby | apache-2.0 | 214 | main | 1,345 | require "spec_helper"
describe CookbookDependency do
context "validations" do
it 'allows ">= 0.0.0" as a version constraint' do
platform = CookbookDependency.new(version_constraint: ">= 0.0.0")
platform.valid?
expect(platform.errors[:version_constraint]).to be_empty
end
it 'does not ... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/category_spec.rb | Ruby | apache-2.0 | 214 | main | 308 | require "spec_helper"
describe Category do
context "associations" do
it { should have_many(:cookbooks) }
end
context "slugs" do
it "should automatically add a slug before saving" do
c = create(:category, name: "Web Servers")
expect(c.slug).to eql("web-servers")
end
end
end |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/ownership_transfer_request_spec.rb | Ruby | apache-2.0 | 214 | main | 2,353 | require "spec_helper"
describe OwnershipTransferRequest do
context "associations" do
it { should belong_to(:cookbook) }
it { should belong_to(:recipient) }
it { should belong_to(:sender) }
end
context "validations" do
it { should validate_presence_of(:cookbook) }
it { should validate_presenc... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/supported_platform_spec.rb | Ruby | apache-2.0 | 214 | main | 1,883 | require "spec_helper"
describe SupportedPlatform do
context "validations" do
subject { build(:supported_platform) }
it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name).scoped_to(:version_constraint) }
it 'allows ">= 0.0.0" as a version constraint' do
platform =... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/group_spec.rb | Ruby | apache-2.0 | 214 | main | 862 | require "spec_helper"
describe Group do
context "associations" do
it { should have_many(:group_members).dependent(:destroy) }
it { should have_many(:members) }
it { should have_many(:group_resources).dependent(:destroy) }
end
it "requires a name" do
group = Group.new(name: "")
expect(group).... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/email_preference_spec.rb | Ruby | apache-2.0 | 214 | main | 809 | require "spec_helper"
describe EmailPreference do
context "associations" do
it { should belong_to(:system_email) }
it { should belong_to(:user) }
end
context "validations" do
it { should validate_presence_of(:user) }
it { should validate_presence_of(:system_email) }
end
it "should have a to... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/account_spec.rb | Ruby | apache-2.0 | 214 | main | 1,731 | require "spec_helper"
describe Account do
context "associations" do
it { should belong_to(:user) }
end
context "validations" do
it { should validate_presence_of(:user) }
it { should validate_presence_of(:uid) }
it { should validate_presence_of(:provider) }
it { should validate_presence_of(:o... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_upload_spec.rb | Ruby | apache-2.0 | 214 | main | 12,317 | require "and_feathers"
require "and_feathers/gzipped_tarball"
require "spec_helper"
require "tempfile"
describe CookbookUpload do
describe "#finish(user)" do
before do
create(:category, name: "Other")
end
let(:cookbook) do
JSON.dump("category" => "Other")
end
let(:user) do
cre... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/system_email_spec.rb | Ruby | apache-2.0 | 214 | main | 344 | require "spec_helper"
describe SystemEmail do
subject { build(:system_email) }
context "associations" do
it { should have_many(:email_preferences) }
it { should have_many(:subscribed_users) }
end
context "validations" do
it { should validate_presence_of(:name) }
it { should validate_uniquenes... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_follower_spec.rb | Ruby | apache-2.0 | 214 | main | 488 | require "spec_helper"
describe CookbookFollower do
context "associations" do
it { should belong_to(:cookbook) }
it { should belong_to(:user) }
end
context "validations" do
it "validates the uniquness of cookbook_id scoped to user_id" do
create(:cookbook_follower)
expect(subject).to vali... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/universe_cache_spec.rb | Ruby | apache-2.0 | 214 | main | 966 | require "spec_helper"
describe UniverseCache do
it "stores cache values in a protocol-based key" do
http_cache = UniverseCache.new("http://")
http_cache.fetch { "stuff" }
https_cache = UniverseCache.new("https://")
https_cache.fetch { "things" }
expect(Rails.cache.read("http-universe")).to eql(... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/collaborator_spec.rb | Ruby | apache-2.0 | 214 | main | 1,947 | require "spec_helper"
describe Collaborator do
context "associations" do
it { should belong_to(:resourceable) }
it { should belong_to(:user) }
it { should belong_to(:group).optional }
end
context "validations" do
let(:cookbook) { create(:cookbook) }
let(:tool) { create(:tool) }
let(:user... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_upload/metadata_spec.rb | Ruby | apache-2.0 | 214 | main | 1,385 | require "spec_helper"
describe CookbookUpload::Metadata do
describe "setting the platforms attribute" do
it "fails loudly if Hash coercion fails" do
expect do
CookbookUpload::Metadata.new(platforms: "")
end.to raise_error(Dry::Struct::Error)
end
it "can't coerce Arrays into Hashes" d... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_upload/parameters_spec.rb | Ruby | apache-2.0 | 214 | main | 7,128 | require "spec_helper"
describe CookbookUpload::Parameters do
include TarballHelpers
def params(hash)
CookbookUpload::Parameters.new(hash)
end
describe "#category_name" do
it "is extracted from the cookbook JSON" do
params = params(cookbook: '{"category":"Cool"}', tarball: double)
expect(... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/models/cookbook_upload/archive_spec.rb | Ruby | apache-2.0 | 214 | main | 511 | require "spec_helper"
describe CookbookUpload::Archive do
describe "#gzipped?" do
it "returns true if a tar file is GZipped" do
tarball = described_class.new(File.new("spec/support/cookbook_fixtures/redis-test-v1.tgz"))
expect(tarball.send(:gzipped?)).to be true
end
it "fails if a tar file i... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/tool_creation_spec.rb | Ruby | apache-2.0 | 214 | main | 669 | require "spec_helper"
describe "creating a tool" do
it "is possible for users to create a tool" do
sign_in(create(:user))
visit "/"
follow_relation "view_profile"
follow_relation "view_tools"
follow_relation "add_tool"
within ".tool_data" do
fill_in "tool[name]", with: "butter"
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/branding_spec.rb | Ruby | apache-2.0 | 214 | main | 4,002 | require "spec_helper"
require "tempfile"
describe "the set of SASS assets", type: :feature do
# A custom branding file.
class BrandingFile
# append datetime after name for uniqueness.
def initialize(name, content = nil)
t = Time.zone.now
@filename = "#{name}_#{t.to_i}_#{t.usec}.scss"
@ful... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_feed_spec.rb | Ruby | apache-2.0 | 214 | main | 372 | require "spec_helper"
describe "cookbook feed" do
it "lists cookbooks by a metadata search term" do
create(:cookbook, name: "AmazingCookbook")
visit "/"
within ".appnav" do
click_link "Cookbooks"
end
within ".search_form" do
fill_in "q", with: "Amazing"
submit_form
end
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_following_spec.rb | Ruby | apache-2.0 | 214 | main | 1,148 | require "spec_helper"
describe "cookbook following" do
before do
sign_in(create(:user))
create_list(:cookbook, 2)
end
context "from the cookbook partial" do
before do
visit "/cookbooks"
follow_first_relation "follow"
end
it "allows a user to follow a cookbook", use_cuprite: true... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_view_spec.rb | Ruby | apache-2.0 | 214 | main | 1,743 | require "spec_helper"
describe "viewing a cookbook" do
let!(:owner) { create(:user) }
let!(:cookbook) { create(:cookbook, owner: owner) }
it "displays cookbook details if the cookbook exists" do
visit "/"
follow_relation "cookbooks"
within ".recently-updated" do
follow_relation "cookbook"
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/admin_view_email_spec.rb | Ruby | apache-2.0 | 214 | main | 576 | require "spec_helper"
feature "admin email permissions" do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
scenario "admin user goes to another users page" do
sign_in(admin)
visit user_path(user)
expect(page).to have_content(user.email)
end
scenario "regular user goes to another us... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/fieri_spec.rb | Ruby | apache-2.0 | 214 | main | 595 | require "spec_helper"
# a :request spec instead of :feature, doesn't need full-on Capybara
describe "fieri routes", type: :request do
describe "GET /status" do
it "should return a 200" do
expect(Feature).to receive(:active?).with(:fieri).and_return(true)
get fieri.status_path
expect(response).t... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/edit_profile_spec.rb | Ruby | apache-2.0 | 214 | main | 419 | require "spec_helper"
describe "editing the current user profile" do
it "updates the users profile" do
sign_in(create(:user))
manage_profile
within ".edit_user" do
fill_in "user[slack_username]", with: "eddardstark"
fill_in "user[company]", with: "Winterfell"
fill_in "user[twitter_user... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/admin_transfers_cookbook_ownership_spec.rb | Ruby | apache-2.0 | 214 | main | 554 | require "spec_helper"
feature "admin transfers cookbook ownership" do
let(:cookbook) { create(:cookbook) }
let(:new_owner) { create(:user) }
before do
sign_in(create(:admin))
visit cookbook_path(cookbook)
follow_relation "transfer_ownership"
within "#transfer" do
find(".collaborators", vi... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/admin_role_management_spec.rb | Ruby | apache-2.0 | 214 | main | 615 | require "spec_helper"
feature "admin role management" do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
scenario "admin user grants another user admin role" do
sign_in(admin)
visit user_path(user)
follow_relation "make_admin"
expect_to_see_success_message
expect(page).to have_c... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/authentication_spec.rb | Ruby | apache-2.0 | 214 | main | 305 | require "spec_helper"
describe "signing in with oauth" do
it "signs a user in" do
sign_in(create(:user))
expect_to_see_success_message
end
end
describe "signing out with oc-id" do
it "signs a user out" do
sign_in(create(:user))
sign_out
expect_to_see_success_message
end
end |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/search_spec.rb | Ruby | apache-2.0 | 214 | main | 869 | require "spec_helper"
feature "tools and cookbooks can be searched for", use_cuprite: true do
let!(:cookbook) { create(:cookbook, name: "apache") }
let!(:tool) { create(:tool, name: "Berkshelf") }
before { visit "/" }
it "returns results for tools" do
within ".search_bar" do
follow_relation "toggle-... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_featuring_spec.rb | Ruby | apache-2.0 | 214 | main | 450 | require "spec_helper"
feature "supermarket admins can feature a cookbook" do
let(:cookbook) { create(:cookbook) }
let(:admin) { create(:admin) }
before do
sign_in(admin)
visit cookbook_path(cookbook)
follow_relation "toggle_featured"
end
it "displays a success message" do
expect_to_see_suc... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/tool_directory_spec.rb | Ruby | apache-2.0 | 214 | main | 342 | require "spec_helper"
describe "tool directory" do
before do
create_list(:tool, 5)
visit "/"
within ".appnav" do
click_link "Tools & Plugins"
end
end
it "lists the five most recently added tools" do
within ".recently_added_tools" do
expect(all(".simple_listing li").size).to eql... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_manage_spec.rb | Ruby | apache-2.0 | 214 | main | 1,164 | require "spec_helper"
describe "updating a cookbook's issues and source urls" do
let(:user) { create(:user) }
before { sign_in user }
it "saves the source and issues urls" do
cookbook = create(:cookbook, owner: user)
visit cookbook_path(cookbook)
within ".sidebar" do
follow_relation "edit-co... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/badges_cookbook_partner_spec.rb | Ruby | apache-2.0 | 214 | main | 1,446 | require "spec_helper"
describe "A cookbook that has been granted a Partner badge" do
let!(:badged_cookbook) { create(:partner_cookbook, name: "ReallyGreatPartnerCookbook") }
let!(:other_badged_cookbook) { create :partner_cookbook }
let!(:non_badged_cookbook) { create :cookbook }
describe "on its page" do
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_collaboration_spec.rb | Ruby | apache-2.0 | 214 | main | 11,704 | require "spec_helper"
describe "cookbook collaboration" do
let(:suzie) { create(:user) }
let(:sally) { create(:user) }
let(:cookbook) { create(:cookbook, owner: sally) }
before do
create(:cookbook_collaborator, resourceable: cookbook, user: suzie)
end
def navigate_to_cookbook
visit "/"
follow... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_directory_spec.rb | Ruby | apache-2.0 | 214 | main | 784 | require "spec_helper"
describe "cookbook directory" do
before do
create_list(:cookbook, 5)
visit "/"
within ".appnav" do
click_link "Cookbooks"
end
end
it "lists the five most recently updated cookbooks" do
within ".recently-updated" do
expect(all(".simple_listing li").size).to... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/delete_tool_spec.rb | Ruby | apache-2.0 | 214 | main | 473 | require "spec_helper"
describe "deleting a tool" do
before do
user = create(:user)
create(:tool, name: "butter", owner: user)
sign_in(user)
visit "/"
follow_relation "view_profile"
follow_relation "view_tools"
follow_relation "delete_tool"
end
it "displays a success message" do
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_deprecation_spec.rb | Ruby | apache-2.0 | 214 | main | 1,764 | require "spec_helper"
feature "cookbook owners can deprecate a cookbook" do
let(:cookbook) { create(:cookbook) }
let(:replacement_cookbook) { create(:cookbook) }
let(:user) { cookbook.owner }
context "to just say DO NOT USE THIS" do
before do
sign_in(user)
visit cookbook_path(cookbook)
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/signout_spec.rb | Ruby | apache-2.0 | 214 | main | 220 | require "spec_helper"
describe "signing out" do
include CustomUrlHelper
it "displays a message about oc-id" do
sign_in(create(:user))
sign_out
expect(page).to have_content(chef_identity_url)
end
end |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/available_for_adoption_spec.rb | Ruby | apache-2.0 | 214 | main | 437 | require "spec_helper"
describe "adoptable cookbooks directory" do
# let!(:adoptable_cookbook) { create(:cookbook, up_for_adoption: true ) }
before do
@adoptable_cookbook = create(:cookbook, name: "CookbookName", up_for_adoption: true)
visit "/available_for_adoption"
click_link @adoptable_cookbook.na... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/groups_management_spec.rb | Ruby | apache-2.0 | 214 | main | 6,338 | require "spec_helper"
feature "groups management" do
let(:user) { create(:user) }
before do
sign_in(user)
end
describe "user visits their profile page" do
context "when the collaborator_groups feature is activated" do
before do
Feature.activate(:collaborator_groups)
visit user_p... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/account_linking_spec.rb | Ruby | apache-2.0 | 214 | main | 547 | require "spec_helper"
describe "linking an OAuth account to a user" do
it "associates a user with a GitHub account" do
sign_in(create(:user))
manage_github_accounts
connect_github_account
expect_to_see_success_message
end
end
describe "unlinking an OAuth account on a user" do
it "unassociates ... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/cookbook_undeprecation_spec.rb | Ruby | apache-2.0 | 214 | main | 525 | require "spec_helper"
feature "cookbook owners can undeprecate a cookbook" do
let(:cookbook) { create(:cookbook, deprecated: true, replacement: create(:cookbook)) }
let(:user) { cookbook.owner }
before do
sign_in(user)
visit cookbook_path(cookbook)
follow_relation "undeprecate"
end
it "displays... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/features/edit_tool_spec.rb | Ruby | apache-2.0 | 214 | main | 539 | require "spec_helper"
describe "editing a tool" do
before do
user = create(:user)
create(:tool, name: "butter", owner: user)
sign_in(user)
visit "/"
follow_relation "view_profile"
follow_relation "view_tools"
follow_relation "edit_tool"
within ".tool_data" do
fill_in "tool[na... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/oauth_token_refresh_schedule_worker_spec.rb | Ruby | apache-2.0 | 214 | main | 430 | require "spec_helper"
describe OauthTokenRefreshScheduleWorker do
let(:worker) { OauthTokenRefreshScheduleWorker.new }
it "refreshes only tokens which expire soon" do
expiring_users = FactoryBot.create_list(:user, 3)
expect(Account)
.to receive(:tokens_expiring_soon)
.and_return(expiring_user... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/cookbook_notify_worker_spec.rb | Ruby | apache-2.0 | 214 | main | 917 | require "spec_helper"
describe CookbookNotifyWorker do
let!(:system_email1) { create(:system_email, name: "New cookbook version") }
let!(:system_email2) { create(:system_email, name: "Cookbook deprecated") }
let!(:cookbook) { create(:cookbook) }
it "notifies each interested non-imported cookbook follower via ... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/cookbook_deprecated_notifier_spec.rb | Ruby | apache-2.0 | 214 | main | 1,154 | require "spec_helper"
describe CookbookDeprecatedNotifier do
let!(:system_email1) { create(:system_email, name: "Cookbook deleted") }
let!(:system_email2) { create(:system_email, name: "Cookbook deprecated") }
it "sends emails to cookbook owner, collaborators and followers who want to receive emails" do
dis... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/spdx_license_update_worker_spec.rb | Ruby | apache-2.0 | 214 | main | 1,549 | require "spec_helper"
describe SpdxLicenseUpdateWorker, type: :worker do
let(:cookbook) { create(:cookbook) }
let(:json_data) do
[
{
"reference": "https://spdx.org/licenses/eGenix.html",
"isDeprecatedLicenseId": false,
"detailsUrl": "https://spdx.org/licenses/eGenix.json",
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/oauth_token_refresh_worker_spec.rb | Ruby | apache-2.0 | 214 | main | 5,187 | require "spec_helper"
require "vcr_helper"
describe OauthTokenRefreshWorker do
before do
# NOTE: the purpose of these ENV variables is to facilitate happy-path VCR
# cassette regeneration in the OauthTokenRefreshWorker. To re-record the
# happy-path cassette(s) delete the existing cassette(s) and run thi... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/fieri_notify_worker_spec.rb | Ruby | apache-2.0 | 214 | main | 912 | require "spec_helper"
require "webmock/rspec"
describe FieriNotifyWorker do
let(:cookbook) { create(:cookbook) }
it "sends a POST request to the configured fieri_url for cookbook evaluation" do
stub_request(:any, ENV["FIERI_URL"])
worker = FieriNotifyWorker.new
result = worker.perform(cookbook.cookbo... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/sitemap_refresh_worker_spec.rb | Ruby | apache-2.0 | 214 | main | 574 | require "spec_helper"
require "vcr_helper"
describe SitemapRefreshWorker do
around(:each) do |example|
VCR.use_cassette("sitemap_refresh_worker", record: :once) do
example.run
end
end
it "refreshes the sitemap" do
sitemap_file_path = SitemapGenerator::Sitemap.public_path.to_s + SitemapGenerato... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/workers/cookbook_deletion_worker_spec.rb | Ruby | apache-2.0 | 214 | main | 1,529 | require "spec_helper"
describe CookbookDeletionWorker do
let!(:system_email1) { create(:system_email, name: "Cookbook deleted") }
let!(:system_email2) { create(:system_email, name: "Cookbook deprecated") }
let!(:cookbook) { create(:cookbook) }
let!(:worker) { CookbookDeletionWorker.new }
let!(:sally) { creat... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/adoption_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 1,930 | require "spec_helper"
describe AdoptionHelper do
before do
fake_policy = double(:policy, manage_adoption?: true)
allow(helper).to receive(:policy) { fake_policy }
end
context "Cookbooks" do
it "generates a link to enable adoption for a Cookbook" do
cookbook = create(:cookbook, name: "haha", up... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/collaborators_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 2,002 | require "spec_helper"
describe CollaboratorsHelper do
let!(:cookbook) { create(:cookbook) }
let!(:collaborator1) { create(:cookbook_collaborator, resourceable: cookbook) }
let(:group) { create(:group) }
let!(:collaborator2) { create(:cookbook_collaborator, resourceable: cookbook, group: group) }
let!(:colla... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/feature_flag_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 513 | require "spec_helper"
describe FeatureFlagHelper do
describe "#air_gap?" do
context "when the feature flag is set to true" do
before do
ENV["AIR_GAPPED"] = "true"
end
it "returns true" do
expect(helper.air_gapped?).to eq(true)
end
end
context "when the feature fl... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/groups_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 1,308 | require "spec_helper"
describe GroupsHelper do
let(:group) { create(:group) }
let(:admin_user) { create(:user) }
let!(:admin_member) do
create(:admin_group_member, user: admin_user, group: group)
end
let(:user) { create(:user) }
let!(:member) do
create(:group_member, user: user, group: group)
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/supported_platforms_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 726 | require "spec_helper"
describe SupportedPlatformsHelper do
describe "#supported_platform_icon" do
it "returns the corresponding platform name to match image filename" do
platform = SupportedPlatform.new(name: "ubuntu")
expect(helper.supported_platform_icon(platform)).to eql("ubuntu")
end
it... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/custom_url_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 3,900 | require "spec_helper"
describe CustomUrlHelper do
include_context "env stashing"
shared_examples "a url with extra pieces" do
it "should allow extra pieces to be passed to the url" do
expect(helper.send(meth, "something")).to eql("#{url}/something")
end
end
it "should have a default domain" do
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/markdown_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 12,048 | require "spec_helper"
describe MarkdownHelper do
describe "#render_markdown" do
it "renders markdown" do
expect(helper.render_markdown("# Test")).to match(/h1/)
end
it "renders fenced code blocks" do
codeblock = <<-CODEBLOCK.strip_heredoc
```sh
$ bundle exec rake spec:all
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/users_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 1,190 | require "spec_helper"
describe UsersHelper do
let(:user) { create(:user, email: "johndoe@example.com") }
describe "#gravatar_for" do
context "when gravatar feature is enabled" do
before do
allow(Feature).to receive(:active?).with(:gravatar).and_return(true)
end
it "returns the image... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/application_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 2,717 | require "spec_helper"
describe ApplicationHelper do
describe "#auth_path" do
context "when using a symbol" do
it "returns the correct path" do
expect(auth_path(:github)).to eq("/auth/github")
end
end
context "when using a string" do
it "returns the correct path" do
expe... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/cookbooks_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 3,852 | require "spec_helper"
require "nokogiri"
describe CookbooksHelper do
describe "#contingent_link" do
it "links to a cookbook using the cookbook name and version" do
apt = create(:cookbook, name: "apt")
nginx = create(:cookbook, name: "nginx")
version = create(:cookbook_version, cookbook: nginx, ... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/cookbook_versions_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 2,362 | require "spec_helper"
describe CookbookVersionsHelper do
describe "#render_document" do
it 'converts markdown to html when the extension is "md"' do
expect(render_document("*hi*", "md")).to eql("<p><em>hi</em></p>\n")
end
it "returns the content if no extension is specified" do
expect(render... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/helpers/tools_helper_spec.rb | Ruby | apache-2.0 | 214 | main | 335 | require "spec_helper"
describe ToolsHelper do
describe "#pretty_type" do
it "correctly capitalizes DSC Resource" do
expect(helper.pretty_type("dsc_resource")).to eql("DSC Resource")
end
it "titleizes everything" do
expect(helper.pretty_type("blueberry_muffin")).to eql("Blueberry Muffin")
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/routing/user_routes_spec.rb | Ruby | apache-2.0 | 214 | main | 510 | require "spec_helper"
describe "user routes" do
context "to show a user" do
it "uses the Chef Account username as the id parameter" do
# NOTE: if this fails, be sure to update
# app/views/contributors/index.html.erb, which uses the optimized user
# route helper
user = create(:user)
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/routing/cookbook_version_routes_spec.rb | Ruby | apache-2.0 | 214 | main | 3,069 | require "spec_helper"
describe "cookbook version routes" do
context "API" do
context "#show" do
it "can route using underscores" do
expect(get: "/api/v1/cookbooks/redis/versions/1_0_0", format: :json).to route_to(controller: "api/v1/cookbook_versions", action: "show", format: :json, cookbook: "redi... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/routing/universe_routes_spec.rb | Ruby | apache-2.0 | 214 | main | 495 | require "spec_helper"
describe "universe routes" do
context "API" do
context "universe#index" do
it "can route using /api/v1/universe path" do
expect(get: "/api/v1/universe", format: :json).to route_to(controller: "api/v1/universe", action: "index", format: :json)
end
it "routes GET /u... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/services/grant_badge_to_cookbook_spec.rb | Ruby | apache-2.0 | 214 | main | 2,402 | require "spec_helper"
describe GrantBadgeToCookbook do
let(:cookbook) { create(:cookbook) }
let(:badge_name) { "partner" }
let(:badge_granter) { GrantBadgeToCookbook.new(badge: badge_name, cookbook: cookbook.name) }
context "finding the cookbook" do
it "searches for the cookbook by name" do
expect(C... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/services/update_spdx_license_url_spec.rb | Ruby | apache-2.0 | 214 | main | 2,804 | require "spec_helper"
describe UpdateSpdxLicenseUrl do
context "on the supplied version of a single cookbook" do
let(:cookbook) { create :cookbook }
let(:cookbook_version) { cookbook.latest_cookbook_version }
it "returns a message about successful scheduling" do
allow(SpdxLicenseUpdateWorker).to r... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/services/run_quality_metrics_spec.rb | Ruby | apache-2.0 | 214 | main | 4,095 | require "spec_helper"
describe RunQualityMetrics do
context "when fieri is enabled" do
before :each do
expect(Feature).to receive(:active?).with(:fieri).and_return(true)
end
context "on the latest version of a single cookbook" do
let(:cookbook) { create :cookbook }
let(:latest_version)... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/services/fetch_spdx_license_json_spec.rb | Ruby | apache-2.0 | 214 | main | 2,026 | require "spec_helper"
require "webmock/rspec"
describe FetchSpdxLicenseJson do
let(:fetch_spdx) { FetchSpdxLicenseJson.new }
let(:license_json) {
[
{
"reference": "https://spdx.org/licenses/APL-1.0.html",
"isDeprecatedLicenseId": false,
"detailsUrl": "https://spdx.org/licenses/APL... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/services/make_user_admin_spec.rb | Ruby | apache-2.0 | 214 | main | 2,080 | require "spec_helper"
describe MakeUserAdmin do
let(:user) { create(:user) }
let(:make_user_admin) { MakeUserAdmin.new(user.username) }
context "finding the user" do
it "searches for the user by the username" do
expect(User).to receive(:with_username).with(user.username).and_return([user])
make_... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/omni_auth_control.rb | Ruby | apache-2.0 | 214 | main | 1,483 | module OmniAuthControl
EXPIRATION = Time.current.to_i
def self.stub_github!(user = User.new)
OmniAuth.config.mock_auth[:github] = github_hash(user)
end
def self.stub_chef!(user = User.new)
OmniAuth.config.mock_auth[:chef_oauth2] = chef_hash(user)
end
def self.github_hash(user = User.new)
gith... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/auto_authorize.rb | Ruby | apache-2.0 | 214 | main | 427 | #
# Stubs out an action for a given model.
# Useful in controller specs where we don't care about the
# business logic for who is authorized but merely what happens
# when they are.
#
# @example
# auto_authorize!(model, 'action')
#
# @param [ActiveRecord::Base]
# @param [String]
#
def auto_authorize!(model, action)
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/default_extractor.rb | Ruby | apache-2.0 | 214 | main | 441 | class DefaultExtractor < Extractor::Base
def first_name
split_name.first
end
def last_name
split_name.last
end
def uid
auth["uid"]
end
def username
auth["info"]["username"]
end
def email
auth["info"]["email"]
end
def oauth_token
auth["credentials"]["token"]
end
de... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/env_helpers.rb | Ruby | apache-2.0 | 214 | main | 544 | module EnvHelpers
#
# Given a hash of ENV variables and values, yield a block where that ENV is a
# reality, and reset ENV after the block is called. Decidedly not threadsafe.
#
# @example
# with_env('DEBUG' => '1') { ENV['DEBUG'] } #=> '1'
#
# @param temporary_env [Hash] the desired ENV variables
#... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/request_helpers.rb | Ruby | apache-2.0 | 214 | main | 244 | module RequestHelpers
def parsed_response
@parsed_response ||= if response.body
JSON.parse(response.body.strip)
else
{}
end
end
end |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/tarball_helpers.rb | Ruby | apache-2.0 | 214 | main | 883 | require "and_feathers"
require "and_feathers/gzipped_tarball"
module TarballHelpers
#
# Builds and returns a gzipped tarball Tempfile which contains a directory
# named and a minimal metadata.json file inside that directory.
#
# @example
#
# tarball = build_cookbook_tarball do |base|
# base.file(... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/api_spec_helpers.rb | Ruby | apache-2.0 | 214 | main | 4,922 | require_relative "tarball_helpers"
require "mixlib/authentication/signedheaderauth"
module ApiSpecHelpers
#
# Shares a cookbook with a given name and options using the /api/v1/cookbooks API.
#
# @param cookbook_name [String] the name of the cookbook to be shared
# @param user [User] the user that's sharing t... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/feature_helpers.rb | Ruby | apache-2.0 | 214 | main | 3,571 | module FeatureHelpers
#
# If +user+ is not passed it, the mock_auth defaults to the one specified in
# the spec_helper
#
def sign_in(user)
OmniAuthControl.stub_chef!(user)
OmniAuthControl.stub_github!(user)
visit "/"
within ".appnav" do
follow_relation "sign_in"
end
end
def si... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/matchers/authorizer_matcher.rb | Ruby | apache-2.0 | 214 | main | 443 | RSpec::Matchers.define :permit_authorization do |action|
match do |authorizer|
authorizer.public_send("#{action}?")
end
failure_message do |authorizer|
"#{authorizer.class} does not permit #{action} on #{authorizer.record} for #{authorizer.user.inspect}!"
end
failure_message_when_negated do |authori... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/shared_contexts/rake.rb | Ruby | apache-2.0 | 214 | main | 584 | require "rake"
shared_context "rake" do
let(:rake) { Rake::Application.new }
let(:task_name) { self.class.top_level_description }
let(:task_path) { "lib/tasks/#{task_name.split(":").first}" }
subject { rake[task_name] }
def loaded_files_excluding_current_rake_file
$LOADED_FEATURES.reject { ... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/shared_contexts/env_stash.rb | Ruby | apache-2.0 | 214 | main | 217 | shared_context "env stashing" do
let(:stash) { {} }
before do
stash.clear
ENV.each do |k, v|
stash[k] = v
ENV[k] = nil
end
end
after do
stash.each { |k, v| ENV[k] = v }
end
end |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/spec/support/i18n/exceptions.rb | Ruby | apache-2.0 | 214 | main | 529 | # The default exception handling for I18n does not allow to catch missing
# translations during automated tests. This custom exception handler will
# actually raise exceptions instead of silently swallowing them.
module I18n
class ActuallyRaiseExceptionHandler < ExceptionHandler
def call(exception, locale, key, o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.