Skip to content

Commit af7e3a6

Browse files
committed
remove destination accountable from transfer sources options
1 parent b1746f3 commit af7e3a6

File tree

8 files changed

+12
-32
lines changed

8 files changed

+12
-32
lines changed

app/models/member.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def display_name_with_uid
4040
# @params _destination_accountable used to keep the same API as
4141
# Organization#display_id
4242
# @return [Integer]
43-
def display_id(_destination_accountable)
43+
def display_id
4444
member_uid
4545
end
4646

app/models/organization.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ def display_name_with_uid
2929
#
3030
# @params destination_accountable [Organization | Object] target of a transfer
3131
# @return [Integer | String]
32-
def display_id(destination_accountable)
33-
if destination_accountable.is_a?(Organization)
34-
account.accountable_id
35-
else
36-
''
37-
end
32+
def display_id
33+
account.accountable_id
3834
end
3935

4036
def ensure_reg_number_seq!

app/models/transfer_sources_options.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ class TransferSourcesOptions
44
# Constructor
55
#
66
# @param sources [Array<Account>]
7-
# @param destination_accountable [Member | Organization]
8-
def initialize(sources, destination_accountable)
7+
def initialize(sources)
98
@sources = sources
10-
@destination_accountable = destination_accountable
119
end
1210

1311
# Returns the collection as an Array containing pairs of <option>'s text and
@@ -22,7 +20,7 @@ def to_a
2220

2321
private
2422

25-
attr_reader :sources, :destination_accountable
23+
attr_reader :sources
2624

2725
def to_accountable_type_and_uid(account)
2826
[account.accountable_type, account.accountable.try(:member_uid)]
@@ -32,12 +30,8 @@ def to_text_and_value(account)
3230
accountable = account.accountable
3331

3432
[
35-
"#{display_id(accountable)} #{accountable.class} #{accountable}",
33+
"#{accountable.display_id} #{accountable.class} #{accountable}",
3634
account.id
3735
]
3836
end
39-
40-
def display_id(accountable)
41-
accountable.display_id(destination_accountable)
42-
end
4337
end

app/views/transfers/_sources.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<%= form.label :source %>
33
<%= form.select :source,
44
options_for_select(
5-
TransferSourcesOptions.new(sources, accountable).to_a,
5+
TransferSourcesOptions.new(sources).to_a,
66
selected: current_user.member(current_organization).account.id
77
), {}, id: "select2-time", class: "form-control"
88
%>

spec/controllers/transfers_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
get :new, params
7272

7373
expect(response.body).to include("<select id=\"select2-time\" class=\"form-control\" name=\"transfer[source]\"><option selected=\"selected\" value=\"#{member_admin.account.id}\">#{member_admin.member_uid} Member #{member_admin}</option>")
74-
expect(response.body).to include("<option value=\"#{test_organization.account.id}\"> Organization #{test_organization}</option></select>")
74+
expect(response.body).to include("<option value=\"#{test_organization.account.id}\">#{test_organization.id} Organization #{test_organization}</option></select>")
7575
end
7676
end
7777

spec/models/member_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
end
3737

3838
describe '#display_id' do
39-
subject { member.display_id(nil) }
39+
subject { member.display_id }
4040

4141
it { is_expected.to eq(member.member_uid) }
4242
end

spec/models/organization_spec.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
let(:organization) { Fabricate(:organization) }
55

66
describe '#display_id' do
7-
subject { organization.display_id(destination_accountable) }
7+
subject { organization.display_id }
88

9-
context 'when the destination_accountable is an organization' do
10-
let(:destination_accountable) { Fabricate(:organization) }
11-
it { is_expected.to eq(organization.account.accountable_id) }
12-
end
13-
14-
context 'when the destination_accountable is not an organization' do
15-
let(:destination_accountable) { Fabricate(:member) }
16-
it { is_expected.to eq('') }
17-
end
9+
it { is_expected.to eq(organization.account.accountable_id) }
1810
end
1911

2012
describe 'ensure_url validation' do

spec/models/transfer_sources_options_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe TransferSourcesOptions do
44
let(:transfer_sources_options) do
5-
described_class.new(sources, destination_accountable)
5+
described_class.new(sources)
66
end
77

88
describe '#to_a' do
@@ -14,8 +14,6 @@
1414
Fabricate(:member, organization: organization, member_uid: 1)
1515
end
1616

17-
let(:destination_accountable) { Fabricate(:organization) }
18-
1917
let(:sources) do
2018
[organization.account, member.account, newer_member.account]
2119
end

0 commit comments

Comments
 (0)