Skip to content

Commit 4d73f3f

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Fix funding metadata not being printed in some situations
Namely, when a gem has not previously been installed, and Bundler is using the compact index API, fund metadata was not getting printed because the proper delegation was not implemented in the specification class used by the compact index. rubygems/rubygems@9ef5139f60
1 parent 6a474ef commit 4d73f3f

File tree

2 files changed

+32
-21
lines changed

2 files changed

+32
-21
lines changed

lib/bundler/endpoint_specification.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ def extensions
9292
end
9393
end
9494

95+
# needed for `bundle fund`
96+
def metadata
97+
if @remote_specification
98+
@remote_specification.metadata
99+
elsif _local_specification
100+
_local_specification.metadata
101+
else
102+
super
103+
end
104+
end
105+
95106
def _local_specification
96107
return unless @loaded_from && File.exist?(local_specification_path)
97108
eval(File.read(local_specification_path), nil, local_specification_path).tap do |spec|

spec/bundler/install/gems/fund_spec.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
context "when gems include a fund URI" do
3333
it "displays the plural fund message after installing" do
34-
install_gemfile <<-G
35-
source "#{file_uri_for(gem_repo2)}"
34+
install_gemfile <<-G, artifice: "compact_index"
35+
source "https://gem.repo2"
3636
gem 'has_funding_and_other_metadata'
3737
gem 'has_funding'
3838
gem 'rack-obama'
@@ -42,8 +42,8 @@
4242
end
4343

4444
it "displays the singular fund message after installing" do
45-
install_gemfile <<-G
46-
source "#{file_uri_for(gem_repo2)}"
45+
install_gemfile <<-G, artifice: "compact_index"
46+
source "https://gem.repo2"
4747
gem 'has_funding'
4848
gem 'rack-obama'
4949
G
@@ -58,8 +58,8 @@
5858
end
5959

6060
it "does not display the plural fund message after installing" do
61-
install_gemfile <<-G
62-
source "#{file_uri_for(gem_repo2)}"
61+
install_gemfile <<-G, artifice: "compact_index"
62+
source "https://gem.repo2"
6363
gem 'has_funding_and_other_metadata'
6464
gem 'has_funding'
6565
gem 'rack-obama'
@@ -69,8 +69,8 @@
6969
end
7070

7171
it "does not display the singular fund message after installing" do
72-
install_gemfile <<-G
73-
source "#{file_uri_for(gem_repo2)}"
72+
install_gemfile <<-G, artifice: "compact_index"
73+
source "https://gem.repo2"
7474
gem 'has_funding'
7575
gem 'rack-obama'
7676
G
@@ -81,8 +81,8 @@
8181

8282
context "when gems do not include fund messages" do
8383
it "does not display any fund messages" do
84-
install_gemfile <<-G
85-
source "#{file_uri_for(gem_repo2)}"
84+
install_gemfile <<-G, artifice: "compact_index"
85+
source "https://gem.repo2"
8686
gem "activesupport"
8787
G
8888

@@ -92,8 +92,8 @@
9292

9393
context "when a dependency includes a fund message" do
9494
it "does not display the fund message" do
95-
install_gemfile <<-G
96-
source "#{file_uri_for(gem_repo2)}"
95+
install_gemfile <<-G, artifice: "compact_index"
96+
source "https://gem.repo2"
9797
gem 'gem_with_dependent_funding'
9898
G
9999

@@ -110,8 +110,8 @@
110110
"funding_uri" => "https://example.com/also_has_funding/funding",
111111
}
112112
end
113-
install_gemfile <<-G
114-
source "#{file_uri_for(gem_repo1)}"
113+
install_gemfile <<-G, artifice: "compact_index"
114+
source "https://gem.repo1"
115115
gem 'also_has_funding', :git => '#{lib_path("also_has_funding-1.0")}'
116116
G
117117

@@ -124,8 +124,8 @@
124124
"funding_uri" => "https://example.com/also_has_funding/funding",
125125
}
126126
end
127-
install_gemfile <<-G
128-
source "#{file_uri_for(gem_repo1)}"
127+
install_gemfile <<-G, artifice: "compact_index"
128+
source "https://gem.repo1"
129129
gem 'also_has_funding', :git => '#{lib_path("also_has_funding-1.0")}'
130130
G
131131

@@ -134,8 +134,8 @@
134134
"funding_uri" => "https://example.com/also_has_funding/funding",
135135
}
136136
end
137-
install_gemfile <<-G
138-
source "#{file_uri_for(gem_repo1)}"
137+
install_gemfile <<-G, artifice: "compact_index"
138+
source "https://gem.repo1"
139139
gem 'also_has_funding', :git => '#{lib_path("also_has_funding-1.1")}'
140140
G
141141

@@ -149,14 +149,14 @@
149149
}
150150
end
151151
gemfile <<-G
152-
source "#{file_uri_for(gem_repo1)}"
152+
source "https://gem.repo1"
153153
gem 'also_has_funding', :git => '#{lib_path("also_has_funding-1.0")}'
154154
G
155155

156-
bundle :install
156+
bundle :install, artifice: "compact_index"
157157
expect(out).to include("1 installed gem you directly depend on is looking for funding.")
158158

159-
bundle :install
159+
bundle :install, artifice: "compact_index"
160160
expect(out).to include("1 installed gem you directly depend on is looking for funding.")
161161
end
162162
end

0 commit comments

Comments
 (0)