Skip to content

Commit

Permalink
Chore: Remove dead code (#976)
Browse files Browse the repository at this point in the history
* chore: remove jasmine rails route (#961)

* chore: remove test card endpoint (#962)

* chore: remove unused StoriesHelper class (#963)

* chore: remove unused Team#allowed_domain? (#964)

* chore: remove unused User.recently_created (#965)

* chore: remove unused Story#cycle_time_in (#966)
  • Loading branch information
danielmbrasil authored Oct 2, 2024
1 parent 12079e2 commit 336910c
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 250 deletions.
40 changes: 0 additions & 40 deletions app/controllers/static_controller.rb

This file was deleted.

6 changes: 0 additions & 6 deletions app/helpers/stories_helper.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/models/story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ def fix_story_accepted_at
project.start_date = accepted_at
end

def cycle_time_in(unit = :days)
raise 'wrong unit' unless %i[days weeks months years].include?(unit)
(cycle_time / 1.send(unit)).round
end

def release_date=(val)
return if val.blank?

Expand Down
10 changes: 0 additions & 10 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ def not_archived

has_attachment :logo, accept: %i[jpg png gif bmp]

def allowed_domain?(email)
whitelist = (registration_domain_whitelist || '').split(DOMAIN_SEPARATORS_REGEX).map(&:strip)
blacklist = (registration_domain_blacklist || '').split(DOMAIN_SEPARATORS_REGEX).map(&:strip)
has_whitelist = true
has_whitelist = whitelist.any? { |domain| email.include?(domain) } unless whitelist.empty?
has_blacklist = false
has_blacklist = blacklist.any? { |domain| email.include?(domain) } unless blacklist.empty?
has_whitelist && !has_blacklist
end

def to_param
::FriendlyId::Disabler.disabled? ? (id&.to_s) : super
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def not_archived
reset_password_keys: AUTHENTICATION_KEYS
# unlock_keys: AUTHENTICATION_KEYS

scope :recently_created, lambda { |created_at|
where('users.created_at > ?', created_at) if created_at
}

def password_required?
# Password is required if it is being set, but not for new records
if !persisted?
Expand Down
156 changes: 0 additions & 156 deletions app/views/static/testcard.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
end

if Rails.env.development?
get 'testcard' => 'static#testcard'
mount LetterOpenerWeb::Engine, at: "/letter_opener"
end

Expand All @@ -118,8 +117,6 @@

root 'projects#index'

mount JasmineRails::Engine => '/specs' if defined?(JasmineRails)

namespace :gitlab do
namespace :projects do
resources :events, only: :create
Expand Down
1 change: 0 additions & 1 deletion spec/models/story_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
subject.started_at = 5.days.ago
subject.update_attribute :state, 'accepted'
expect(subject.accepted_at).to eq(Time.current)
expect(subject.cycle_time_in(:days)).to eq(5)
end
end
end
Expand Down
25 changes: 0 additions & 25 deletions spec/models/team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,6 @@
it { is_expected.to have_many(:api_tokens) }
it { is_expected.to have_many(:tag_groups) }

context '#allowed_domain' do
it 'is in whitelist' do
subject.registration_domain_whitelist = 'codeminer42.com, uol.com.br'
expect(subject.allowed_domain?('[email protected]')).to be_truthy
expect(subject.allowed_domain?('[email protected]')).to be_truthy
expect(subject.allowed_domain?('[email protected]')).to be_falsey
end

it 'is not in blacklist' do
subject.registration_domain_blacklist = "hotmail.com\ngmail.com\nyahoo.com.br"
expect(subject.allowed_domain?('[email protected]')).to be_truthy
expect(subject.allowed_domain?('[email protected]')).to be_truthy
expect(subject.allowed_domain?('[email protected]')).to be_falsey
end

it 'it is both in the whitelist and not in the blacklist' do
subject.registration_domain_whitelist = 'codeminer42.com, uol.com.br'
subject.registration_domain_blacklist = "hotmail.com\ngmail.com\nyahoo.com.br"
expect(subject.allowed_domain?('[email protected]')).to be_truthy
expect(subject.allowed_domain?('[email protected]')).to be_truthy
expect(subject.allowed_domain?('[email protected]')).to be_falsey
expect(subject.allowed_domain?('[email protected]')).to be_falsey
end
end

describe 'scopes' do
describe '.ordered_by_name' do
let!(:first_team) { create(:team, name: 'Team 2') }
Expand Down

0 comments on commit 336910c

Please sign in to comment.