diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 995a27e1011..4bccfd05d45 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -92,7 +92,6 @@ Rails/I18nLocaleTexts: Exclude: - 'app/mailers/mailer.rb' - 'app/mailers/owners_mailer.rb' - - 'app/models/ownership_call.rb' - 'app/models/user.rb' # Offense count: 5 @@ -107,8 +106,6 @@ Rails/RedundantPresenceValidationOnBelongsTo: Exclude: - 'app/models/api_key_rubygem_scope.rb' - 'app/models/deletion.rb' - - 'app/models/ownership_call.rb' - - 'app/models/ownership_request.rb' - 'app/models/subscription.rb' - 'app/models/version.rb' diff --git a/app/assets/stylesheets/modules/shared.css b/app/assets/stylesheets/modules/shared.css index 499adb14719..b10e381dd98 100644 --- a/app/assets/stylesheets/modules/shared.css +++ b/app/assets/stylesheets/modules/shared.css @@ -222,44 +222,8 @@ span.github-btn { font-weight: 800; } -.adoption__tag { - display: inline-block; - font-size: 0.8em; - font-weight: 800; +.description__heading { color: #e9573f; - border: 1px solid #e9573f; - border-radius: 8px; - padding: 0.25em 1em; - margin-bottom: 0.9em; - vertical-align: 0.3em; - transition: color 0.25s ease-in, - background-color 0.25s ease-in, - transform 0.3s ease-out; -} - -.adoption__tag:hover{ - color: white; - background-color: #e9573f; -} - -.adoption__heading { - color: #e9573f; -} - -.t-body h2.adoption__heading--no-padding { - padding-top: 0px; -} - -.adoption__blog__link { - color: #e9573f; - text-decoration: underline; - font-size: 0.6em; - font-weight: bold; -} - -.adoption__rdoc__link { - text-decoration: underline; - font-weight: bold; } .tooltip__text { diff --git a/app/avo/resources/ownership.rb b/app/avo/resources/ownership.rb index 079445d9d63..114bbd58abc 100644 --- a/app/avo/resources/ownership.rb +++ b/app/avo/resources/ownership.rb @@ -26,7 +26,6 @@ def fields field :push_notifier, as: :boolean field :owner_notifier, as: :boolean - field :ownership_request_notifier, as: :boolean field :authorization, as: :heading diff --git a/app/avo/resources/rubygem.rb b/app/avo/resources/rubygem.rb index 4f3c81c1698..b93d7764a98 100644 --- a/app/avo/resources/rubygem.rb +++ b/app/avo/resources/rubygem.rb @@ -35,8 +35,6 @@ def fields field :ownerships, as: :has_many field :ownerships_including_unconfirmed, as: :has_many - field :ownership_calls, as: :has_many - field :ownership_requests, as: :has_many field :organization, as: :belongs_to field :subscriptions, as: :has_many diff --git a/app/avo/resources/user.rb b/app/avo/resources/user.rb index 2e594b52c06..7faebf43563 100644 --- a/app/avo/resources/user.rb +++ b/app/avo/resources/user.rb @@ -64,8 +64,6 @@ def fields # rubocop:disable Metrics field :web_hooks, as: :has_many field :unconfirmed_ownerships, as: :has_many field :api_keys, as: :has_many, name: "API Keys" - field :ownership_calls, as: :has_many - field :ownership_requests, as: :has_many field :pushed_versions, as: :has_many field :oidc_api_key_roles, as: :has_many field :webauthn_credentials, as: :has_many diff --git a/app/controllers/adoptions_controller.rb b/app/controllers/adoptions_controller.rb deleted file mode 100644 index 8ee0d1cbdf1..00000000000 --- a/app/controllers/adoptions_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -class AdoptionsController < ApplicationController - include SessionVerifiable - - before_action :find_rubygem - before_action :redirect_to_verify, if: -> { policy(@rubygem).manage_adoption? && !verified_session_active? } - - def index - @ownership_call = @rubygem.ownership_call - @user_request = @rubygem.ownership_requests.find_by(user: current_user) - @ownership_requests = @rubygem.ownership_requests.preload(:user) - end - - private - - def find_rubygem - super - authorize @rubygem, :show_adoption? if @rubygem - end -end diff --git a/app/controllers/notifiers_controller.rb b/app/controllers/notifiers_controller.rb index d8d83f899a0..0a59b7a80db 100644 --- a/app/controllers/notifiers_controller.rb +++ b/app/controllers/notifiers_controller.rb @@ -10,12 +10,10 @@ def show def update to_enable_push, to_disable_push = notifier_options("push") to_enable_owner, to_disable_owner = notifier_options("owner") - to_enable_ownership_request, to_disable_ownership_request = notifier_options("ownership_request") current_user.transaction do current_user.ownerships.update_push_notifier(to_enable_push, to_disable_push) current_user.ownerships.update_owner_notifier(to_enable_owner, to_disable_owner) - current_user.ownerships.update_ownership_request_notifier(to_enable_ownership_request, to_disable_ownership_request) Mailer.notifiers_changed(current_user.id).deliver_later end @@ -25,7 +23,7 @@ def update private def notifier_params - params.expect(ownerships: [%i[push owner ownership_request]]) + params.expect(ownerships: [%i[push owner]]) end def notifier_options(param) diff --git a/app/controllers/ownership_calls_controller.rb b/app/controllers/ownership_calls_controller.rb deleted file mode 100644 index 67fd36844cf..00000000000 --- a/app/controllers/ownership_calls_controller.rb +++ /dev/null @@ -1,46 +0,0 @@ -class OwnershipCallsController < ApplicationController - include SessionVerifiable - - before_action :find_rubygem, except: :index - before_action :redirect_to_signin, unless: :signed_in?, except: :index - before_action :redirect_to_new_mfa, if: :mfa_required_not_yet_enabled?, except: :index - before_action :redirect_to_settings_strong_mfa_required, if: :mfa_required_weak_level_enabled?, except: :index - before_action :redirect_to_verify, only: %i[create close], unless: :verified_session_active? - before_action :find_ownership_call, only: :close - - rescue_from ActiveRecord::RecordInvalid, with: :redirect_try_again - rescue_from ActiveRecord::RecordNotSaved, with: :redirect_try_again - - def index - set_page - @ownership_calls = OwnershipCall.opened.includes(:user, rubygem: %i[latest_version gem_download]).order(created_at: :desc) - .page(@page) - .per(Gemcutter::OWNERSHIP_CALLS_PER_PAGE) - end - - def create - @ownership_call = authorize @rubygem.ownership_calls.new(user: current_user, note: params[:note]) - if @ownership_call.save - redirect_to rubygem_adoptions_path(@rubygem.slug), notice: t(".success_notice", gem: @rubygem.name) - else - redirect_to rubygem_adoptions_path(@rubygem.slug), alert: @ownership_call.errors.full_messages.to_sentence - end - end - - def close - @ownership_call.close! - redirect_to rubygem_path(@rubygem.slug), notice: t("ownership_calls.update.success_notice", gem: @rubygem.name) - end - - private - - def find_ownership_call - @ownership_call = @rubygem.ownership_call - return redirect_try_again unless @ownership_call - authorize @ownership_call - end - - def redirect_try_again(_exception = nil) - redirect_to rubygem_adoptions_path(@rubygem.slug), alert: t("try_again") - end -end diff --git a/app/controllers/ownership_requests_controller.rb b/app/controllers/ownership_requests_controller.rb deleted file mode 100644 index 6d641c2328b..00000000000 --- a/app/controllers/ownership_requests_controller.rb +++ /dev/null @@ -1,56 +0,0 @@ -class OwnershipRequestsController < ApplicationController - include SessionVerifiable - - before_action :find_rubygem - before_action :redirect_to_signin, unless: :signed_in? - before_action :redirect_to_new_mfa, if: :mfa_required_not_yet_enabled? - before_action :redirect_to_settings_strong_mfa_required, if: :mfa_required_weak_level_enabled? - before_action :redirect_to_verify, only: %i[update close_all], if: -> { policy(@rubygem).manage_adoption? && !verified_session_active? } - - rescue_from ActiveRecord::RecordInvalid, with: :redirect_try_again - rescue_from ActiveRecord::RecordNotSaved, with: :redirect_try_again - - def create - ownership_request = authorize @rubygem.ownership_requests.new( - ownership_call: @rubygem.ownership_call, - user: current_user, - note: params[:note] - ) - if ownership_request.save - redirect_to rubygem_adoptions_path(@rubygem.slug), notice: t(".success_notice") - else - redirect_to rubygem_adoptions_path(@rubygem.slug), alert: ownership_request.errors.full_messages.to_sentence - end - end - - def update - @ownership_request = OwnershipRequest.find(params[:id]) - - case params.expect(:status) - when "close" then close - when "approve" then approve - else redirect_try_again - end - end - - def close_all - authorize(@rubygem, :manage_adoption?).ownership_requests.each(&:close!) - redirect_to rubygem_adoptions_path(@rubygem.slug), notice: t("ownership_requests.close.success_notice", gem: @rubygem.name) - end - - private - - def approve - authorize(@ownership_request, :approve?).approve!(current_user) - redirect_to rubygem_adoptions_path(@rubygem.slug), notice: t(".approved_notice", name: current_user.display_id) - end - - def close - authorize(@ownership_request, :close?).close!(current_user) - redirect_to rubygem_adoptions_path(@rubygem.slug), notice: t(".closed_notice") - end - - def redirect_try_again(_exception = nil) - redirect_to rubygem_adoptions_path(@rubygem.slug), alert: t("try_again") - end -end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 0ddf1f9184c..58b613dd642 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -48,11 +48,6 @@ def destroy redirect_to root_path, notice: t(".request_queued") end - def adoptions - @ownership_calls = current_user.ownership_calls.includes(:user, rubygem: %i[latest_version gem_download]) - @ownership_requests = current_user.ownership_requests.includes(:rubygem) - end - def security_events @security_events = current_user.events.order(id: :desc).page(params[:page]).per(50) render Profiles::SecurityEventsView.new(security_events: @security_events) diff --git a/app/controllers/rubygems_controller.rb b/app/controllers/rubygems_controller.rb index e5a9ef07d30..88f1fde17d2 100644 --- a/app/controllers/rubygems_controller.rb +++ b/app/controllers/rubygems_controller.rb @@ -22,7 +22,6 @@ def index def show @versions = @rubygem.public_versions.limit(5) - @adoption = @rubygem.ownership_call if @versions.to_a.any? render "show" else diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 9624140d33c..d1364f86369 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -10,7 +10,6 @@ def show @latest_version = @rubygem.find_version_by_slug!(params[:id]) @versions = @rubygem.public_versions_with_extra_version(@latest_version) @versioned_links = @rubygem.links(@latest_version) - @adoption = @rubygem.ownership_call @on_version_page = true render "rubygems/show" end diff --git a/app/helpers/owners_helper.rb b/app/helpers/owners_helper.rb index a9fcfc214fc..7cb74e73aa2 100644 --- a/app/helpers/owners_helper.rb +++ b/app/helpers/owners_helper.rb @@ -18,10 +18,4 @@ def mfa_status(user) image_tag("/images/check.svg") end end - - def sanitize_note(text) - options = RDoc::Options.new - options.pipe = true - simple_format RDoc::Markup.new.convert(text, RDoc::Markup::ToHtml.new(options)) - end end diff --git a/app/helpers/rubygems_helper.rb b/app/helpers/rubygems_helper.rb index d652cb01316..cdd1d138551 100644 --- a/app/helpers/rubygems_helper.rb +++ b/app/helpers/rubygems_helper.rb @@ -121,11 +121,6 @@ def resend_owner_confirmation_link(rubygem) resend_confirmation_rubygem_owners_path(rubygem.slug), class: "gem__link t-list__item" end - def rubygem_adoptions_link(rubygem) - link_to "Adoption", - rubygem_adoptions_path(rubygem.slug), class: "gem__link t-list__item" - end - def rubygem_security_events_link(rubygem) link_to "Security Events", security_events_rubygem_path(rubygem.slug), class: "gem__link t-list__item" diff --git a/app/mailers/owners_mailer.rb b/app/mailers/owners_mailer.rb index 2130ee0abcb..50491c260ff 100644 --- a/app/mailers/owners_mailer.rb +++ b/app/mailers/owners_mailer.rb @@ -40,28 +40,4 @@ def owner_added(user_id, owner_id, authorizer_id, gem_id) mail to: @user.email, subject: t("mailer.owner_added.subject_#{owner_i18n_key(@owner, @user)}", gem: @rubygem.name, owner_handle: @owner.display_handle) end - - def new_ownership_requests(rubygem_id, user_id) - @user = User.find(user_id) - @rubygem = Rubygem.find(rubygem_id) - @ownership_requests_count = @rubygem.ownership_requests.opened.count - mail to: @user.email, - subject: "New ownership request(s) for #{@rubygem.name}" - end - - def ownership_request_approved(ownership_request_id) - @ownership_request = OwnershipRequest.find(ownership_request_id) - @rubygem = @ownership_request.rubygem - @user = @ownership_request.user - mail to: @user.email, - subject: "Your ownership request was approved." - end - - def ownership_request_closed(ownership_request_id) - @ownership_request = OwnershipRequest.find(ownership_request_id) - @rubygem = @ownership_request.rubygem - @user = @ownership_request.user - mail to: @user.email, - subject: "Your ownership request was closed." - end end diff --git a/app/models/ownership.rb b/app/models/ownership.rb index bbe1f3776c8..153f56f9c5c 100644 --- a/app/models/ownership.rb +++ b/app/models/ownership.rb @@ -1,4 +1,6 @@ class Ownership < ApplicationRecord + self.ignored_columns += %w[ownership_request_notifier] + belongs_to :rubygem belongs_to :user belongs_to :authorizer, class_name: "User" @@ -53,10 +55,6 @@ def self.update_owner_notifier(to_enable_owner, to_disable_owner) update_notifier(to_enable_owner, to_disable_owner, "owner_notifier") end - def self.update_ownership_request_notifier(to_enable_ownership_request, to_disable_ownership_request) - update_notifier(to_enable_ownership_request, to_disable_ownership_request, "ownership_request_notifier") - end - def valid_confirmation_token? token_expires_at > Time.zone.now end diff --git a/app/models/ownership_call.rb b/app/models/ownership_call.rb deleted file mode 100644 index 01b836dbf77..00000000000 --- a/app/models/ownership_call.rb +++ /dev/null @@ -1,19 +0,0 @@ -class OwnershipCall < ApplicationRecord - belongs_to :rubygem - belongs_to :user - has_many :ownership_requests, -> { opened }, dependent: :destroy, inverse_of: :ownership_call - - validates :note, length: { maximum: Gemcutter::MAX_TEXT_FIELD_LENGTH } - validates :rubygem_id, :user_id, :status, :note, presence: true - validates :rubygem_id, uniqueness: { conditions: -> { opened }, message: "can have only one open ownership call" } - - delegate :name, to: :rubygem, prefix: true - delegate :display_handle, to: :user, prefix: true - - enum :status, { opened: true, closed: false } - - def close! - ownership_requests.each(&:close!) - update!(status: :closed) - end -end diff --git a/app/models/ownership_request.rb b/app/models/ownership_request.rb deleted file mode 100644 index 3aafdd45514..00000000000 --- a/app/models/ownership_request.rb +++ /dev/null @@ -1,43 +0,0 @@ -class OwnershipRequest < ApplicationRecord - belongs_to :rubygem - belongs_to :user - belongs_to :ownership_call, optional: true - belongs_to :approver, class_name: "User", optional: true - - validates :status, :note, presence: true - validates :note, length: { maximum: Gemcutter::MAX_TEXT_FIELD_LENGTH } - validates :user_id, uniqueness: { scope: :rubygem_id, conditions: -> { opened } } - validate :not_already_owner, on: :create - - delegate :name, to: :user, prefix: true - delegate :name, to: :rubygem, prefix: true - - enum :status, { opened: 0, approved: 1, closed: 2 } - - def approve!(approver) - return unless Pundit.policy!(approver, self).approve? - transaction do - update!(status: :approved, approver: approver) - Ownership.create_confirmed(rubygem, user, approver) - end - - rubygem.ownership_notifiable_owners.each do |notified_user| - OwnersMailer.owner_added(notified_user.id, user_id, approver.id, rubygem_id).deliver_later - end - - OwnersMailer.ownership_request_approved(id).deliver_later - end - - def close!(closer = nil) - update!(status: :closed) - return if closer && closer == user # Don't notify the requester if they closed their own request - OwnersMailer.ownership_request_closed(id).deliver_later - end - - private - - def not_already_owner - return unless rubygem.owned_by?(user) - errors.add(:user_id, I18n.t("activerecord.errors.models.ownership_request.attributes.user_id.existing")) - end -end diff --git a/app/models/rubygem.rb b/app/models/rubygem.rb index 59529105575..f0c423f4a71 100644 --- a/app/models/rubygem.rb +++ b/app/models/rubygem.rb @@ -8,7 +8,6 @@ class Rubygem < ApplicationRecord has_many :owners_including_unconfirmed, through: :ownerships_including_unconfirmed, source: :user has_many :push_notifiable_owners, ->(gem) { gem.owners.push_notifiable_owners }, through: :ownerships, source: :user has_many :ownership_notifiable_owners, ->(gem) { gem.owners.ownership_notifiable_owners }, through: :ownerships, source: :user - has_many :ownership_request_notifiable_owners, ->(gem) { gem.owners.ownership_request_notifiable_owners }, through: :ownerships, source: :user has_many :subscriptions, dependent: :destroy has_many :subscribers, through: :subscriptions, source: :user has_many :versions, dependent: :destroy, validate: false @@ -16,8 +15,6 @@ class Rubygem < ApplicationRecord has_many :web_hooks, dependent: :destroy has_one :linkset, dependent: :destroy has_one :gem_download, -> { where(version_id: 0) }, inverse_of: :rubygem - has_many :ownership_calls, -> { opened }, dependent: :destroy, inverse_of: :rubygem - has_many :ownership_requests, -> { opened }, dependent: :destroy, inverse_of: :rubygem has_many :audits, as: :auditable, inverse_of: :auditable has_many :link_verifications, as: :linkable, inverse_of: :linkable, dependent: :destroy has_many :oidc_rubygem_trusted_publishers, class_name: "OIDC::RubygemTrustedPublisher", inverse_of: :rubygem, dependent: :destroy @@ -269,10 +266,6 @@ def create_ownership(user) Ownership.create_confirmed(self, user, user) if unowned? end - def ownership_call - ownership_calls.find_by(status: "opened") - end - def update_versions!(version, spec) version.update_attributes_from_gem_specification!(spec) end diff --git a/app/models/user.rb b/app/models/user.rb index b10a873d9c4..3ad58b83323 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -50,12 +50,6 @@ class User < ApplicationRecord has_many :unconfirmed_ownerships, -> { unconfirmed }, dependent: :destroy, inverse_of: :user, class_name: "Ownership" has_many :api_keys, dependent: :destroy, inverse_of: :owner, as: :owner - has_many :ownership_calls, -> { opened }, dependent: :destroy, inverse_of: :user - has_many :closed_ownership_calls, -> { closed }, dependent: :destroy, inverse_of: :user, class_name: "OwnershipCall" - has_many :ownership_requests, -> { opened }, dependent: :destroy, inverse_of: :user - has_many :closed_ownership_requests, -> { closed }, dependent: :destroy, inverse_of: :user, class_name: "OwnershipRequest" - has_many :approved_ownership_requests, -> { approved }, dependent: :destroy, inverse_of: :user, class_name: "OwnershipRequest" - has_many :audits, as: :auditable, dependent: :nullify has_many :rubygem_events, through: :rubygems, source: :events @@ -143,10 +137,6 @@ def self.ownership_notifiable_owners where(ownerships: { owner_notifier: true }) end - def self.ownership_request_notifiable_owners - where(ownerships: { ownership_request_notifier: true }) - end - def self.normalize_email(email) email.to_s.gsub(/\s+/, "") rescue ArgumentError @@ -336,8 +326,6 @@ def expire_all_api_keys def destroy_associations_for_discard ownerships.unscope(where: :confirmed_at).destroy_all - ownership_requests.update_all(status: :closed) - ownership_calls.unscope(where: :status).destroy_all oidc_pending_trusted_publishers.destroy_all subscriptions.destroy_all web_hooks.destroy_all diff --git a/app/policies/admin/rubygem_policy.rb b/app/policies/admin/rubygem_policy.rb index 620b3614320..752784aafd4 100644 --- a/app/policies/admin/rubygem_policy.rb +++ b/app/policies/admin/rubygem_policy.rb @@ -13,8 +13,6 @@ def resolve has_association :latest_version has_association :ownerships has_association :ownerships_including_unconfirmed - has_association :ownership_calls - has_association :ownership_requests has_association :subscriptions has_association :subscribers has_association :web_hooks diff --git a/app/policies/admin/user_policy.rb b/app/policies/admin/user_policy.rb index 117f703d5d8..b2bee86822d 100644 --- a/app/policies/admin/user_policy.rb +++ b/app/policies/admin/user_policy.rb @@ -13,8 +13,6 @@ def resolve has_association :memberships has_association :oidc_api_key_roles has_association :organizations - has_association :ownership_calls - has_association :ownership_requests has_association :ownerships has_association :pushed_versions has_association :rubygems diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index d7bf716f226..e7e80d61150 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -31,11 +31,6 @@ def deny(error = t(:forbidden)) false end - def allow - @error = nil - true - end - def current_user?(record_user) user && user == record_user end @@ -59,9 +54,4 @@ def organization_member_with_role?(user, minimum_role) def policy!(user, record) = Pundit.policy!(user, record) def user_policy!(record) = policy!(user, record) - - def user_authorized?(record, action) - policy = user_policy!(record) - policy.send(action) || deny(policy.error) - end end diff --git a/app/policies/ownership_call_policy.rb b/app/policies/ownership_call_policy.rb deleted file mode 100644 index dafeff928cc..00000000000 --- a/app/policies/ownership_call_policy.rb +++ /dev/null @@ -1,14 +0,0 @@ -class OwnershipCallPolicy < ApplicationPolicy - class Scope < ApplicationPolicy::Scope - end - - delegate :rubygem, to: :record - - def create? - user_authorized?(rubygem, :manage_adoption?) - end - - def close? - user_authorized?(rubygem, :manage_adoption?) - end -end diff --git a/app/policies/ownership_request_policy.rb b/app/policies/ownership_request_policy.rb deleted file mode 100644 index c1db2e38200..00000000000 --- a/app/policies/ownership_request_policy.rb +++ /dev/null @@ -1,18 +0,0 @@ -class OwnershipRequestPolicy < ApplicationPolicy - class Scope < ApplicationPolicy::Scope - end - - delegate :rubygem, to: :record - - def create? - current_user?(record.user) && user_authorized?(rubygem, :request_ownership?) - end - - def approve? - rubygem_owned_by?(user) - end - - def close? - current_user?(record.user) || rubygem_owned_by?(user) - end -end diff --git a/app/policies/rubygem_policy.rb b/app/policies/rubygem_policy.rb index 8c23df1c0d0..ccf189f6689 100644 --- a/app/policies/rubygem_policy.rb +++ b/app/policies/rubygem_policy.rb @@ -20,29 +20,10 @@ def configure_trusted_publishers? rubygem_owned_by_with_role?(user, minimum_required_role: :owner, minimum_required_org_role: :admin) end - def manage_adoption? - rubygem_owned_by_with_role?(user, minimum_required_role: :owner) - end - - def request_ownership? - return allow if rubygem.ownership_calls.any? - return false if rubygem.downloads >= ABANDONED_DOWNLOADS_MAX - return false if rubygem.latest_version.nil? || rubygem.latest_version.created_at.after?(ABANDONED_RELEASE_AGE.ago) - allow - end - - def show_adoption? - manage_adoption? || request_ownership? - end - def show_events? rubygem_owned_by?(user) end - def close_ownership_requests? - rubygem_owned_by_with_role?(user, minimum_required_role: :owner) - end - def show_unconfirmed_ownerships? rubygem_owned_by_with_role?(user, minimum_required_role: :owner, minimum_required_org_role: :admin) end diff --git a/app/views/adoptions/index.html.erb b/app/views/adoptions/index.html.erb deleted file mode 100644 index 7d6ae93012f..00000000000 --- a/app/views/adoptions/index.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -<% @title_for_header_only = t('.title') %> - -<% content_for :title do %> -

