Rebase, pass rubocop, remove between-tags references
This is a rebase and resubmission of #453
This commit is contained in:
parent
b1121cb1ee
commit
a287bd872b
|
@ -135,7 +135,7 @@ module GitHubChangelogGenerator
|
|||
if options[:add_issues_wo_labels]
|
||||
issues
|
||||
else
|
||||
issues.reject { |issue| !issue["labels"].map { |l| l["name"] }.any? }
|
||||
issues.select { |issue| issue["labels"].map { |l| l["name"] }.any? }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,25 +2,6 @@
|
|||
|
||||
module GitHubChangelogGenerator
|
||||
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(:options) { {} }
|
||||
let(:generator) { described_class.new(default_options.merge(options)) }
|
||||
|
@ -32,6 +13,33 @@ module GitHubChangelogGenerator
|
|||
let(:unlabeled_issue) { { "labels" => [] } }
|
||||
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
|
||||
generator.get_filtered_issues(issues)
|
||||
end
|
||||
|
@ -40,13 +48,12 @@ module GitHubChangelogGenerator
|
|||
|
||||
it { is_expected.to eq(expected_issues) }
|
||||
|
||||
describe "when 'exclude_labels' is provided" do
|
||||
let(:options) { { exclude_labels: %w(BAD BOO) } }
|
||||
context "when 'exclude_labels' 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
|
||||
end
|
||||
|
||||
context "when 'add_issues_wo_labels' is false" do
|
||||
let(:options) { { add_issues_wo_labels: false } }
|
||||
|
@ -55,7 +62,7 @@ module GitHubChangelogGenerator
|
|||
it { is_expected.to eq(expected_issues) }
|
||||
|
||||
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] }
|
||||
|
||||
it { is_expected.to eq(expected_issues) }
|
||||
|
@ -63,10 +70,11 @@ module GitHubChangelogGenerator
|
|||
end
|
||||
|
||||
context "when 'include_labels' is specified" do
|
||||
let(:options) { { include_labels: %w(GOOD) } }
|
||||
let(:options) { { include_labels: %w[GOOD] } }
|
||||
let(:expected_issues) { [good_issue] }
|
||||
|
||||
it { is_expected.to eq(expected_issues) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,8 +13,8 @@ describe GitHubChangelogGenerator::Generator do
|
|||
end
|
||||
end
|
||||
|
||||
describe "tag_section_mapping" do
|
||||
let(:all_tags) { tags_from_strings(%w(8 7 6 5 4 3 2 1)) }
|
||||
describe "#tag_section_mapping" do
|
||||
let(:all_tags) { tags_from_strings(%w[8 7 6 5 4 3 2 1]) }
|
||||
let(:sorted_tags) { all_tags }
|
||||
|
||||
let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
|
||||
|
@ -72,18 +72,6 @@ describe GitHubChangelogGenerator::Generator do
|
|||
it_behaves_like "a full changelog"
|
||||
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
|
||||
let(:options) { { since_tag: "6" } }
|
||||
let(:expected_mapping) do
|
||||
|
@ -121,32 +109,9 @@ describe GitHubChangelogGenerator::Generator do
|
|||
it_behaves_like "a section mapping"
|
||||
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 "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"
|
||||
end
|
||||
|
@ -165,67 +130,6 @@ describe GitHubChangelogGenerator::Generator do
|
|||
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
|
||||
subject { generator.filter_excluded_tags(tags_from_strings(%w[1 2 3])) }
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user