Skip to content

Commit

Permalink
Merge pull request #188 from ninoseki/fix-orchestrator-error
Browse files Browse the repository at this point in the history
fix: remove duplicated URLs from websites
  • Loading branch information
ninoseki authored Feb 6, 2024
2 parents bab9209 + 20905bc commit 8f2b2fc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/miteru/orchestrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ def websites
Miteru.logger.warn("Feed:#{feed.source} failed - #{result.failure}")
end
end
end.flatten
end.flatten.uniq(&:url)
end

#
# @return [Array<Miteru::Feeds::Base>]
#
def feeds
Miteru.feeds.map(&:new)
end

private
Expand All @@ -52,12 +59,5 @@ def threads
def verbose?
Miteru.config.verbose
end

#
# @return [Array<Miteru::Feeds::Base>]
#
def feeds
Miteru.feeds.map(&:new)
end
end
end
25 changes: 25 additions & 0 deletions spec/orchestrator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

class DummyFeed < Miteru::Feeds::Base
def initialize(base_url = "http://example.com")
super(base_url)
end

def urls
["http://example.com"] * 10
end
end

RSpec.describe Miteru::Orchestrator do
subject(:orchestrator) { described_class.new }

before do
allow(orchestrator).to receive(:feeds).and_return([DummyFeed.new] * 10)
end

describe "#websites" do
it do
expect(orchestrator.websites.map(&:url)).to eq(["http://example.com"])
end
end
end

0 comments on commit 8f2b2fc

Please sign in to comment.