- <%= t('.title') %> - <% if policy(@rubygem).manage_adoption? %> - <%= t(".subtitle_owner_html", gem: @rubygem.name) %> - <% else %> - <%= t(".subtitle_user_html", gem: @rubygem.name) %> - <% end %> -

-<% end %> - -
-

<%= t(".ownership_calls") %> - [?] -

-
- -<% if @ownership_call %> -
- <%= sanitize_note(@ownership_call.note) %> -

- <%= t("ownership_calls.created_by") %>: - <%= link_to @ownership_call.user_display_handle, profile_path(@ownership_call.user), class: "t-text t-link" %> -

- <% if policy(@ownership_call).close? %> - <%= button_to t("ownership_calls.close"), close_rubygem_ownership_calls_path(@ownership_call.rubygem.slug), method: :patch, class: "form__submit form__submit--medium" %> - <% end %> -
- -<% elsif policy(@rubygem).manage_adoption? %> - <%= render partial: "ownership_calls/form", locals: { gem: @rubygem.name } %> -<% else %> -
-

<%= t(".no_ownership_calls", gem: @rubygem.name) %>

-
-<% end %> - -<%= render "ownership_requests/list" %> diff --git a/app/views/components/oidc/id_token/key_value_pairs_component.rb b/app/views/components/oidc/id_token/key_value_pairs_component.rb index 8052eb446ad..16e4c201c85 100644 --- a/app/views/components/oidc/id_token/key_value_pairs_component.rb +++ b/app/views/components/oidc/id_token/key_value_pairs_component.rb @@ -6,7 +6,7 @@ class OIDC::IdToken::KeyValuePairsComponent < ApplicationComponent def view_template dl(class: "t-body provider_attributes full-width overflow-wrap") do pairs.each do |key, val| - dt(class: "adoption__heading text-right") { code { key } } + dt(class: "description__heading text-right") { code { key } } dd { code { val } } end end diff --git a/app/views/components/oidc/trusted_publisher/github_action/table_component.rb b/app/views/components/oidc/trusted_publisher/github_action/table_component.rb index ecb8e83242b..0f23630da5d 100644 --- a/app/views/components/oidc/trusted_publisher/github_action/table_component.rb +++ b/app/views/components/oidc/trusted_publisher/github_action/table_component.rb @@ -3,14 +3,14 @@ class OIDC::TrustedPublisher::GitHubAction::TableComponent < ApplicationComponen def view_template dl(class: "tw-flex tw-flex-col sm:tw-grid sm:tw-grid-cols-2 tw-items-baseline tw-gap-4 full-width overflow-wrap") do - dt(class: "adoption__heading ") { "GitHub Repository" } + dt(class: "description__heading ") { "GitHub Repository" } dd { code { github_action.repository } } - dt(class: "adoption__heading ") { "Workflow Filename" } + dt(class: "description__heading ") { "Workflow Filename" } dd { code { github_action.workflow_filename } } if github_action.environment? - dt(class: "adoption__heading") { "Environment" } + dt(class: "description__heading") { "Environment" } dd { code { github_action.environment } } end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index aa3422566f8..212e8486712 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -143,7 +143,6 @@ <%- else %> <%= link_to t('.footer.security'), page_path("security"), class: "nav--v__link--footer" %> <%- end %> - <%= link_to t('.footer.looking_for_maintainers'), ownership_calls_path, class: "nav--v__link--footer" %>
diff --git a/config/deploy/ownership-requests-notify-daily.yaml.erb b/config/deploy/ownership-requests-notify-daily.yaml.erb deleted file mode 100644 index cd80384e7e5..00000000000 --- a/config/deploy/ownership-requests-notify-daily.yaml.erb +++ /dev/null @@ -1,94 +0,0 @@ -apiVersion: batch/v1 -kind: CronJob -metadata: - name: ownership-requests-notify-daily - labels: - name: ownership-requests-notify-daily -spec: - concurrencyPolicy: Forbid - schedule: "0 2 * * *" - jobTemplate: - spec: - template: - metadata: - labels: - name: ownership-requests-notify-daily - tags.datadoghq.com/env: "<%= environment %>" - tags.datadoghq.com/service: rubygems.org - tags.datadoghq.com/version: <%= current_sha %> - spec: - restartPolicy: "OnFailure" - containers: - - name: ownership-requests-notify-daily - image: 048268392960.dkr.ecr.us-west-2.amazonaws.com/rubygems/rubygems.org:<%= current_sha %> - args: ["rake", "ownership_request_notification:send"] - resources: - <% if environment == 'production' %> - requests: - cpu: 500m - memory: 1Gi - limits: - cpu: 2000m - memory: 3Gi - <% else %> - requests: - cpu: 200m - memory: 1Gi - limits: - cpu: 500m - memory: 2Gi - <% end %> - env: - - name: RAILS_ENV - value: "<%= environment %>" - - name: ENV - value: "<%= environment %>" - - name: DD_AGENT_HOST - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: status.hostIP - - name: STATSD_IMPLEMENTATION - value: "datadog" - - name: STATSD_HOST - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: status.hostIP - - name: STATSD_ADDR - value: $(STATSD_HOST):8125 - - name: SECRET_KEY_BASE - valueFrom: - secretKeyRef: - name: <%= environment %> - key: secret_key_base - - name: CLIENT_ID - valueFrom: - secretKeyRef: - name: <%= environment %> - key: client_id - - name: SLACK_HOOK - valueFrom: - secretKeyRef: - name: <%= environment %> - key: slack_hook - - name: HONEYBADGER_API_KEY - valueFrom: - secretKeyRef: - name: <%= environment %> - key: honeybadger_api_key - - name: DATABASE_URL - valueFrom: - secretKeyRef: - name: <%= environment %> - key: database_url - volumeMounts: - - mountPath: /app/lib/tasks/users_verify.rake - name: users-verify-rake-volume - subPath: users_verify.rake - securityContext: - privileged: false - volumes: - - name: users-verify-rake-volume - configMap: - name: users-verify-rake-file diff --git a/config/deploy/production/ownership-requests-notify-daily.yaml.erb b/config/deploy/production/ownership-requests-notify-daily.yaml.erb deleted file mode 120000 index 137a21a41cc..00000000000 --- a/config/deploy/production/ownership-requests-notify-daily.yaml.erb +++ /dev/null @@ -1 +0,0 @@ -../ownership-requests-notify-daily.yaml.erb \ No newline at end of file diff --git a/config/deploy/staging/ownership-requests-notify-daily.yaml.erb b/config/deploy/staging/ownership-requests-notify-daily.yaml.erb deleted file mode 120000 index 137a21a41cc..00000000000 --- a/config/deploy/staging/ownership-requests-notify-daily.yaml.erb +++ /dev/null @@ -1 +0,0 @@ -../ownership-requests-notify-daily.yaml.erb \ No newline at end of file diff --git a/config/initializers/prosopite.rb b/config/initializers/prosopite.rb index 19c65ff5a37..ec9758a21a7 100644 --- a/config/initializers/prosopite.rb +++ b/config/initializers/prosopite.rb @@ -13,10 +13,7 @@ # avo auditing potentially loads things multiple times, but it will be bounded by the size of the audit "app/avo/actions/application_action.rb", "app/components/avo/fields/audited_changes_field/show_component.html.erb", - "app/components/avo/views/resource_index_component.html.erb", - - # calls count for each owner, AR doesn't yet allow preloading aggregates - "app/views/ownership_requests/_ownership_request.html.erb" + "app/components/avo/views/resource_index_component.html.erb" ] end end diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index 1a0ca94ead3..5fce0e26e4f 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -232,16 +232,6 @@ def self.api_key_owner_id(req) end end - rate_limited_ownership_request_action = [{ controller: "ownership_requests", action: "create" }] - REQUEST_LIMIT_PERIOD = 2.days - - throttle("ownership_requests/email", limit: REQUEST_LIMIT_PER_EMAIL, period: REQUEST_LIMIT_PERIOD) do |req| - if protected_route?(rate_limited_ownership_request_action, req.path, req.request_method) - action_dispatch_req = ActionDispatch::Request.new(req.env) - User.find_by_remember_token(action_dispatch_req.cookie_jar.signed["remember_token"])&.email.presence - end - end - ### Custom Throttle Response ### # By default, Rack::Attack returns an HTTP 429 for throttled responses, diff --git a/config/locales/de.yml b/config/locales/de.yml index 4e27d72653d..759b84980e3 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -116,11 +116,6 @@ de: user_id: already_confirmed: ist bereits Eigentümer dieses Gems already_invited: wurde bereits zu diesem Gem eingeladen - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -401,28 +396,6 @@ de: subtitle: body_html: body_text: - ownerhip_request_closed: - title: ANFRAGE ZUR BESITZERRECHTIGUNG - subtitle: Hallo %{handle}! - body_html: Vielen Dank, dass du dich um die Besitzerrechte für das %{gem}-Gem - beworben hast. Leider müssen wir dir mitteilen, dass deine Anfrage vom Gem-Besitzer - geschlossen wurde. - ownerhip_request_approved: - body_html: Herzlichen Glückwunsch! Deine Anfrage zur Besitzerrechte für das - %{gem}-Gem wurde genehmigt. Du wurdest als Besitzer zum Gem - hinzugefügt. - new_ownership_requests: - body_html: - zero: Es gibt keine neuen Anfragen zur Besitzerrechte für das %{gem}-Gem. - one: Es gibt eine neue Anfrage zur Besitzerrechte für das %{gem}-Gem. - Bitte klicke auf den unten stehenden Button, um sie anzuzeigen. - other: Es gibt %{count} neue Anfragen zur Besitzerrechte für das - %{gem}-Gem. Bitte klicke auf den unten stehenden Button, - um alle Anfragen anzuzeigen. - button: BESITZERRECHTE - disable_notifications: Um diese Nachrichten nicht mehr zu erhalten, aktualisiere - deine - owners_page: BESITZERRECHTE web_hook_deleted: title: WEBHOOK GELÖSCHT subject: Dein %{host}-Webhook wurde gelöscht @@ -639,7 +612,6 @@ de: title: update: owner_heading: - owner_request_heading: push_heading: webauthn_verifications: expired_or_already_used: @@ -730,11 +702,6 @@ de: ui_and_api: ui_and_gem_signin: profiles: - adoptions: - no_ownership_calls: - no_ownership_requests: - title: - subtitle_html: edit: change_avatar: disabled_avatar_html: @@ -897,47 +864,6 @@ de: imported_gem_version_notice: version: yanked: - adoptions: - index: - title: - subtitle_owner_html: - subtitle_user_html: - ownership_calls: - no_ownership_calls: - ownership_calls: - update: - success_notice: - create: - success_notice: - index: - title: - subtitle_html: - share_requirements: - note_for_applicants: - created_by: - details: - apply: - close: - markup_supported_html: - create_call: - ownership_requests: - create: - success_notice: - update: - approved_notice: - closed_notice: - close: - success_notice: - ownership_requests: - note_for_owners: - your_ownership_requests: - close_all: - approve: - gems_published: - created_at: - no_ownership_requests: - create_req: - signin_to_create_html: webauthn_credentials: callback: success: diff --git a/config/locales/en.yml b/config/locales/en.yml index 8cbcceaa8b0..7ab500963cf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -111,11 +111,6 @@ en: user_id: already_confirmed: "is already an owner of this gem" already_invited: "is already invited to this gem" - ownership_request: - attributes: - user_id: - taken: "has already requested ownership" - existing: "is already an owner" user: attributes: handle: @@ -367,20 +362,6 @@ en: subtitle: Hi %{user_handle}! body_html: Your role was updated to %{role} for %{gem} gem. body_text: Your role was updated to %{role} for %{gem} gem. - ownerhip_request_closed: - title: OWNERSHIP REQUEST - subtitle: Hi %{handle}! - body_html: Thank you for applying for ownership of %{gem}. We regret to inform you that your ownership request was closed by the gem owner. - ownerhip_request_approved: - body_html: Congratulations! Your ownership request for %{gem} was approved. You were added as an owner to the gem. - new_ownership_requests: - body_html: - zero: There are no new ownership requests for %{gem}. - one: There is one new ownership request for %{gem}. Please click on the button below to see it. - other: There are %{count} new ownership requests for %{gem}. Please click on the button below to see all requests. - button: OWNERSHIP REQUESTS - disable_notifications: To stop receiving these messages, update your - owners_page: OWNERSHIPS web_hook_deleted: title: WEBHOOK DELETED subject: Your %{host} webhook was deleted @@ -552,7 +533,6 @@ en: title: Email notifications update: Update owner_heading: Ownership Notifications - owner_request_heading: Ownership Request Notifications push_heading: Push Notifications webauthn_verifications: expired_or_already_used: The token in the link you used has either expired or been used already. @@ -643,11 +623,6 @@ en: ui_and_api: UI and API (Recommended) ui_and_gem_signin: UI and gem signin profiles: - adoptions: - no_ownership_calls: You have not created any ownership call for any of your gems. - no_ownership_requests: You have not created any ownership request. - title: Adoption - subtitle_html: Ask for new maintainers or request ownership (read more) edit: change_avatar: Change Avatar disabled_avatar_html: "A default avatar is used due to private email settings. To enable a personalized Gravatar, turn on 'Show email in public profile'. Notice this will expose your email to the public." @@ -810,47 +785,6 @@ en: imported_gem_version_notice: "This gem version was imported to RubyGems.org on %{import_date}. The date displayed was specified by the author in the gemspec." version: yanked: yanked - adoptions: - index: - title: Adoptions - subtitle_owner_html: Ask new maintainers to join %{gem} (read more) - subtitle_user_html: Request ownership of %{gem} (read more) - ownership_calls: Ownership Call - no_ownership_calls: There are no ownership calls for %{gem}. The gem owners are not looking for new maintainers. - ownership_calls: - update: - success_notice: The ownership call for %{gem} was closed. - create: - success_notice: Created ownership call for %{gem}. - index: - title: Maintainers wanted - subtitle_html: RubyGems looking for new maintainers to join (read more) - share_requirements: Please share in what areas do you need help - note_for_applicants: "Note for applicants:" - created_by: Created by - details: Details - apply: Apply - close: Close - markup_supported_html: Rdoc markup supported - create_call: Create ownership call - ownership_requests: - create: - success_notice: Your ownership request was submitted. - update: - approved_notice: Ownership request was approved. %{name} is added as an owner. - closed_notice: Ownership request was closed. - close: - success_notice: All open ownership requests for %{gem} were closed. - ownership_requests: Ownership Requests - note_for_owners: "Note for owners:" - your_ownership_requests: Your ownership requests - close_all: Close all - approve: Approve - gems_published: Gems published - created_at: Created at - no_ownership_requests: Requests to join your project will show up here. No ownership requests for %{gem} yet. - create_req: Create ownership request - signin_to_create_html: Please sign in to create an ownership request. webauthn_credentials: callback: success: You have successfully registered a security device. diff --git a/config/locales/es.yml b/config/locales/es.yml index 13af010f64d..ee4e6809115 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -114,11 +114,6 @@ es: user_id: already_confirmed: ya es propietario de esta gema already_invited: ya ha sido invitado a esta gema - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -400,24 +395,6 @@ es: subtitle: body_html: body_text: - ownerhip_request_closed: - title: CANDIDATURA A PROPIETARIO - subtitle: "¡Hola %{handle}!" - body_html: Gracias por proponerte como propietario para %{gem}. - Lamentamos informarte de que el dueño de la gema ha cerrado tu solicitud. - ownerhip_request_approved: - body_html: "¡Enhorabuena! Tu candidatura a propietario de %{gem} - ha sido aprobada. Se te ha añadido a la lista de propietarios de la gema." - new_ownership_requests: - body_html: - zero: No hay nuevas candidaturas a propietario para %{gem}. - one: Hay una nueva candidatura a propietario para %{gem}. - Por favor haz click en el botón siguiente para verla. - other: Hay %{count} nuevas candidaturas a propietario para %{gem}. - Por favor haz click en el botón siguiente para ver todas las candidaturas. - button: CANDIDATURAS A PROPIETARIO - disable_notifications: Para dejar de recibir estos mensajes actualiza tus - owners_page: PROPIETARIOS web_hook_deleted: title: WEBHOOK ELIMINADO subject: Se ha borrado tu webhook en %{host} @@ -623,7 +600,6 @@ es: title: Notificación de email update: Actualizar owner_heading: Notificaciones de propietarios - owner_request_heading: Notificaciones de solicitud de propietarios push_heading: Notificaciones Push webauthn_verifications: expired_or_already_used: El token del enlace utilizado ha expirado o ya ha sido @@ -726,14 +702,6 @@ es: ui_and_api: Interfaz de Usuario y API ui_and_gem_signin: Interfaz de Usuario y firma de gemas profiles: - adoptions: - no_ownership_calls: No has creado llamadas a ser propietario para ninguna de - tus gemas - no_ownership_requests: No has creado ninguna petición para ser propietario - title: Adopción - subtitle_html: Pide nuevos responsables de mantenimiento o solicita propietarios - (leer - más) edit: change_avatar: Cambiar avatar disabled_avatar_html: Se usa un avatar por defecto debido a la configuración @@ -927,57 +895,6 @@ es: el archivo gemspec. version: yanked: borrada - adoptions: - index: - title: Adopciones - subtitle_owner_html: Solicita nuevos responsables de mantenimiento para %{gem} - (leer - más) - subtitle_user_html: Solicita ser propietario de %{gem} (leer - más) - ownership_calls: Solicitud de propietarios - no_ownership_calls: No hay convocatorias de propietarios para %{gem}. Los dueños - de la gema no están buscando nuevos responsables de mantenimiento. - ownership_calls: - update: - success_notice: Convocatoria para propietarios de %{gem} cerrada. - create: - success_notice: Creada convocatoria para propietarios de %{gem}. - index: - title: Se buscan responsables de mantenimiento - subtitle_html: Gemas que buscan nuevos responsables de mantenimiento (leer - más) - share_requirements: Por favor especifica en que areas necesitas ayuda - note_for_applicants: 'Nota para candidatos:' - created_by: Creado por - details: Detalles - apply: Proponte - close: Cerrar - markup_supported_html: Etiquetas - Rdoc soportadas - create_call: Crear convocatoria para propietarios - ownership_requests: - create: - success_notice: Se ha enviado tu candidatura a propietario. - update: - approved_notice: Candidatura a propietario aprobada. %{name} añadido a propietarios. - closed_notice: Se ha cerrado la candidatura a propietario. - close: - success_notice: Se han cerrado todas las candidaturas a propietario de %{gem}. - ownership_requests: Candidaturas a propietario - note_for_owners: 'Nota para propietarios:' - your_ownership_requests: Tus candidaturas a propietario - close_all: Cerrar todas - approve: Aprobar - gems_published: Gemas publicadas - created_at: Creado el - no_ownership_requests: Las peticiones para unirse a tu proyecto aparecerán aquí. - Todavia no hay candidaturas a propietario para %{gem}. - create_req: Crea una candidatura a propietario - signin_to_create_html: Por favor accede - para crear una candidatura a propietario. webauthn_credentials: callback: success: Has dado de alta con éxito un dispositivo de seguridad. diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 335f12a7271..7c295b4451a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -112,11 +112,6 @@ fr: user_id: already_confirmed: already_invited: - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -379,20 +374,6 @@ fr: subtitle: body_html: body_text: - ownerhip_request_closed: - title: - subtitle: - body_html: - ownerhip_request_approved: - body_html: - new_ownership_requests: - body_html: - zero: - one: - other: - button: - disable_notifications: - owners_page: web_hook_deleted: title: subject: @@ -563,7 +544,6 @@ fr: title: update: owner_heading: - owner_request_heading: push_heading: webauthn_verifications: expired_or_already_used: @@ -654,11 +634,6 @@ fr: ui_and_api: ui_and_gem_signin: profiles: - adoptions: - no_ownership_calls: - no_ownership_requests: - title: - subtitle_html: edit: change_avatar: disabled_avatar_html: @@ -847,47 +822,6 @@ fr: imported_gem_version_notice: version: yanked: retiré - adoptions: - index: - title: - subtitle_owner_html: - subtitle_user_html: - ownership_calls: - no_ownership_calls: - ownership_calls: - update: - success_notice: - create: - success_notice: - index: - title: - subtitle_html: - share_requirements: - note_for_applicants: - created_by: - details: - apply: - close: - markup_supported_html: - create_call: - ownership_requests: - create: - success_notice: - update: - approved_notice: - closed_notice: - close: - success_notice: - ownership_requests: - note_for_owners: - your_ownership_requests: - close_all: - approve: - gems_published: - created_at: - no_ownership_requests: - create_req: - signin_to_create_html: webauthn_credentials: callback: success: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index da473912e4e..a0dfbd4cd0a 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -105,11 +105,6 @@ ja: user_id: already_confirmed: は既にこのgemの所有者です already_invited: は既にこのgemに招待されています - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -367,20 +362,6 @@ ja: subtitle: body_html: body_text: - ownerhip_request_closed: - title: 所有権の申請 - subtitle: こんにちは、%{handle}! - body_html: "%{gem}の所有権を申請いただきありがとうございます。心苦しいのですが所有権の申請はgemの所有者により却下されました。" - ownerhip_request_approved: - body_html: おめでとうございます!%{gem}の所有権の申請が許諾されました。gemの所有者として追加されました。 - new_ownership_requests: - body_html: - zero: "%{gem}には新しい所有権の申請がありません。" - one: "%{gem}には1件の新しい所有権の申請があります。申請を見るには以下のボタンをクリックしてください。" - other: "%{gem}には%{count}件の新しい所有権の申請があります。全ての申請を見るには以下のボタンをクリックしてください。" - button: 所有権の申請 - disable_notifications: これらのメッセージの受け取りを停止するには、こちらを更新してください: - owners_page: 所有権 web_hook_deleted: title: webhookが削除されました subject: "%{host}のwebhookが削除されました" @@ -543,7 +524,6 @@ ja: title: Eメール通知 update: 更新 owner_heading: 所有権の通知 - owner_request_heading: 所有権の申請の通知 push_heading: プッシュ通知 webauthn_verifications: expired_or_already_used: 使用されたリンク中のトークンは期限切れか既に使われています。 @@ -634,11 +614,6 @@ ja: ui_and_api: UIとAPI(推奨) ui_and_gem_signin: UIとgemのサインイン profiles: - adoptions: - no_ownership_calls: 所有者の募集を作成しているgemがありません。 - no_ownership_requests: 所有権の申請をしていません。 - title: 引き継ぎ - subtitle_html: 新しい貢献者を募るか所有権を申請してください(詳細) edit: change_avatar: アバターを変更 disabled_avatar_html: プライベートEメール設定のため、既定のアバターが使われています。パーソナライズされたGravatarを有効にするには「公開プロフィールにEメールを表示」を有効にしてください。なおこのようにするとEメールが公開されます。 @@ -808,48 +783,6 @@ ja: imported_gem_version_notice: このgemのバージョンは%{import_date}にRubyGems.orgにインポートされました。表示されている日付は作者によってgemspec中で指定されました。 version: yanked: ヤンク済み - adoptions: - index: - title: 引き継ぎ - subtitle_owner_html: '%{gem} に新しく参加するメンテナを呼び掛ける (詳細)' - subtitle_user_html: '%{gem}の所有権を申請する (詳細)' - ownership_calls: メンテナの募集 - no_ownership_calls: "%{gem}の所有権の募集はありません。gemの所有者は新しいメンテナを探していません。" - ownership_calls: - update: - success_notice: "%{gem}の所有権の募集は修了しました。" - create: - success_notice: "%{gem}への所有権の募集を作成します。" - index: - title: メンテナの募集 - subtitle_html: RubyGemsは新しく参加するメンテナを求めています(詳細) - share_requirements: 手を借りたい領域を共有してください - note_for_applicants: 応募者への補足: - created_by: 作成者 - details: 詳細 - apply: 申請 - close: 却下 - markup_supported_html: Rdocのマークアップに対応しています - create_call: 所有者の募集を作成 - ownership_requests: - create: - success_notice: 所有権の申請が提出されました。 - update: - approved_notice: 所有権の申請が承認されました。%{name}は所有者として追加されました。 - closed_notice: 所有権の申請が却下されました。 - close: - success_notice: "%{gem}への全ての未完了の所有権の申請は却下されました。" - ownership_requests: 所有権の申請 - note_for_owners: 所有者への補足: - your_ownership_requests: 所有権の申請 - close_all: 全て却下 - approve: 承認 - gems_published: gemが公開されました - created_at: 作成日 - no_ownership_requests: プロジェクトへの参加申請はこちらに表示されます。まだ%{gem}への所有権の申請はありません。 - create_req: 所有権の申請を作成 - signin_to_create_html: 所有権の申請を作成するにはサインインしてください。 webauthn_credentials: callback: success: セキュリティ機器が正常に登録されました。 diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 8b80c356537..c4280726b33 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -104,11 +104,6 @@ nl: user_id: already_confirmed: already_invited: - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -363,20 +358,6 @@ nl: subtitle: body_html: body_text: - ownerhip_request_closed: - title: - subtitle: - body_html: - ownerhip_request_approved: - body_html: - new_ownership_requests: - body_html: - zero: - one: - other: - button: - disable_notifications: - owners_page: web_hook_deleted: title: subject: @@ -543,7 +524,6 @@ nl: title: update: owner_heading: - owner_request_heading: push_heading: webauthn_verifications: expired_or_already_used: @@ -634,11 +614,6 @@ nl: ui_and_api: ui_and_gem_signin: profiles: - adoptions: - no_ownership_calls: - no_ownership_requests: - title: - subtitle_html: edit: change_avatar: disabled_avatar_html: @@ -801,47 +776,6 @@ nl: imported_gem_version_notice: version: yanked: verwijderd - adoptions: - index: - title: - subtitle_owner_html: - subtitle_user_html: - ownership_calls: - no_ownership_calls: - ownership_calls: - update: - success_notice: - create: - success_notice: - index: - title: - subtitle_html: - share_requirements: - note_for_applicants: - created_by: - details: - apply: - close: - markup_supported_html: - create_call: - ownership_requests: - create: - success_notice: - update: - approved_notice: - closed_notice: - close: - success_notice: - ownership_requests: - note_for_owners: - your_ownership_requests: - close_all: - approve: - gems_published: - created_at: - no_ownership_requests: - create_req: - signin_to_create_html: webauthn_credentials: callback: success: diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 17f9db3650f..85c15cf9db7 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -111,11 +111,6 @@ pt-BR: user_id: already_confirmed: already_invited: - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -376,20 +371,6 @@ pt-BR: subtitle: body_html: body_text: - ownerhip_request_closed: - title: - subtitle: - body_html: - ownerhip_request_approved: - body_html: - new_ownership_requests: - body_html: - zero: - one: - other: - button: - disable_notifications: - owners_page: web_hook_deleted: title: subject: @@ -555,7 +536,6 @@ pt-BR: title: update: owner_heading: - owner_request_heading: push_heading: webauthn_verifications: expired_or_already_used: @@ -646,11 +626,6 @@ pt-BR: ui_and_api: ui_and_gem_signin: profiles: - adoptions: - no_ownership_calls: - no_ownership_requests: - title: - subtitle_html: edit: change_avatar: Mudar foto de perfil disabled_avatar_html: @@ -825,47 +800,6 @@ pt-BR: imported_gem_version_notice: version: yanked: removida - adoptions: - index: - title: - subtitle_owner_html: - subtitle_user_html: - ownership_calls: - no_ownership_calls: - ownership_calls: - update: - success_notice: - create: - success_notice: - index: - title: - subtitle_html: - share_requirements: - note_for_applicants: - created_by: - details: - apply: - close: - markup_supported_html: - create_call: - ownership_requests: - create: - success_notice: - update: - approved_notice: - closed_notice: - close: - success_notice: - ownership_requests: - note_for_owners: - your_ownership_requests: - close_all: - approve: - gems_published: - created_at: - no_ownership_requests: - create_req: - signin_to_create_html: webauthn_credentials: callback: success: diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 4ccc9effaaa..21c74d4d95d 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -106,11 +106,6 @@ zh-CN: user_id: already_confirmed: already_invited: - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -368,20 +363,6 @@ zh-CN: subtitle: body_html: body_text: - ownerhip_request_closed: - title: 所有权申请驳回 - subtitle: 你好,%{hand}! - body_html: 感谢您申请对 %{gem} 的所有权。我们很遗憾地通知您,您的所有权申请已被该 Gem 的所有者驳回。 - ownerhip_request_approved: - body_html: 恭喜您!您对 %{gem} 的所有权申请已被批准。您已被添加为该 Gem 的所有者之一。 - new_ownership_requests: - body_html: - zero: - one: - other: "%{gem}%{count} 个新的所有权申请。请点击下面的按钮查看所有请求。" - button: 所有权申请 - disable_notifications: 要停止接收这些信息,请更新您的 - owners_page: 所有权 web_hook_deleted: title: 删除 Webhook subject: 您的 RubyGems.org Webhook 已被删除 @@ -548,7 +529,6 @@ zh-CN: title: 邮件通知 update: 更新 owner_heading: 所有权通知 - owner_request_heading: 所有权申请通知 push_heading: 推送通知 webauthn_verifications: expired_or_already_used: 您链接中使用的的令牌已过期或已被使用。 @@ -641,11 +621,6 @@ zh-CN: ui_and_api: UI 和 API(推荐使用) ui_and_gem_signin: UI 和 Gem 签署 profiles: - adoptions: - no_ownership_calls: 您没有为您的任何 Gem 创建任何所有权的调用。 - no_ownership_requests: 您没有创建任何所有权申请。 - title: 领养 - subtitle_html: 寻求新的维护者或申请所有权 (了解更多) edit: change_avatar: 修改头像 disabled_avatar_html: @@ -814,48 +789,6 @@ zh-CN: gemspec 中指定。 version: yanked: 已撤回 - adoptions: - index: - title: 领养 - subtitle_owner_html: 请新的维护者加入 %{gem} (了解更多) - subtitle_user_html: 申请对 %{gem} 的所有权 (了解更多) - ownership_calls: 所有权调用 - no_ownership_calls: 没有对 %{gem} 的所有权调用。该 Gem 并没有在寻求新的维护者。 - ownership_calls: - update: - success_notice: 对 %{gem} 的所有权调用已关闭。 - create: - success_notice: 已创建对 %{gem} 的所有权调用。 - index: - title: 维护者招募 - subtitle_html: RubyGems 正在寻找新的维护者加入 (了解更多) - share_requirements: 请分享您在哪些方面需要帮助 - note_for_applicants: 申请人须知: - created_by: 创建 - details: 详情 - apply: 申请 - close: 关闭 - markup_supported_html: 支持 Rdoc - 标记语法 - create_call: 创建所有权调用 - ownership_requests: - create: - success_notice: 您的所有权申请已经被提交 - update: - approved_notice: 所有权申请已被批准。%{name} 已被添加为新的所有者之一。 - closed_notice: 所有权申请已经被关闭。 - close: - success_notice: 对 %{gem} 的所有开放所有权申请都已被关闭。 - ownership_requests: 所有权申请 - note_for_owners: 所有者须知: - your_ownership_requests: 您的所有权申请 - close_all: 关闭所有 - approve: 批准 - gems_published: 已发布的 Gem - created_at: 创建于 - no_ownership_requests: 加入您项目的申请将显示在这里。还没有对 %{gem} 的所有权申请。 - create_req: 创建所有权申请 - signin_to_create_html: 请 登录 来新建一个所有权申请。 webauthn_credentials: callback: success: 您已成功注册一个安全设备。 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 8d051bfeb67..82c6b95c1f5 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -105,11 +105,6 @@ zh-TW: user_id: already_confirmed: 已是此 Gem 的擁有者 already_invited: 已獲邀加入此 Gem - ownership_request: - attributes: - user_id: - taken: - existing: user: attributes: handle: @@ -363,20 +358,6 @@ zh-TW: subtitle: body_html: body_text: - ownerhip_request_closed: - title: 所有權請求 - subtitle: 嗨 %{handle}! - body_html: 感謝您申請 %{gem} 的所有權。我們很遺憾地通知您,您的所有權請求已被 Gem 擁有者關閉。 - ownerhip_request_approved: - body_html: 恭喜!您對 %{gem} 的所有權請求已通過。您已加入 Gem 的擁有者名單。 - new_ownership_requests: - body_html: - zero: - one: - other: "%{gem}%{count} 項新所有權請求。請點擊下方按鈕來查看所有請求。" - button: 所有權請求 - disable_notifications: 若要停止接收這些訊息,請更新您的 - owners_page: 所有權 web_hook_deleted: title: Webhook 遭刪除 subject: 您在 RubyGems.org 上的 Webhook 遭到刪除 @@ -543,7 +524,6 @@ zh-TW: title: 電子郵件通知 update: 更新 owner_heading: 所有權通知 - owner_request_heading: 所有權請求通知 push_heading: 推送通知 webauthn_verifications: expired_or_already_used: 您所使用的連結中的權杖已過期或被使用。 @@ -635,11 +615,6 @@ zh-TW: ui_and_api: 使用者介面與 API (建議) ui_and_gem_signin: 使用者介面和 Gem 登入 profiles: - adoptions: - no_ownership_calls: - no_ownership_requests: 您尚未建立任何所有權請求。 - title: 認養 - subtitle_html: 請求新維護者或所有權 (了解詳情) edit: change_avatar: disabled_avatar_html: @@ -804,49 +779,6 @@ zh-TW: gemspec 指定。 version: yanked: 已被移除 - adoptions: - index: - title: 認養 - subtitle_owner_html: 請求新的維護者加入 %{gem} (read - more) - subtitle_user_html: - ownership_calls: - no_ownership_calls: - ownership_calls: - update: - success_notice: - create: - success_notice: - index: - title: 徵求維護者 - subtitle_html: RubyGems 正在尋找新的維護者加入團隊 (了解詳情) - share_requirements: 請說明您需要哪方面的協助 - note_for_applicants: - created_by: 建立者 - details: - apply: 申請 - close: 關閉 - markup_supported_html: 支援 - Rdoc 標記語言 - create_call: - ownership_requests: - create: - success_notice: 您的所有權請求已送出。 - update: - approved_notice: 所有權請求已核准。%{name} 已加入擁有者名單。 - closed_notice: - close: - success_notice: - ownership_requests: 所有權請求 - note_for_owners: - your_ownership_requests: 您的所有權請求 - close_all: 全部關閉 - approve: - gems_published: 已發布的 Gems - created_at: 建立於 - no_ownership_requests: 您的專案的加入請求將在此顯示。 - create_req: 建立所有權請求 - signin_to_create_html: webauthn_credentials: callback: success: 您已成功註冊安全裝置。 diff --git a/config/routes.rb b/config/routes.rb index 7207d02133b..c31ca97e2fe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -171,7 +171,6 @@ resource :totp, only: %i[new create destroy] resource :settings, only: :edit resource :profile, only: %i[edit update] do - get :adoptions get :security_events member do get :delete @@ -219,17 +218,9 @@ get 'confirm', to: 'owners#confirm', as: :confirm, on: :collection get 'resend_confirmation', to: 'owners#resend_confirmation', as: :resend_confirmation, on: :collection end - resource :ownership_calls, only: %i[update create] do - patch 'close', to: 'ownership_calls#close', as: :close, on: :collection - end - resources :ownership_requests, only: %i[create update] do - patch 'close_all', to: 'ownership_requests#close_all', as: :close_all, on: :collection - end - resources :adoptions, only: %i[index] resources :trusted_publishers, controller: 'oidc/rubygem_trusted_publishers', only: %i[index create destroy new] end - resources :ownership_calls, only: :index resources :webauthn_credentials, only: :destroy resource :webauthn_verification, only: [] do get 'successful_verification' diff --git a/db/seeds.rb b/db/seeds.rb index 7af1eed39f6..99f6b90820c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -19,12 +19,6 @@ email_confirmed: true ).find_or_create_by!(email: "gem-user@example.com") -requester = User.create_with( - handle: "gem-requester", - password: password, - email_confirmed: true -).find_or_create_by!(email: "gem-requester@example.com") - User.create_with( handle: "gem-security", email_confirmed: true, @@ -44,23 +38,6 @@ rubygem.ownerships.new(user: maintainer, authorizer: author).confirm! end -rubygem_requestable = Rubygem.find_or_create_by!( - name: "rubygem_requestable" -) do |rubygem| - rubygem.ownerships.new(user: author, authorizer: author).confirm! -end - -rubygem_requestable.ownership_calls.create_with( - note: "closed ownership call note!", - status: :closed -).find_or_create_by!(user: author) -rubygem_requestable.ownership_calls.create_with( - note: "open ownership call note!" -).find_or_create_by!(user: author) -rubygem_requestable.ownership_requests.create_with( - note: "open ownership request" -).find_or_create_by!(ownership_call: rubygem_requestable.ownership_call, user: requester) - Version.create_with( indexed: true, pusher: author, @@ -99,7 +76,7 @@ pusher: author, yanked_at: Time.utc(2020, 3, 3), sha256: Digest::SHA2.base64digest("rubygem_requestable-1.0.0.gem") -).find_or_create_by!(rubygem: rubygem_requestable, number: "1.0.0", platform: "ruby", gem_platform: "ruby") +).find_or_create_by!(rubygem: rubygem1, number: "1.0.0", platform: "ruby", gem_platform: "ruby") user.web_hooks.find_or_create_by!(url: "https://example.com/rubygem0", rubygem: rubygem0) user.web_hooks.find_or_create_by!(url: "http://example.com/all", rubygem: nil) @@ -325,5 +302,4 @@ - email: #{author.email}, password: #{password} -> gem author owning few example gems - email: #{maintainer.email}, password: #{password} -> gem maintainer having push access to one author's example gem - email: #{user.email}, password: #{password} -> user with no gems - - email: #{requester.email}, password: #{password} -> user with an ownership request MESSAGE diff --git a/lib/tasks/ownership_requests_mailer.rake b/lib/tasks/ownership_requests_mailer.rake deleted file mode 100644 index 4bcc90b3f04..00000000000 --- a/lib/tasks/ownership_requests_mailer.rake +++ /dev/null @@ -1,15 +0,0 @@ -namespace :ownership_request_notification do - desc "Send email notification about ownership requests to the owners" - task send: :environment do - gems_with_requests = OwnershipRequest.where(created_at: 24.hours.ago..Time.current).pluck(:rubygem_id).uniq - return unless gems_with_requests - - gems_with_requests.each do |rubygem_id| - rubygem = Rubygem.find(rubygem_id) - - rubygem.ownership_request_notifiable_owners.each do |user| - OwnersMailer.new_ownership_requests(rubygem_id, user.id).deliver_later - end - end - end -end diff --git a/test/factories/ownership_call.rb b/test/factories/ownership_call.rb deleted file mode 100644 index 94326189ac3..00000000000 --- a/test/factories/ownership_call.rb +++ /dev/null @@ -1,10 +0,0 @@ -FactoryBot.define do - factory :ownership_call do - rubygem - user - note { "small note" } - trait :closed do - status { "closed" } - end - end -end diff --git a/test/factories/ownership_request.rb b/test/factories/ownership_request.rb deleted file mode 100644 index ccf5de19f00..00000000000 --- a/test/factories/ownership_request.rb +++ /dev/null @@ -1,19 +0,0 @@ -FactoryBot.define do - factory :ownership_request do - rubygem - user - note { "small note here" } - status { "opened" } - approver { nil } - trait :approved do - approver { user } - status { "approved" } - end - trait :closed do - status { "closed" } - end - trait :with_ownership_call do - ownership_call - end - end -end diff --git a/test/functional/adoptions_controller_test.rb b/test/functional/adoptions_controller_test.rb deleted file mode 100644 index 33fb98b98da..00000000000 --- a/test/functional/adoptions_controller_test.rb +++ /dev/null @@ -1,148 +0,0 @@ -require "test_helper" - -class AdoptionsControllerTest < ActionController::TestCase - context "on GET to index" do - setup do - @user = create(:user) - end - context "signed user is owner of rubygem" do - setup do - @rubygem = create(:rubygem, owners: [@user], downloads: 2_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - sign_in_as @user - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - context "ownership call exists" do - setup do - @ownership_call = create(:ownership_call, rubygem: @rubygem, user: @user, note: "example call") - end - - context "ownership request exists" do - setup do - @ownership_request = create(:ownership_request, rubygem: @rubygem, ownership_call: @ownership_call, note: "example request") - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "have button for approve and close all ownership requests" do - assert page.has_content?("example request") - assert page.has_selector?("button[type='submit']", text: "Close") - assert page.has_selector?("button[type='submit']", text: "Close all") - end - end - - context "ownership request doesn't exist" do - setup do - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "have button to close ownership call" do - assert page.has_content?("example call") - assert page.has_selector?("button[type='submit']", text: "Close") - end - end - end - - context "ownership call doesn't exist" do - context "ownership request exists" do - setup do - @ownership_request = create(:ownership_request, rubygem: @rubygem) - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "have button to create ownership call" do - assert page.has_selector?("input[value='Create ownership call']") - end - end - - context "ownership request doesn't exist" do - setup do - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "not show any ownership request" do - assert page.has_content?("No ownership requests for #{@rubygem.name}") - end - end - end - end - - context "signed in user is not owner of rubygem" do - setup do - @rubygem = create(:rubygem, downloads: 2_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - sign_in_as @user - end - context "ownership call exists" do - setup do - @ownership_call = create(:ownership_call, rubygem: @rubygem) - end - - context "ownership request by user exists" do - setup do - @ownership_request = create(:ownership_request, rubygem: @rubygem, ownership_call: @ownership_call, user: @user, note: "example request") - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - should "have button to close ownership request" do - assert page.has_content?("example request") - assert page.has_selector?("button[type='submit']", text: "Close") - end - end - - context "ownership request doesn't exist" do - setup do - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "have button to create ownership request" do - assert page.has_selector?("input[value='Create ownership request']") - end - end - end - - context "ownership call doesn't exist" do - setup do - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "not show any ownership request" do - assert page.has_content?("There are no ownership calls for #{@rubygem.name}") - end - end - end - - context "user is not signed in" do - context "ownership call and request exits" do - setup do - @rubygem = create(:rubygem, downloads: 2_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - @ownership_call = create(:ownership_call, rubygem: @rubygem, note: "example call") - @ownership_request = create(:ownership_request, rubygem: @rubygem, ownership_call: @ownership_call, user: @user, note: "example request") - get :index, params: { rubygem_id: @rubygem.name } - end - - should respond_with :success - should "not show ownership request or create button" do - refute page.has_content?("example request") - refute page.has_selector?("input[value='Create']") - end - should "show ownership call" do - assert page.has_content?("example call") - end - end - end - end -end diff --git a/test/functional/multifactor_auths_controller_test.rb b/test/functional/multifactor_auths_controller_test.rb index aab7a260730..a3ad88f4ed6 100644 --- a/test/functional/multifactor_auths_controller_test.rb +++ b/test/functional/multifactor_auths_controller_test.rb @@ -654,8 +654,7 @@ class MultifactorAuthsControllerTest < ActionController::TestCase Rubygem::MFA_REQUIRED_THRESHOLD + 1, rubygem_id: @rubygem.id ) - @redirect_paths = [adoptions_profile_path, - dashboard_path, + @redirect_paths = [dashboard_path, delete_profile_path, edit_profile_path, new_profile_api_key_path, diff --git a/test/functional/ownership_calls_controller_test.rb b/test/functional/ownership_calls_controller_test.rb deleted file mode 100644 index e53d1e3e5d1..00000000000 --- a/test/functional/ownership_calls_controller_test.rb +++ /dev/null @@ -1,373 +0,0 @@ -require "test_helper" - -class OwnershipCallsControllerTest < ActionController::TestCase - context "When logged in" do - setup do - @user = create(:user) - sign_in_as(@user) - end - - teardown do - sign_out - end - - context "on POST to create" do - setup do - @rubygem = create(:rubygem, owners: [@user], number: "1.0.0") - end - - context "user is owner of rubygem and verified" do - setup do - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - context "with correct params" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "short note" } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should "set success notice flash" do - expected_notice = "Created ownership call for #{@rubygem.name}." - - assert_equal expected_notice, flash[:notice] - end - should "create a call" do - assert_not_nil @rubygem.ownership_calls.find_by(user: @user) - end - end - - context "with params missing" do - setup do - post :create, params: { rubygem_id: @rubygem.name } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should "set alert flash" do - expected_alert = "Note can't be blank" - - assert_equal expected_alert, flash[:alert] - end - should "not create a call" do - assert_nil @rubygem.ownership_calls.find_by(user: @user) - end - end - - context "when call is already open" do - setup do - create(:ownership_call, rubygem: @rubygem) - post :create, params: { rubygem_id: @rubygem.name, note: "other small note" } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should "set alert flash" do - expected_alert = "Rubygem can have only one open ownership call" - - assert_equal expected_alert, flash[:alert] - end - should "not create a call" do - assert_equal 1, @rubygem.ownership_calls.count - end - end - end - - context "user is owner and not verified" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "short note" } - end - - should redirect_to("verify page") { verify_session_path } - end - - context "user is not owner of rubygem" do - setup do - @user = create(:user) - sign_in_as(@user) - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - post :create, params: { rubygem_id: @rubygem.name, note: "short note" } - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - should respond_with :forbidden - - should "not create a call" do - assert_nil @rubygem.ownership_calls.find_by(user: @user) - end - end - end - - context "on PATCH to close" do - setup do - @rubygem = create(:rubygem, owners: [@user], number: "1.0.0") - end - - context "user is owner of rubygem and verified" do - setup do - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - context "ownership call exists" do - setup do - create(:ownership_call, rubygem: @rubygem, user: @user, status: "opened") - patch :close, params: { rubygem_id: @rubygem.name } - end - should redirect_to("rubygems show") { rubygem_path(@rubygem.slug) } - should "set success notice flash" do - expected_notice = "The ownership call for #{@rubygem.name} was closed." - - assert_equal expected_notice, flash[:notice] - end - should "update status to close" do - assert_empty @rubygem.ownership_calls - end - end - - context "ownership call does not exist" do - setup do - patch :close, params: { rubygem_id: @rubygem.name } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - - should "set try again notice flash" do - assert_equal "Something went wrong. Please try again.", flash[:alert] - end - end - end - - context "user is owner and not verified" do - setup do - create(:ownership_call, rubygem: @rubygem, user: @user) - patch :close, params: { rubygem_id: @rubygem.name } - end - - should redirect_to("verify page") { verify_session_path } - end - - context "user is not owner of rubygem" do - setup do - @user = create(:user) - sign_in_as(@user) - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - - create(:ownership_call, rubygem: @rubygem, user: @user) - patch :close, params: { rubygem_id: @rubygem.name } - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - should respond_with :forbidden - - should "not update status to close" do - assert_not_empty @rubygem.ownership_calls - end - end - end - - context "when user owns a gem with more than MFA_REQUIRED_THRESHOLD downloads" do - setup do - @rubygem = create(:rubygem) - create(:ownership, rubygem: @rubygem, user: @user) - GemDownload.increment( - Rubygem::MFA_REQUIRED_THRESHOLD + 1, - rubygem_id: @rubygem.id - ) - end - - context "user has mfa disabled" do - context "on GET to index" do - setup do - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "not redirect to mfa" do - assert page.has_content? "Maintainers wanted" - end - end - - context "on PATCH to close" do - setup do - patch :close, params: { rubygem_id: @rubygem.name } - end - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal close_rubygem_ownership_calls_path, session[:mfa_redirect_uri] - end - end - - context "on POST to create" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "short note" } - end - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_calls_path, session[:mfa_redirect_uri] - end - end - end - - context "user has mfa set to weak level" do - setup do - @user.enable_totp!(ROTP::Base32.random_base32, :ui_only) - end - - context "on GET to index" do - setup do - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "not redirect to mfa" do - assert page.has_content? "Maintainers wanted" - end - end - - context "on PATCH to close" do - setup do - patch :close, params: { rubygem_id: @rubygem.name } - end - should redirect_to("edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal close_rubygem_ownership_calls_path, session[:mfa_redirect_uri] - end - end - - context "on POST to create" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "short note" } - end - should redirect_to("edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_calls_path, session[:mfa_redirect_uri] - end - end - end - - context "user has MFA set to strong level, expect normal behaviour" do - setup do - @user.enable_totp!(ROTP::Base32.random_base32, :ui_and_api) - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - context "on GET to index" do - setup do - get :index, params: { rubygem_id: @rubygem.name } - end - should respond_with :success - - should "not redirect to mfa" do - assert page.has_content? "Maintainers wanted" - end - end - - context "on PATCH to close" do - setup do - create(:ownership_call, rubygem: @rubygem, user: @user, status: "opened") - patch :close, params: { rubygem_id: @rubygem.name } - end - should redirect_to("rubygems show") { rubygem_path(@rubygem.slug) } - end - - context "on POST to create" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "short note" } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - end - end - end - end - - context "When user not logged in" do - context "on POST to create" do - setup do - @rubygem = create(:rubygem, number: "1.0.0") - post :create, params: { rubygem_id: @rubygem.name, note: "short note" } - end - - should "redirect to sign in" do - assert_redirected_to sign_in_path - end - should "not create call" do - assert_empty @rubygem.ownership_calls - end - end - - context "on PATCH to close" do - setup do - @rubygem = create(:rubygem, number: "1.0.0") - create(:ownership_call, rubygem: @rubygem) - patch :close, params: { rubygem_id: @rubygem.name } - end - - should "redirect to sign in" do - assert_redirected_to sign_in_path - end - should "not close the call" do - assert_not_empty @rubygem.ownership_calls - end - end - - context "on GET to index" do - setup do - rubygems = create_list(:rubygem, 3, number: "1.0.0") - @ownership_calls = [] - rubygems.each do |rubygem| - @ownership_calls << create(:ownership_call, rubygem: rubygem) - end - get :index - end - should respond_with :success - should "not include closed calls" do - ownership_call = create(:ownership_call, :closed) - - refute page.has_content? ownership_call.rubygem_name - end - should "order calls by created date" do - expected_order = @ownership_calls.reverse.map(&:rubygem_name) - actual_order = assert_select("a.gems__gem__name").map(&:text) - - expected_order.each_with_index do |expected_gem_name, i| - assert_match(/#{expected_gem_name}/, actual_order[i]) - end - end - - should "display entries and total in page info" do - assert_select "header > p.gems__meter", text: /Displaying all 3 ownership calls/ - end - should "display correct number of entries" do - entries = assert_select("a.gems__gem__name") - - assert_equal 3, entries.size - end - end - end -end diff --git a/test/functional/ownership_requests_controller_test.rb b/test/functional/ownership_requests_controller_test.rb deleted file mode 100644 index 2a29093de1d..00000000000 --- a/test/functional/ownership_requests_controller_test.rb +++ /dev/null @@ -1,480 +0,0 @@ -require "test_helper" - -class OwnershipRequestsControllerTest < ActionController::TestCase - include ActionMailer::TestHelper - - context "when logged in" do - setup do - @user = create(:user) - sign_in_as(@user) - end - - context "on POST to create" do - context "for popular gem" do - setup do - @rubygem = create(:rubygem, downloads: 2_000_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago, number: "1.0.0") - end - context "when user is owner" do - setup do - create(:ownership, user: @user, rubygem: @rubygem) - post :create, params: { rubygem_id: @rubygem.name, note: "small note" } - end - - should respond_with :forbidden - - should "not create ownership request" do - assert_nil @rubygem.ownership_requests.find_by(user: @user) - end - end - - context "when user is not an owner" do - context "ownership call exists" do - setup do - create(:ownership_call, rubygem: @rubygem) - post :create, params: { rubygem_id: @rubygem.name, note: "small note" } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - - should "create ownership request" do - assert_not_nil @rubygem.ownership_requests.find_by(user: @user) - end - end - - context "ownership call doesn't exist" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "small note" } - end - should respond_with :forbidden - - should "not create ownership request" do - assert_nil @rubygem.ownership_requests.find_by(user: @user) - end - end - end - end - - context "for less popular gem" do - setup do - @rubygem = create(:rubygem, downloads: 2_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago, number: "1.0.0") - end - - context "when user is owner" do - setup do - create(:ownership, user: @user, rubygem: @rubygem) - post :create, params: { rubygem_id: @rubygem.name, note: "small note" } - end - - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should set_flash[:alert].to("User is already an owner") - - should "not create ownership call" do - assert_nil @rubygem.ownership_requests.find_by(user: @user) - end - end - - context "when user is not an owner" do - context "with correct params" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "small note" } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should set_flash[:notice].to("Your ownership request was submitted.") - - should "create ownership request" do - assert_not_nil @rubygem.ownership_requests.find_by(user: @user) - end - end - context "with missing params" do - setup do - post :create, params: { rubygem_id: @rubygem.name } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should set_flash[:alert].to("Note can't be blank") - - should "not create ownership call" do - assert_nil @rubygem.ownership_requests.find_by(user: @user) - end - end - context "when request from user exists" do - setup do - create(:ownership_request, rubygem: @rubygem, user: @user, note: "other note") - post :create, params: { rubygem_id: @rubygem.name, note: "new note" } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should set_flash[:alert].to("User has already requested ownership") - end - end - end - end - - context "on PATCH to update" do - setup do - @rubygem = create(:rubygem, downloads: 2_000_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago, number: "1.0.0") - end - context "when user is owner and verified" do - setup do - create(:ownership, user: @user, rubygem: @rubygem) - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - context "on close" do - setup do - @requester = create(:user) - ownership_request = create(:ownership_request, rubygem: @rubygem, user: @requester) - perform_enqueued_jobs only: ActionMailer::MailDeliveryJob do - patch :update, params: { rubygem_id: @rubygem.name, id: ownership_request.id, status: "close" } - end - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should "set success notice flash" do - expected_notice = "Ownership request was closed." - - assert_equal expected_notice, flash[:notice] - end - should "send email notifications" do - assert_emails 1 - assert_equal "Your ownership request was closed.", last_email.subject - assert_equal [@requester.email], last_email.to - end - end - - context "on approve" do - setup do - @requester = create(:user) - ownership_request = create(:ownership_request, rubygem: @rubygem, user: @requester) - perform_enqueued_jobs only: ActionMailer::MailDeliveryJob do - patch :update, params: { rubygem_id: @rubygem.name, id: ownership_request.id, status: "approve" } - end - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should "set success notice flash" do - expected_notice = "Ownership request was approved. #{@user.display_id} is added as an owner." - - assert_equal expected_notice, flash[:notice] - end - should "add ownership record" do - ownership = Ownership.find_by(rubygem: @rubygem, user: @requester) - - refute_nil ownership - assert_predicate ownership, :confirmed? - end - should "send email notification" do - assert_emails 3 - request_approved_subjects = ActionMailer::Base.deliveries.map(&:subject) - - assert_contains request_approved_subjects, "Your ownership request was approved." - assert_contains request_approved_subjects, "User #{@requester.handle} was added as an owner to #{@rubygem.name} gem" - - owner_removed_email_to = ActionMailer::Base.deliveries.map(&:to).flatten.uniq - - assert_same_elements @rubygem.owners.pluck(:email), owner_removed_email_to - end - end - - context "on incorrect status" do - setup do - @requester = create(:user) - request = create(:ownership_request, rubygem: @rubygem, user: @requester) - patch :update, params: { rubygem_id: @rubygem.name, id: request.id, status: "random" } - end - - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - - should "set try again flash" do - assert_equal "Something went wrong. Please try again.", flash[:alert] - end - end - end - - context "when user is owner and not verified" do - setup do - create(:ownership, user: @user, rubygem: @rubygem) - @requester = create(:user) - ownership_request = create(:ownership_request, rubygem: @rubygem, user: @requester) - patch :update, params: { rubygem_id: @rubygem.name, id: ownership_request.id, status: "close" } - end - should redirect_to("verify page") { verify_session_path } - end - - context "when user is not an owner" do - setup do - request = create(:ownership_request, rubygem: @rubygem) - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - patch :update, params: { rubygem_id: @rubygem.name, id: request.id, status: "close" } - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - should respond_with :forbidden - end - end - - context "on PATCH to close_all" do - setup do - @rubygem = create(:rubygem, downloads: 2_000_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago, number: "1.0.0") - end - context "when user is owner and verified" do - setup do - create(:ownership, rubygem: @rubygem, user: @user) - create_list(:ownership_request, 3, rubygem: @rubygem) - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - context "with successful update" do - setup do - patch :close_all, params: { rubygem_id: @rubygem.name } - end - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should "set success notice flash" do - expected_notice = "All open ownership requests for #{@rubygem.name} were closed." - - assert_equal expected_notice, flash[:notice] - end - should "close all open requests" do - assert_empty @rubygem.ownership_requests - end - end - - context "with unsuccessful update" do - setup do - OwnershipRequest.any_instance.stubs(:update!).raises(ActiveRecord::RecordNotSaved) - patch :close_all, params: { rubygem_id: @rubygem.name } - end - - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - should "set success notice flash" do - expected_notice = "Something went wrong. Please try again." - - assert_equal expected_notice, flash[:alert] - end - end - end - - context "when user is owner and not verified" do - setup do - create(:ownership, rubygem: @rubygem, user: @user) - patch :close_all, params: { rubygem_id: @rubygem.name } - end - should redirect_to("verify page") { verify_session_path } - end - - context "user is not owner" do - setup do - create_list(:ownership_request, 3, rubygem: @rubygem) - patch :close_all, params: { rubygem_id: @rubygem.name } - end - - should respond_with :forbidden - - should "not close all open requests" do - assert_equal 3, @rubygem.ownership_requests.count - end - end - end - - context "when user owns a gem with more than MFA_REQUIRED_THRESHOLD downloads" do - setup do - @mfa_rubygem = create(:rubygem) - create(:ownership, rubygem: @mfa_rubygem, user: @user) - GemDownload.increment( - Rubygem::MFA_REQUIRED_THRESHOLD + 1, - rubygem_id: @mfa_rubygem.id - ) - @rubygem = create(:rubygem) - create(:ownership_call, rubygem: @rubygem) - @ownership_request = create(:ownership_request) - end - - context "user has mfa disabled" do - context "POST to create" do - setup { post :create, params: { rubygem_id: @rubygem.name, note: "small note" } } - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_requests_path, session[:mfa_redirect_uri] - end - end - - context "PATCH to close_all" do - setup { patch :close_all, params: { rubygem_id: @rubygem.name } } - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal close_all_rubygem_ownership_requests_path, session[:mfa_redirect_uri] - end - end - - context "PATCH to update" do - setup { patch :update, params: { rubygem_id: @rubygem.name, id: @ownership_request.id, status: "closed" } } - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_request_path, session[:mfa_redirect_uri] - end - end - - context "PUT to update" do - setup { put :update, params: { rubygem_id: @rubygem.name, id: @ownership_request.id, status: "closed" } } - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_request_path, session[:mfa_redirect_uri] - end - end - end - - context "user has mfa set to weak level" do - setup do - @user.enable_totp!(ROTP::Base32.random_base32, :ui_only) - end - - context "POST to create" do - setup { post :create, params: { rubygem_id: @rubygem.name, note: "small note" } } - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_requests_path, session[:mfa_redirect_uri] - end - end - - context "PATCH to close_all" do - setup do - patch :close_all, params: { rubygem_id: @rubygem.name } - end - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal close_all_rubygem_ownership_requests_path, session[:mfa_redirect_uri] - end - end - - context "PATCH to update" do - setup { patch :update, params: { rubygem_id: @rubygem.name, id: @ownership_request.id, status: "closed" } } - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_request_path, session[:mfa_redirect_uri] - end - end - - context "PUT to update" do - setup { put :update, params: { rubygem_id: @rubygem.name, id: @ownership_request.id, status: "closed" } } - - should redirect_to("the edit settings page") { edit_settings_path } - - should "set mfa_redirect_uri" do - assert_equal rubygem_ownership_request_path, session[:mfa_redirect_uri] - end - end - end - - context "user has MFA set to strong level, expect normal behaviour" do - setup do - @user.enable_totp!(ROTP::Base32.random_base32, :ui_and_api) - session[:verification] = 10.minutes.from_now - session[:verified_user] = @user.id - end - - teardown do - session[:verification] = nil - session[:verified_user] = nil - end - - context "POST to create" do - setup { post :create, params: { rubygem_id: @rubygem.name, note: "small note" } } - - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - end - - context "PATCH to close_all" do - setup do - create(:version, rubygem: @rubygem, created_at: 2.years.ago, number: "1.0.0") - create(:ownership, rubygem: @rubygem, user: @user) - create_list(:ownership_request, 3, rubygem: @rubygem) - - patch :close_all, params: { rubygem_id: @rubygem.name } - end - - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - end - - context "PATCH to update" do - setup do - @requester = create(:user) - create(:ownership_request, rubygem: @rubygem, user: @requester) - patch :update, params: { rubygem_id: @rubygem.name, id: @ownership_request.id, status: "closed" } - end - - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - end - - context "PUT to update" do - setup do - @requester = create(:user) - create(:ownership_request, rubygem: @rubygem, user: @requester) - put :update, params: { rubygem_id: @rubygem.name, id: @ownership_request.id, status: "closed" } - end - - should redirect_to("adoptions index") { rubygem_adoptions_path(@rubygem.slug) } - end - end - end - end - - context "when not logged in" do - setup do - @rubygem = create(:rubygem, downloads: 2_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago, number: "1.0.0") - end - - context "on POST to create" do - setup do - post :create, params: { rubygem_id: @rubygem.name, note: "small note" } - end - should redirect_to("sign in") { sign_in_path } - end - - context "on PATCH to update" do - setup do - ownership_request = create(:ownership_request) - patch :update, params: { rubygem_id: ownership_request.rubygem_name, id: ownership_request.id, status: "closed" } - end - should redirect_to("sign in") { sign_in_path } - end - - context "on PATCH to close_all" do - setup do - create_list(:ownership_request, 3, rubygem: @rubygem) - patch :close_all, params: { rubygem_id: @rubygem.name } - end - should redirect_to("sign in") { sign_in_path } - end - end -end diff --git a/test/functional/profiles_controller_test.rb b/test/functional/profiles_controller_test.rb index 0cb3ab5a29d..79d96b721a5 100644 --- a/test/functional/profiles_controller_test.rb +++ b/test/functional/profiles_controller_test.rb @@ -349,7 +349,6 @@ class ProfilesControllerTest < ActionController::TestCase end redirect_scenarios = { - "GET to adoptions" => { action: :adoptions, request: { method: "GET", params: { id: 1 } }, path: "/profile/adoptions" }, "GET to delete" => { action: :delete, request: { method: "GET", params: { id: 1 } }, path: "/profile/delete" }, "DELETE to destroy" => { action: :destroy, request: { method: "DELETE", params: { id: 1 } }, path: "/profile" }, "GET to edit" => { action: :edit, request: { method: "GET", params: { id: 1 } }, path: "/profile/edit" }, @@ -420,15 +419,6 @@ class ProfilesControllerTest < ActionController::TestCase assert page.has_content? "Edit Profile" end end - - context "on GET to adoptions" do - setup { get :adoptions, params: { id: @user.id } } - - should "not redirect to mfa" do - assert_response :success - refute page.has_content? "multi-factor" - end - end end end end diff --git a/test/helpers/adoption_helpers.rb b/test/helpers/adoption_helpers.rb deleted file mode 100644 index 6df90a7500f..00000000000 --- a/test/helpers/adoption_helpers.rb +++ /dev/null @@ -1,9 +0,0 @@ -module AdoptionHelpers - def visit_rubygem_adoptions_path(rubygem, user) - visit rubygem_adoptions_path(rubygem.slug, as: user) - return unless page.has_css? "#verify_password_password" - - fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD - click_button "Confirm" - end -end diff --git a/test/helpers/rate_limit_helpers.rb b/test/helpers/rate_limit_helpers.rb index fba31c815f2..04e0634d5c6 100644 --- a/test/helpers/rate_limit_helpers.rb +++ b/test/helpers/rate_limit_helpers.rb @@ -60,10 +60,6 @@ def stay_under_email_limit_for(scope) update_limit_for("#{scope}:#{@user.email}", under_email_limit) end - def stay_under_ownership_request_limit_for(scope) - update_limit_for("#{scope}:#{@user.email}", under_email_limit, Rack::Attack::REQUEST_LIMIT_PERIOD) - end - def stay_under_push_limit_for(scope) under_push_limit = (Rack::Attack::PUSH_LIMIT * 0.5).to_i update_limit_for("#{scope}:#{@user.email}", under_push_limit) @@ -111,10 +107,6 @@ def expected_retry_after(level) (period - (now % period)).to_s end - def exceed_ownership_request_limit_for(scope) - update_limit_for("#{scope}:#{@user.email}", exceeding_email_limit, Rack::Attack::REQUEST_LIMIT_PERIOD) - end - def assert_throttle_at(level) assert_response :too_many_requests assert_equal expected_retry_after(level), @response.headers["Retry-After"] diff --git a/test/integration/notification_settings_test.rb b/test/integration/notification_settings_test.rb index 6737b8f4386..8b52edd7287 100644 --- a/test/integration/notification_settings_test.rb +++ b/test/integration/notification_settings_test.rb @@ -26,14 +26,9 @@ class NotificationSettingsTest < SystemTest assert_unchecked_field notifier_off_radio(ownership1, "owner") assert_checked_field notifier_on_radio(ownership2, "owner") assert_unchecked_field notifier_off_radio(ownership2, "owner") - assert_checked_field notifier_on_radio(ownership1, "ownership_request") - assert_unchecked_field notifier_off_radio(ownership1, "ownership_request") - assert_checked_field notifier_on_radio(ownership2, "ownership_request") - assert_unchecked_field notifier_off_radio(ownership2, "ownership_request") choose notifier_off_radio(ownership1, "push") choose notifier_off_radio(ownership2, "owner") - choose notifier_off_radio(ownership2, "ownership_request") perform_enqueued_jobs only: ActionMailer::MailDeliveryJob do click_button I18n.t("notifiers.show.update") @@ -55,10 +50,6 @@ class NotificationSettingsTest < SystemTest assert_unchecked_field notifier_off_radio(ownership1, "owner") assert_unchecked_field notifier_on_radio(ownership2, "owner") assert_checked_field notifier_off_radio(ownership2, "owner") - assert_checked_field notifier_on_radio(ownership1, "ownership_request") - assert_unchecked_field notifier_off_radio(ownership1, "ownership_request") - assert_unchecked_field notifier_on_radio(ownership2, "ownership_request") - assert_checked_field notifier_off_radio(ownership2, "ownership_request") end end diff --git a/test/integration/ownership_call_test.rb b/test/integration/ownership_call_test.rb deleted file mode 100644 index 484e3428b78..00000000000 --- a/test/integration/ownership_call_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -require "test_helper" -require "helpers/adoption_helpers" - -class OwnershipCallsTest < SystemTest - include ActionMailer::TestHelper - include AdoptionHelpers - - setup do - @owner = create(:user) - end - - test "ownership calls listing and pagination on index" do - gems = create_list(:rubygem, 15, owners: [@owner], number: "1.0.0") # rubocop:disable FactoryBot/ExcessiveCreateList - gems.each do |gem| - create(:ownership_call, rubygem: gem, user: @owner) - end - visit ownership_calls_path - - assert_selector :css, ".gems__meter", text: "Displaying ownership calls 1 - 10 of 15 in total" - assert_selector :css, ".gems__gem", count: 10 - end - - test "shows no calls notice if call doesn't exist" do - rubygem = create(:rubygem, owners: [@owner], downloads: 2_000) - create(:version, rubygem: rubygem, created_at: 2.years.ago) - user = create(:user) - visit rubygem_adoptions_path(rubygem.slug, as: user) - - assert page.has_content? "There are no ownership calls for #{rubygem.name}" - end - - test "create ownership call as owner" do - rubygem = create(:rubygem, owners: [@owner], downloads: 2_000) - create(:version, rubygem: rubygem, created_at: 2.years.ago) - visit_rubygem_adoptions_path(rubygem, @owner) - - assert page.has_field? "Note" - create_call("call about _note_ by *owner*.") - - assert_selector :css, "div.ownership__details > p", text: "call about note by owner." - end - - test "shows correct data and formatting about call if exists" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0", downloads: 2_000) - create(:ownership_call, rubygem: rubygem, user: @owner, note: "note _italics_ *bold*.") - user = create(:user) - visit rubygem_adoptions_path(rubygem.slug, as: user) - - assert page.has_link? @owner.handle, href: profile_path(@owner) - within "div.ownership__details" do - assert page.has_css? "em", text: "italics" - assert page.has_css? "strong", text: "bold" - end - end - - test "ownership call of less popular gem as user" do - rubygem = create(:rubygem, owners: [@owner], downloads: 2_000) - create(:version, rubygem: rubygem, created_at: 2.years.ago) - user = create(:user) - visit rubygem_path(rubygem.slug, as: user) - - within ".gem__aside > div.t-list__items" do - click_link "Adoption" - end - - assert page.has_content? "There are no ownership calls for #{rubygem.name}" - assert page.has_field? "Note" - assert page.has_button? "Create ownership request" - end - - test "hide adoptions link if popular gem" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0", downloads: 20_000) - user = create(:user) - visit rubygem_path(rubygem.slug, as: user) - - refute page.has_selector? "a[href='#{rubygem_adoptions_path(rubygem.slug)}']" - end - - test "show adoptions link if less popular gem" do - user = create(:user) - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0") - create(:ownership_call, rubygem: rubygem, user: @owner) - - visit rubygem_path(rubygem.slug, as: user) - - within ".gem__aside > div.t-list__items" do - assert_selector :css, "a[href='#{rubygem_adoptions_path(rubygem.slug)}']" - end - end - - test "show adoptions link if owner" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0", downloads: 20_000) - create(:ownership_call, rubygem: rubygem, user: @owner) - - visit rubygem_path(rubygem.slug, as: @owner) - - within ".gem__aside > div.t-list__items" do - assert_selector :css, "a[href='#{rubygem_adoptions_path(rubygem.slug)}']" - end - end - - test "close ownership call" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0") - ownership_call = create(:ownership_call, rubygem: rubygem, user: @owner) - create_list(:ownership_request, 3, :with_ownership_call, rubygem: rubygem, ownership_call: ownership_call) - - visit_rubygem_adoptions_path(rubygem, @owner) - within first("form.button_to") do - click_button "Close" - end - - perform_enqueued_jobs only: ActionMailer::MailDeliveryJob - - assert_emails 3 - end - - private - - def create_call(note) - fill_in "Note", with: note - click_button "Create ownership call" - end -end diff --git a/test/integration/ownership_request_test.rb b/test/integration/ownership_request_test.rb deleted file mode 100644 index dba4aca0eb7..00000000000 --- a/test/integration/ownership_request_test.rb +++ /dev/null @@ -1,98 +0,0 @@ -require "test_helper" -require "helpers/adoption_helpers" - -class OwnershipRequestsTest < SystemTest - include ActionMailer::TestHelper - include AdoptionHelpers - - setup do - @owner = create(:user) - end - - test "create ownership request" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0") - user = create(:user) - create(:ownership_call, rubygem: rubygem) - visit ownership_calls_path(as: user.id) - click_link "Apply" - - fill_in "Note", with: "request has _italics_ with *bold*." - click_button "Create ownership request" - - within all("div.ownership__details")[1] do - assert page.has_css? "em", text: "italics" - assert page.has_css? "strong", text: "bold" - end - assert page.has_button? "Close" - refute page.has_button? "Approve" - end - - test "approve ownership request by owner" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0") - user = create(:user) - create(:ownership_call, rubygem: rubygem) - create(:ownership_request, user: user, rubygem: rubygem) - - visit_rubygem_adoptions_path(rubygem, @owner) - - click_button "Approve" - - assert_enqueued_emails 3 - assert_includes(rubygem.owners, user) - end - - test "close ownership request by requester" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0") - user = create(:user) - create(:ownership_call, rubygem: rubygem) - create(:ownership_request, user: user, rubygem: rubygem) - - visit rubygem_adoptions_path(rubygem.slug, as: user.id) - - click_button "Close" - - assert_empty rubygem.ownership_requests - assert_enqueued_emails 0 - end - - test "close ownership request by owner" do - rubygem = create(:rubygem, owners: [@owner], number: "1.0.0") - user = create(:user) - create(:ownership_call, rubygem: rubygem) - create(:ownership_request, user: user, rubygem: rubygem) - - visit_rubygem_adoptions_path(rubygem, @owner) - - perform_enqueued_jobs only: ActionMailer::MailDeliveryJob do - page.find_by_id("owner_close_request").click - end - - assert_empty rubygem.ownership_requests - assert_emails 1 - assert_equal "Your ownership request was closed.", last_email.subject - end - - test "cannot close all requests as user" do - rubygem = create(:rubygem, owners: [@owner], downloads: 2_000) - create(:version, rubygem: rubygem, created_at: 2.years.ago) - user = create(:user) - create_list(:ownership_request, 3, rubygem: rubygem) - - visit rubygem_adoptions_path(rubygem.slug, as: user.id) - - refute page.has_link? "Close all" - end - - test "close all requests as owner" do - rubygem = create(:rubygem, owners: [@owner], downloads: 2_000) - create(:version, rubygem: rubygem, created_at: 2.years.ago) - create_list(:ownership_request, 3, rubygem: rubygem) - - visit_rubygem_adoptions_path(rubygem, @owner) - - click_button "Close all" - perform_enqueued_jobs only: ActionMailer::MailDeliveryJob - - assert_emails 3 - end -end diff --git a/test/integration/rack_attack_test.rb b/test/integration/rack_attack_test.rb index a2aeb7b5a69..6b0a8cbaeba 100644 --- a/test/integration/rack_attack_test.rb +++ b/test/integration/rack_attack_test.rb @@ -243,21 +243,6 @@ class RackAttackTest < ActionDispatch::IntegrationTest end end end - - context "ownership requests" do - setup do - sign_in_as(@user) - @rubygem = create(:rubygem, name: "test", downloads: 2_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - stay_under_ownership_request_limit_for("ownership_requests/email") - post "/gems/#{@rubygem.name}/ownership_requests", params: { rubygem_id: @rubygem.name, note: "small note" } - end - - should "allow creating new requests" do - assert_redirected_to "/gems/test/adoptions" - assert_equal "small note", @rubygem.ownership_requests.last.note - end - end end context "requests is higher than limit" do @@ -708,21 +693,6 @@ class RackAttackTest < ActionDispatch::IntegrationTest end end end - - context "ownership requests" do - setup do - sign_in_as(@user) - @rubygem = create(:rubygem, name: "test", downloads: 2_000) - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - exceed_ownership_request_limit_for("ownership_requests/email") - post "/gems/#{@rubygem.name}/ownership_requests", params: { rubygem_id: @rubygem.name, note: "small note" } - end - - should "throttle creating new requests" do - assert_response :too_many_requests - assert_empty @rubygem.ownership_requests - end - end end private diff --git a/test/jobs/delete_user_job_test.rb b/test/jobs/delete_user_job_test.rb index 361d13954d3..1dd0bdacb11 100644 --- a/test/jobs/delete_user_job_test.rb +++ b/test/jobs/delete_user_job_test.rb @@ -124,31 +124,6 @@ class DeleteUserJobTest < ActiveJob::TestCase assert_deleted subscription end - test "succeeds with ownership calls and requests" do - user = create(:user) - rubygem = create(:rubygem, owners: [user]) - other_user = create(:user) - other_rubygem = create(:rubygem, owners: [other_user]) - - closed_call = create(:ownership_call, rubygem: rubygem, user: user, status: :closed) - open_call = create(:ownership_call, rubygem: rubygem, user: user) - - other_call = create(:ownership_call, rubygem: other_rubygem, user: other_user) - closed_request = create(:ownership_request, ownership_call: other_call, rubygem: other_rubygem, user: user, status: :closed) - approved_request = create(:ownership_request, ownership_call: other_call, rubygem: other_rubygem, user: user, status: :approved) - open_request = create(:ownership_request, ownership_call: other_call, rubygem: other_rubygem, user: user) - other_request = create(:ownership_request, ownership_call: open_call, rubygem: rubygem, user: other_user) - - assert_delete user - assert_deleted open_call - assert_deleted closed_call - assert_deleted other_request - assert_predicate approved_request.reload, :approved? - assert_predicate open_request.reload, :closed? - assert_predicate closed_request.reload, :closed? - assert_equal other_call.reload.user, other_user - end - def assert_delete(user) Mailer.expects(:deletion_complete).with(user.email).returns(mock(deliver_later: nil)) Mailer.expects(:deletion_failed).never diff --git a/test/mailers/previews/mailer_preview.rb b/test/mailers/previews/mailer_preview.rb index e2241ae7712..aef279cbf34 100644 --- a/test/mailers/previews/mailer_preview.rb +++ b/test/mailers/previews/mailer_preview.rb @@ -118,22 +118,6 @@ def api_key_revoked Mailer.api_key_revoked(api_key.user.id, api_key.name, api_key.scopes.to_sentence, "https://example.com") end - def new_ownership_requests - gem = Rubygem.order(updated_at: :desc).last - user = gem.owners.last - OwnersMailer.new_ownership_requests(gem.id, user.id) - end - - def ownership_request_closed - ownership_request = OwnershipRequest.last - OwnersMailer.ownership_request_closed(ownership_request.id) - end - - def ownership_request_approved - ownership_request = OwnershipRequest.last - OwnersMailer.ownership_request_approved(ownership_request.id) - end - def webhook_deleted_global user = User.last url = "https://example.com/webhook" diff --git a/test/models/ownership_call_test.rb b/test/models/ownership_call_test.rb deleted file mode 100644 index eaa019e4a63..00000000000 --- a/test/models/ownership_call_test.rb +++ /dev/null @@ -1,86 +0,0 @@ -require "test_helper" - -class OwnershipCallTest < ActiveSupport::TestCase - setup do - @user = create(:user) - @rubygem = create(:rubygem) - end - - should belong_to :rubygem - should have_db_index :rubygem_id - should belong_to :user - should have_db_index :user_id - - context "factory" do - should "be valid with plain factory" do - assert_predicate build(:ownership_call, user: @user, rubygem: @rubygem), :valid? - end - - should "be valid with closed trait" do - ownership_call = build(:ownership_call, :closed, user: @user, rubygem: @rubygem) - - assert_predicate ownership_call, :valid? - assert_predicate ownership_call, :closed? - end - end - - context "#create" do - should "create a call with open status" do - ownership_call = @rubygem.ownership_calls.create(user: @user, note: "valid note") - - assert_predicate ownership_call, :opened? - end - - should "not create a call with note longer than 64000 chars" do - ownership_call = build(:ownership_call, user: @user, rubygem: @rubygem, - note: "r" * (Gemcutter::MAX_TEXT_FIELD_LENGTH + 1)) - - refute_predicate ownership_call, :valid? - assert_contains ownership_call.errors[:note], "is too long (maximum is 64000 characters)" - end - - should "not create a call without note" do - ownership_call = build(:ownership_call, user: @user, rubygem: @rubygem, note: nil) - - refute_predicate ownership_call, :valid? - assert_contains ownership_call.errors[:note], "can't be blank" - end - - should "not create multiple open calls for a rubygem" do - create(:ownership_call, user: @user, rubygem: @rubygem) - ownership_call = build(:ownership_call, user: create(:user), rubygem: @rubygem) - - refute_predicate ownership_call, :valid? - assert_contains ownership_call.errors[:rubygem_id], "can have only one open ownership call" - end - end - - context "#close" do - setup do - @ownership_call = create(:ownership_call, user: @user, rubygem: @rubygem) - end - - should "close all associated open requests and then call" do - create_list(:ownership_request, 2, rubygem: @rubygem, ownership_call: @ownership_call) - @ownership_call.close! - - assert_predicate @ownership_call, :closed? - assert_empty @ownership_call.ownership_requests.opened - end - - should "not close approved request" do - create_list(:ownership_request, 2, rubygem: @rubygem, ownership_call: @ownership_call) - approved_request = create(:ownership_request, :approved, rubygem: @rubygem, ownership_call: @ownership_call) - @ownership_call.close! - - assert_contains OwnershipRequest.where(ownership_call: @ownership_call, status: :approved), approved_request - end - - should "close call if no requests exist" do - @ownership_call.close! - - assert_predicate @ownership_call, :closed? - assert_empty @ownership_call.ownership_requests.opened - end - end -end diff --git a/test/models/ownership_request_test.rb b/test/models/ownership_request_test.rb deleted file mode 100644 index 7b81a9a3983..00000000000 --- a/test/models/ownership_request_test.rb +++ /dev/null @@ -1,150 +0,0 @@ -require "test_helper" - -class OwnershipRequestTest < ActiveSupport::TestCase - include ActionMailer::TestHelper - - setup do - @user = create(:user) - @rubygem = create(:rubygem) - end - - context "#factory" do - should "be valid with factory" do - assert_predicate build(:ownership_request, user: @user, rubygem: @rubygem), :valid? - end - - should "be valid with approved trait factory" do - assert_predicate build(:ownership_request, :approved, user: @user, rubygem: @rubygem), :valid? - end - - should "be valid with close trait factory" do - assert_predicate build(:ownership_request, :closed, user: @user, rubygem: @rubygem), :valid? - end - - should "be valid with ownership call trait factory" do - assert_predicate build(:ownership_request, :with_ownership_call, user: @user, rubygem: @rubygem), :valid? - end - - should "be valid with ownership call and approved traits factory" do - assert_predicate build(:ownership_request, :with_ownership_call, :approved, user: @user, rubygem: @rubygem), :valid? - end - end - - context "#create" do - should "create a call with open status" do - ownership_request = @rubygem.ownership_requests.create(user: @user, note: "valid note") - - assert_predicate ownership_request, :opened? - end - - should "not create a call without note" do - ownership_request = build(:ownership_request, user: @user, rubygem: @rubygem, note: nil) - - refute_predicate ownership_request, :valid? - assert_contains ownership_request.errors[:note], "can't be blank" - end - - should "not create a call with note longer than 64000 chars" do - ownership_request = build(:ownership_request, user: @user, rubygem: @rubygem, - note: "r" * (Gemcutter::MAX_TEXT_FIELD_LENGTH + 1)) - - refute_predicate ownership_request, :valid? - assert_contains ownership_request.errors[:note], "is too long (maximum is 64000 characters)" - end - - should "not create multiple calls for same user and rubygem" do - create(:ownership_request, user: @user, rubygem: @rubygem) - ownership_request = build(:ownership_request, user: @user, rubygem: @rubygem) - - refute_predicate ownership_request, :valid? - assert_contains ownership_request.errors[:user_id], "has already requested ownership" - end - - should "not create a call when already an owner" do - owner = create(:user, handle: "owner") - create(:ownership, rubygem: @rubygem, user: owner) - ownership_request = build(:ownership_request, user: owner, rubygem: @rubygem) - - refute_predicate ownership_request, :valid? - assert_contains ownership_request.errors[:user_id], "is already an owner" - end - end - - context "#approve" do - setup do - @ownership_request = create(:ownership_request, user: @user, rubygem: @rubygem) - @approver = create(:user) - create(:ownership, rubygem: @rubygem, user: @approver) - end - - should "update approver" do - @ownership_request.approve!(@approver) - - assert_predicate @ownership_request, :approved? - assert_equal @approver, @ownership_request.approver - end - - should "send emails" do - @ownership_request.approve!(@approver) - - assert_enqueued_emails 3 - end - - should "create confirmed ownership" do - @ownership_request.approve!(@approver) - ownership = Ownership.find_by(user: @user, rubygem: @rubygem) - - assert_equal @approver, ownership.authorizer - assert_predicate ownership, :confirmed? - end - - should "raises if cannot update status" do - OwnershipRequest.any_instance.stubs(:update!).raises(ActiveRecord::RecordInvalid) - - assert_raises(ActiveRecord::RecordInvalid) { @ownership_request.approve!(@approver) } - assert_nil Ownership.find_by(user: @user, rubygem: @rubygem) - end - - should "raises if ownership cannot be confirmed" do - Ownership.any_instance.stubs(:update!).raises(ActiveRecord::RecordNotSaved) - - assert_raises(ActiveRecord::RecordNotSaved) { @ownership_request.approve!(@approver) } - assert_nil Ownership.find_by(user: @user, rubygem: @rubygem) - refute_predicate @ownership_request.reload, :approved? - - assert_enqueued_emails 0 - end - end - - context "#close" do - setup do - @ownership_request = create(:ownership_request, user: @user, rubygem: @rubygem) - end - - should "close and not send emails if closed by requester" do - @ownership_request.close!(@user) - - assert_predicate @ownership_request, :closed? - - assert_enqueued_emails 0 - end - - should "close and sends email to requester if closed by owner" do - other_user = create(:user) - create(:ownership, user: other_user, rubygem: @rubygem) - - @ownership_request.close!(other_user) - - assert_predicate @ownership_request, :closed? - - assert_enqueued_emails 1 - end - - should "raises if cannot update status" do - OwnershipRequest.any_instance.stubs(:update!).raises(ActiveRecord::RecordInvalid) - - assert_raises(ActiveRecord::RecordInvalid) { @ownership_request.close!(@user) } - refute_predicate @ownership_request, :closed? - end - end -end diff --git a/test/policies/ownership_call_policy_test.rb b/test/policies/ownership_call_policy_test.rb deleted file mode 100644 index 9bd3c3c93a9..00000000000 --- a/test/policies/ownership_call_policy_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "test_helper" - -class OwnershipCallPolicyTest < PolicyTestCase - setup do - @owner = create(:user) - @rubygem = create(:rubygem, owners: [@owner]) - @ownership_call = @rubygem.ownership_calls.create(user: @owner, note: "valid note") - - @user = create(:user) - end - - def policy!(user) - Pundit.policy!(user, @ownership_call) - end - - def test_create - assert_authorized @owner, :create? - refute_authorized @user, :create? - end - - def test_close - assert_authorized @owner, :close? - refute_authorized @user, :close? - end -end diff --git a/test/policies/ownership_request_policy_test.rb b/test/policies/ownership_request_policy_test.rb deleted file mode 100644 index ae598a5f3d6..00000000000 --- a/test/policies/ownership_request_policy_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require "test_helper" - -class OwnershipRequestPolicyTest < ActiveSupport::TestCase - setup do - @user = create(:user, handle: "user") - @owner = create(:user, handle: "owner") - @requester = create(:user, handle: "requester") - - @rubygem = create(:rubygem, number: "1.0", owners: [@owner], created_at: 2.years.ago) - @rubygem.versions.last.update!(created_at: 2.years.ago) - - # ensure it is possible to request ownership of the rubygem - assert_predicate Pundit.policy!(@requester, @rubygem), :request_ownership? - @ownership_request = create(:ownership_request, rubygem: @rubygem, user: @requester) - end - - context "#create?" do - should "allow the requester to create when the gem is considered abandoned" do - assert_predicate Pundit.policy!(@requester, @ownership_request), :create? - refute_predicate Pundit.policy!(@owner, @ownership_request), :create? - refute_predicate Pundit.policy!(@user, @ownership_request), :create? - end - - should "not allow the requester to create when the gem is not considered abandoned" do - newgem = create(:rubygem, number: "1.0", owners: [@owner]) - newgem_request = build(:ownership_request, rubygem: newgem, user: @requester) - - refute_predicate Pundit.policy!(@requester, newgem_request), :create? - refute_predicate Pundit.policy!(@owner, newgem_request), :create? - refute_predicate Pundit.policy!(@user, newgem_request), :create? - end - end - - context "#approve?" do - should "only allow the owner to approve" do - refute_predicate Pundit.policy!(@requester, @ownership_request), :approve? - assert_predicate Pundit.policy!(@owner, @ownership_request), :approve? - refute_predicate Pundit.policy!(@user, @ownership_request), :approve? - end - end - - context "#close?" do - should "allow the requester to close" do - assert_predicate Pundit.policy!(@requester, @ownership_request), :close? - end - - should "allow the owner to close" do - assert_predicate Pundit.policy!(@owner, @ownership_request), :close? - end - - should "not allow other users to close" do - refute_predicate Pundit.policy!(@user, @ownership_request), :close? - end - end -end diff --git a/test/policies/rubygem_policy_test.rb b/test/policies/rubygem_policy_test.rb index 505dc93a4fd..47a4eecd289 100644 --- a/test/policies/rubygem_policy_test.rb +++ b/test/policies/rubygem_policy_test.rb @@ -59,90 +59,6 @@ def org_policy!(user) end end - context "#manage_adoption?" do - should "only allow the owner" do - assert_authorized policy!(@owner), :manage_adoption? - refute_authorized policy!(@user), :manage_adoption? - refute_authorized policy!(nil), :manage_adoption? - end - - should "only allow owners and org owners" do - assert_authorized org_policy!(@org_owner), :manage_adoption? - assert_authorized org_policy!(@owner), :manage_adoption? - - refute_authorized org_policy!(@org_admin), :manage_adoption? - refute_authorized org_policy!(@org_maintainer), :manage_adoption? - refute_authorized org_policy!(@user), :manage_adoption? - refute_authorized org_policy!(nil), :manage_adoption? - end - end - - context "#request_ownership?" do - should "be true if the gem has ownership calls" do - create(:ownership_call, rubygem: @rubygem, user: @owner) - - assert_authorized policy!(@user), :request_ownership? - end - - should "be false if the gem has more than 10,000 downloads" do - @rubygem = create(:rubygem, owners: [@owner], downloads: 10_001) - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - - assert_operator @rubygem.downloads, :>, RubygemPolicy::ABANDONED_DOWNLOADS_MAX - refute_authorized policy!(@user), :request_ownership? - end - - should "be false if the gem has no versions" do - assert_empty @rubygem.versions - refute_authorized policy!(@user), :request_ownership? - end - - context "when the gem has a version newer than 1 year" do - should "be false" do - create(:version, rubygem: @rubygem, created_at: 11.months.ago) - - refute_authorized policy!(@user), :request_ownership? - end - end - - should "be true if the gem's latest version is older than 1 year and less than 10,000 downloads" do - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - - assert_authorized policy!(@user), :request_ownership? - end - end - - context "#close_ownership_requests" do - should "only allow the owner to close ownership requests" do - assert_authorized policy!(@owner), :close_ownership_requests? - refute_authorized policy!(@maintainer), :close_ownership_requests? - refute_authorized policy!(@user), :close_ownership_requests? - end - - should "only allow owners and org owners" do - assert_authorized org_policy!(@org_owner), :close_ownership_requests? - assert_authorized org_policy!(@owner), :close_ownership_requests? - - refute_authorized org_policy!(@org_admin), :close_ownership_requests? - refute_authorized org_policy!(@org_maintainer), :close_ownership_requests? - refute_authorized org_policy!(@user), :close_ownership_requests? - refute_authorized org_policy!(nil), :close_ownership_requests? - end - end - - context "#show_adoption?" do - should "be true if the gem is owned by the user" do - assert_authorized policy!(@owner), :show_adoption? - refute_authorized policy!(@maintainer), :show_adoption? - end - - should "be true if the rubygem is adoptable" do - create(:version, rubygem: @rubygem, created_at: 2.years.ago) - - assert_authorized policy!(@user), :show_adoption? - end - end - context "#show_events?" do should "only allow the owner and maintainer" do assert_authorized policy!(@owner), :show_events? diff --git a/test/system/avo/rubygems_test.rb b/test/system/avo/rubygems_test.rb index df2099044a5..9aedc3bd46a 100644 --- a/test/system/avo/rubygems_test.rb +++ b/test/system/avo/rubygems_test.rb @@ -294,7 +294,6 @@ class Avo::RubygemsSystemTest < ApplicationSystemTestCase "token_expires_at" => [nil, ownership.token_expires_at.as_json], "owner_notifier" => [nil, true], "authorizer_id" => [nil, security_user.id], - "ownership_request_notifier" => [nil, true], "role" => [nil, ownership.role] }, "unchanged" => {} diff --git a/test/system/multifactor_auths_test.rb b/test/system/multifactor_auths_test.rb index 69a06758f53..bdade1cc8f3 100644 --- a/test/system/multifactor_auths_test.rb +++ b/test/system/multifactor_auths_test.rb @@ -56,10 +56,6 @@ class MultifactorAuthsTest < ApplicationSystemTestCase end context "with mfa disabled" do - should "user with mfa disabled gets redirected back to adoptions after setting up mfa" do - redirect_test_mfa_disabled(adoptions_profile_path) - end - should "user with mfa disabled gets redirected back to dashboard pages after setting up mfa" do redirect_test_mfa_disabled(dashboard_path) end @@ -91,10 +87,6 @@ class MultifactorAuthsTest < ApplicationSystemTestCase end context "with weak level mfa" do - should "user gets redirected back to adoptions after setting up mfa" do - redirect_test_mfa_weak_level(adoptions_profile_path) - end - should "user gets redirected back to dashboard pages after setting up mfa" do redirect_test_mfa_weak_level(dashboard_path) end diff --git a/test/system/profile_test.rb b/test/system/profile_test.rb index 6e00a0e8840..a2938c755c3 100644 --- a/test/system/profile_test.rb +++ b/test/system/profile_test.rb @@ -194,21 +194,6 @@ def sign_out assert_no_enqueued_jobs end - test "seeing ownership calls and requests" do - rubygem = create(:rubygem, owners: [@user], number: "1.0.0") - requested_gem = create(:rubygem, number: "2.0.0") - create(:ownership_call, rubygem: rubygem, user: @user, note: "special note") - create(:ownership_request, rubygem: requested_gem, user: @user, note: "request note") - - sign_in - visit profile_path("nick1") - click_link "Adoptions" - - assert page.has_link?(rubygem.name, href: "/gems/#{rubygem.name}") - assert page.has_content? "special note" - assert page.has_content? "request note" - end - test "seeing the gems ordered by downloads" do create(:rubygem, owners: [@user], number: "1.0.0", downloads: 5) create(:rubygem, owners: [@user], number: "1.0.0", downloads: 2) diff --git a/test/unit/ownership_requests_mailer_test.rb b/test/unit/ownership_requests_mailer_test.rb deleted file mode 100644 index a57bff8afe5..00000000000 --- a/test/unit/ownership_requests_mailer_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "test_helper" - -class OwnershipRequestMailerTest < ActiveSupport::TestCase - include ActiveJob::TestHelper - - context "sending mail for ownership request" do - setup do - @ownership = create(:ownership) - create(:ownership_request, rubygem: @ownership.rubygem, created_at: 1.hour.ago) - Rake::Task["ownership_request_notification:send"].invoke - perform_enqueued_jobs only: ActionMailer::MailDeliveryJob - end - - should "send mail to owners" do - refute_empty ActionMailer::Base.deliveries - email = ActionMailer::Base.deliveries.last - - assert_equal [@ownership.user.email], email.to - assert_equal ["no-reply@mailer.rubygems.org"], email.from - assert_equal "New ownership request(s) for #{@ownership.rubygem.name}", email.subject - assert_match "1 new ownership requests", email.body.to_s - end - end - - teardown do - Rake::Task["ownership_request_notification:send"].reenable - end -end