Rebase, pass rubocop, remove between-tags references

This is a rebase and resubmission of #453
This commit is contained in:
Hunter Haugen 2017-07-27 15:50:59 -07:00
parent b1121cb1ee
commit a287bd872b
No known key found for this signature in database
GPG Key ID: EF99694AA599DDAD
4 changed files with 53 additions and 141 deletions

View File

@ -135,7 +135,7 @@ module GitHubChangelogGenerator
if options[:add_issues_wo_labels] if options[:add_issues_wo_labels]
issues issues
else else
issues.reject { |issue| !issue["labels"].map { |l| l["name"] }.any? } issues.select { |issue| issue["labels"].map { |l| l["name"] }.any? }
end end
end end

View File

@ -2,25 +2,6 @@
module GitHubChangelogGenerator module GitHubChangelogGenerator
describe Generator do describe Generator do
context "#exclude_issues_by_labels" do
let(:label) { { "name" => "BAD" } }
let(:issue) { { "labels" => [label] } }
let(:good_label) { { "name" => "GOOD" } }
let(:good_issue) { { "labels" => [good_label] } }
let(:issues) { [issue, good_issue] }
subject(:generator) { described_class.new(exclude_labels: %w[BAD BOO]) }
it "removes issues with labels in the exclude_label list" do
result = generator.exclude_issues_by_labels(issues)
expect(result).to include(good_issue)
expect(result).not_to include(issue)
end
it { is_expected.to eq(expected_issues) }
end
context "get_filtered_issues" do
let(:default_options) { GitHubChangelogGenerator::Parser.default_options } let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
let(:options) { {} } let(:options) { {} }
let(:generator) { described_class.new(default_options.merge(options)) } let(:generator) { described_class.new(default_options.merge(options)) }
@ -32,6 +13,33 @@ module GitHubChangelogGenerator
let(:unlabeled_issue) { { "labels" => [] } } let(:unlabeled_issue) { { "labels" => [] } }
let(:issues) { [bad_issue, good_issue, unlabeled_issue] } let(:issues) { [bad_issue, good_issue, unlabeled_issue] }
describe "#exclude_issues_by_labels" do
subject do
generator.exclude_issues_by_labels(issues)
end
let(:expected_issues) { issues }
it { is_expected.to eq(expected_issues) }
context "when 'exclude_lables' is provided" do
let(:options) { { exclude_labels: %w[BAD BOO] } }
let(:expected_issues) { [good_issue, unlabeled_issue] }
it { is_expected.to eq(expected_issues) }
end
context "with no option given" do
subject(:generator) { described_class.new }
it "passes everything through when no option given" do
result = generator.exclude_issues_by_labels(issues)
expect(result).to eq(issues)
end
end
end
describe "#get_filtered_issues" do
subject do subject do
generator.get_filtered_issues(issues) generator.get_filtered_issues(issues)
end end
@ -40,13 +48,12 @@ module GitHubChangelogGenerator
it { is_expected.to eq(expected_issues) } it { is_expected.to eq(expected_issues) }
describe "when 'exclude_labels' is provided" do context "when 'exclude_labels' is provided" do
let(:options) { { exclude_labels: %w(BAD BOO) } } let(:options) { { exclude_labels: %w[BAD BOO] } }
let(:expected_issues) { [good_issue, unlabeled_issue] } let(:expected_issues) { [good_issue, unlabeled_issue] }
it { is_expected.to eq(expected_issues) } it { is_expected.to eq(expected_issues) }
end end
end
context "when 'add_issues_wo_labels' is false" do context "when 'add_issues_wo_labels' is false" do
let(:options) { { add_issues_wo_labels: false } } let(:options) { { add_issues_wo_labels: false } }
@ -55,7 +62,7 @@ module GitHubChangelogGenerator
it { is_expected.to eq(expected_issues) } it { is_expected.to eq(expected_issues) }
context "with 'exclude_labels'" do context "with 'exclude_labels'" do
let(:options) { { add_issues_wo_labels: false, exclude_labels: %w(GOOD) } } let(:options) { { add_issues_wo_labels: false, exclude_labels: %w[GOOD] } }
let(:expected_issues) { [bad_issue] } let(:expected_issues) { [bad_issue] }
it { is_expected.to eq(expected_issues) } it { is_expected.to eq(expected_issues) }
@ -63,10 +70,11 @@ module GitHubChangelogGenerator
end end
context "when 'include_labels' is specified" do context "when 'include_labels' is specified" do
let(:options) { { include_labels: %w(GOOD) } } let(:options) { { include_labels: %w[GOOD] } }
let(:expected_issues) { [good_issue] } let(:expected_issues) { [good_issue] }
it { is_expected.to eq(expected_issues) } it { is_expected.to eq(expected_issues) }
end end
end end
end end
end

