|
223 | 223 | expect(result).to eq({"ocicat"=>"MEMBER", "blackmanx"=>"MEMBER", "toyger"=>"MEMBER", "highlander"=>"MEMBER", "russianblue"=>"MEMBER", "ragamuffin"=>"MEMBER", "monalisa"=>"ADMIN", "peterbald"=>"MEMBER", "mainecoon"=>"MEMBER", "laperm"=>"MEMBER"}) |
224 | 224 | end |
225 | 225 | end |
| 226 | + |
| 227 | + context "when there are no admins" do |
| 228 | + let(:members) { %w[ocicat blackmanx] } |
| 229 | + let(:octokit) { instance_double(Octokit::Client) } |
| 230 | + it "returns only members" do |
| 231 | + expect(subject).to receive(:octokit).and_return(octokit).twice |
| 232 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "admin" }).and_return([]) |
| 233 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "member" }).and_return(members.map { |login| { login: } }) |
| 234 | + result = subject.send(:members_and_roles_from_rest) |
| 235 | + expect(result).to eq({"ocicat"=>"MEMBER", "blackmanx"=>"MEMBER"}) |
| 236 | + end |
| 237 | + end |
| 238 | + |
| 239 | + context "when there are no members" do |
| 240 | + let(:admins) { %w[monalisa] } |
| 241 | + let(:octokit) { instance_double(Octokit::Client) } |
| 242 | + it "returns only admins" do |
| 243 | + expect(subject).to receive(:octokit).and_return(octokit).twice |
| 244 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "admin" }).and_return(admins.map { |login| { login: } }) |
| 245 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "member" }).and_return([]) |
| 246 | + result = subject.send(:members_and_roles_from_rest) |
| 247 | + expect(result).to eq({"monalisa"=>"ADMIN"}) |
| 248 | + end |
| 249 | + end |
| 250 | + |
| 251 | + context "when usernames have different cases" do |
| 252 | + let(:admins) { ["Monalisa"] } |
| 253 | + let(:members) { ["OCICAT", "BlackManx"] } |
| 254 | + let(:octokit) { instance_double(Octokit::Client) } |
| 255 | + it "downcases all usernames" do |
| 256 | + expect(subject).to receive(:octokit).and_return(octokit).twice |
| 257 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "admin" }).and_return(admins.map { |login| { login: } }) |
| 258 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "member" }).and_return(members.map { |login| { login: } }) |
| 259 | + result = subject.send(:members_and_roles_from_rest) |
| 260 | + expect(result).to eq({"monalisa"=>"ADMIN", "ocicat"=>"MEMBER", "blackmanx"=>"MEMBER"}) |
| 261 | + end |
| 262 | + end |
| 263 | + |
| 264 | + context "when organization is empty" do |
| 265 | + let(:octokit) { instance_double(Octokit::Client) } |
| 266 | + it "returns an empty hash" do |
| 267 | + expect(subject).to receive(:octokit).and_return(octokit).twice |
| 268 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "admin" }).and_return([]) |
| 269 | + expect(octokit).to receive(:organization_members).with("kittensinc", { role: "member" }).and_return([]) |
| 270 | + result = subject.send(:members_and_roles_from_rest) |
| 271 | + expect(result).to eq({}) |
| 272 | + end |
| 273 | + end |
226 | 274 | end |
227 | 275 |
|
228 | 276 | describe "#pending_members_from_graphql" do |
|
0 commit comments