Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the term "orphaned" is ambiguous - changing the label #507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def outbound_links
variables
end

def orphaned?
def notused?
inbound_links.empty? && outbound_links.empty?
end
end
4 changes: 2 additions & 2 deletions app/views/variables/_badges.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
- if variable.has_formula?
%span.badge.badge-info= t :formula_included

- if variable.orphaned?
- if variable.notused?
%span.badge.badge-warning{ 'data-toggle': 'tooltip',
'data-placement': 'bottom', title: 'Not used by any formula, and has no formula itself' }
Orphaned
Not used
- else
%span.badge.badge-dark used #{pluralize variable.inbound_links.size, 'time'}

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/variables_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

RSpec.describe VariablesController, type: :controller do
describe '#index' do
context 'one orphaned variable' do
context 'one unused variable' do
let!(:variable) { FactoryBot.create :variable }
before { get :index }
it { expect(assigns(:variables)).to eq [variable] }
end

context 'three orphaned variables' do
context 'three unused variables' do
let!(:variable) { FactoryBot.create :variable }
let!(:variable_two) { FactoryBot.create :variable }
let!(:variable_three) { FactoryBot.create :variable }
Expand Down
6 changes: 3 additions & 3 deletions spec/features/variables/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
require 'rails_helper'

describe 'index' do
context 'Variable is orphaned' do
context 'Variable is not used' do
before { FactoryBot.create :variable, name: 'likes_to_eat_chocolate' }
describe 'view all variables' do
before { visit variables_path }
it { expect(page).to have_text 'Available filters for Namespace' }
it { expect(page).to have_link 'likes_to_eat_chocolate' }
it { expect(page).to have_text 'Orphaned' }
it { expect(page).to have_text 'Not used' }
end
end

Expand All @@ -24,7 +24,7 @@
it { expect(page).to have_link 'likes_to_eat_chocolate' }
it { expect(page).to have_link 'likes_to_eat' }
it { expect(page).to have_text 'used 1 time' }
it { expect(page).not_to have_text 'Orphaned' }
it { expect(page).not_to have_text 'Not used' }
end
end
end
6 changes: 3 additions & 3 deletions spec/features/variables/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
require 'rails_helper'

describe 'show' do
context 'Variable is orphaned' do
context 'Variable is not used' do
let(:variable) { FactoryBot.create :variable, name: 'likes_to_eat_chocolate' }
describe 'view all variables' do
before { visit variable_path(variable) }
it { expect(page).to have_content variable.name }
it { expect(page).to have_text 'Orphaned' }
it { expect(page).to have_text 'Not used' }
end
end

Expand All @@ -20,7 +20,7 @@
it { expect(page).to have_link parent.name }
it { expect(page).to have_content child.name }
it { expect(page).to have_text 'used 1 time' }
it { expect(page).not_to have_text 'Orphaned' }
it { expect(page).not_to have_text 'Not used' }
end
end
end
14 changes: 7 additions & 7 deletions spec/models/variable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
let(:child1) { FactoryBot.create :variable }
let(:child2) { FactoryBot.create :variable }

let(:orphan) { FactoryBot.create :variable }
let(:notused) { FactoryBot.create :variable }

it { expect(parent.inbound_links.size).to eq 2 }
it { expect(parent.outbound_links.size).to eq 0 }
it { expect(parent.orphaned?).to be false }
it { expect(parent.notused?).to be false }

it { expect(child1.outbound_links.size).to eq 1 }
it { expect(child1.inbound_links.size).to eq 0 }
it { expect(child1.orphaned?).to be false }
it { expect(child1.notused?).to be false }

it { expect(child2.outbound_links.size).to eq 1 }
it { expect(child2.inbound_links.size).to eq 0 }
it { expect(child2.orphaned?).to be false }
it { expect(child2.notused?).to be false }

it { expect(orphan.orphaned?).to be true }
it { expect(orphan.inbound_links.size).to be 0 }
it { expect(orphan.outbound_links.size).to be 0 }
it { expect(notused.notused?).to be true }
it { expect(notused.inbound_links.size).to be 0 }
it { expect(notused.outbound_links.size).to be 0 }
end
end