View File

@ -13,8 +13,8 @@ describe GitHubChangelogGenerator::Generator do
end end
end end
describe "tag_section_mapping" do describe "#tag_section_mapping" do
let(:all_tags) { tags_from_strings(%w(8 7 6 5 4 3 2 1)) } let(:all_tags) { tags_from_strings(%w[8 7 6 5 4 3 2 1]) }
let(:sorted_tags) { all_tags } let(:sorted_tags) { all_tags }
let(:default_options) { GitHubChangelogGenerator::Parser.default_options } let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
@ -72,18 +72,6 @@ describe GitHubChangelogGenerator::Generator do
it_behaves_like "a full changelog" it_behaves_like "a full changelog"
end end
context "with between tags only" do
let(:options) { { between_tags: %w(3 5 8) } }
let(:expected_mapping) do
{
tag_with_name("8") => [tag_with_name("5"), tag_with_name("8")],
tag_with_name("5") => [tag_with_name("3"), tag_with_name("5")]
}
end
it_behaves_like "a section mapping"
end
context "with since only" do context "with since only" do
let(:options) { { since_tag: "6" } } let(:options) { { since_tag: "6" } }
let(:expected_mapping) do let(:expected_mapping) do
@ -121,32 +109,9 @@ describe GitHubChangelogGenerator::Generator do
it_behaves_like "a section mapping" it_behaves_like "a section mapping"
end end
context "with since, due, and between_tags" do
let(:options) { { since_tag: "2", due_tag: "7", between_tags: %w(3 5 6) } }
let(:expected_mapping) do
{
tag_with_name("6") => [tag_with_name("5"), tag_with_name("6")],
tag_with_name("5") => [tag_with_name("3"), tag_with_name("5")]
}
end
it_behaves_like "a section mapping"
end
context "with conflicting since/due/between_tags" do
let(:options) { { since_tag: "2", due_tag: "7", between_tags: %w(1 3 6 8) } }
let(:expected_mapping) do
{
tag_with_name("6") => [tag_with_name("3"), tag_with_name("6")]
}
end
it_behaves_like "a section mapping"
end
context "with excluded tags" do context "with excluded tags" do
context "as a list of strings" do context "as a list of strings" do
let(:options) { { exclude_tags: %w(2 5 7) } } let(:options) { { exclude_tags: %w[2 5 7] } }
it_behaves_like "a changelog with some exclusions" it_behaves_like "a changelog with some exclusions"
end end
@ -165,67 +130,6 @@ describe GitHubChangelogGenerator::Generator do
end end
end end
describe "#filter_between_tags" do
context "when between_tags nil" do
before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: nil)
end
subject do
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
end
context "when between_tags same as input array" do
before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3))
end
subject do
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
end
context "when between_tags filled with correct values" do
before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2))
end
subject do
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(tags_from_strings(%w(1 2))) }
end
context "when between_tags filled with invalid values" do
before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 q w))
end
subject do
@generator.get_filtered_tags(tags_from_strings(%w(1 2 3)))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(tags_from_strings(%w(1))) }
end
end
describe "#get_filtered_tags" do
subject do
generator.get_filtered_tags(tags_from_strings(%w(1 2 3 4 5)))
end
context "respects between tags" do
let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3)) }
it { is_expected.to be_a Array }
it { is_expected.to match_array(tags_from_strings(%w(1 2 3))) }
end
end
describe "#filter_excluded_tags" do describe "#filter_excluded_tags" do
subject { generator.filter_excluded_tags(tags_from_strings(%w[1 2 3])) } subject { generator.filter_excluded_tags(tags_from_strings(%w[1 2 3])) }