forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the already included module instead of reopening classes.
Related to ManageIQ#14128 We should either use RssFeed.class_eval to reopen the class to force rails to load the RssFeed model first or the technique in this commit, which is to just include the module in RssFeed. Note, this module was already being included so there was no reason to reopen the class also. The existing layout of re-opening the RssFeed with different class definitions: rss_feed/import_export.rb: class RssFeed rss_feed.rb: class RssFeed < ApplicationRecord can cause `TypeError: superclass mismatch for class RssFeed` if the import_export.rb is loaded first.
- Loading branch information
Showing
4 changed files
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
class RssFeed | ||
module ImportExport | ||
extend ActiveSupport::Concern | ||
module RssFeed::ImportExport | ||
extend ActiveSupport::Concern | ||
|
||
def export_to_array | ||
h = attributes | ||
["id", "created_on", "updated_on", "yml_file_mtime"].each { |k| h.delete(k) } | ||
[self.class.to_s => h] | ||
end | ||
def export_to_array | ||
h = attributes | ||
["id", "created_on", "updated_on", "yml_file_mtime"].each { |k| h.delete(k) } | ||
[self.class.to_s => h] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FactoryGirl.define do | ||
factory :rss_feed do | ||
sequence(:name) { |n| "feed_#{seq_padded_for_sorting(n)}" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
describe RssFeed::ImportExport do | ||
it "#export_to_array" do | ||
expect(FactoryGirl.create(:rss_feed, :title => "Latest things!!!") | ||
.export_to_array.first["RssFeed"]["title"]).to eq("Latest things!!!") | ||
end | ||
end |