Fix decidim-templates gem definition to include templates migrations#6899
Fix decidim-templates gem definition to include templates migrations#6899tramuntanal merged 4 commits intodevelopfrom
Conversation
|
Should we add some kind of test making sure the command runs fine? |
|
That would be great @mrcasals , do you know how we can test this? |
|
@microstudi maybe something like we do in |
|
I'll take a look monday, see if I figure something out. However I suspect this should be a part of a broader strategy of testing gems and interactions with included and options decidim modules. |
|
@microstudi yup, I don't want to block this PR for that! |
| # Checks that every table from a migration is included in the generated schema | ||
| schema = File.read("#{test_app}/db/schema.rb") | ||
| tables = [] | ||
| dropped = [] | ||
| Decidim::GemManager.plugins.each do |plugin| | ||
| Dir.glob("#{plugin}db/migrate/*.rb").each do |migration| | ||
| lines = File.readlines(migration) | ||
| tables.concat(lines.filter { |line| line.match? "create_table" }.map { |line| line.match(/(:)([a-z_0-9]+)/)[2] }) | ||
| dropped.concat(lines.filter { |line| line.match? "drop_table" }.map { |line| line.match(/(:)([a-z_0-9]+)/)[2] }) | ||
| end | ||
| end | ||
| tables.each do |table| | ||
| next if dropped.include? table | ||
|
|
||
| expect(schema).to match(/create_table "#{table}"|create_table :#{table}/) |
There was a problem hiding this comment.
@mrcasals I've come out with this trick to test if the generated app has all the tables specified in the different modules. This works for the use case, if the db folder is not included in the gem, migrations are not copy and test fails.
What do you think?
tramuntanal
left a comment
There was a problem hiding this comment.
Good work @microstudi
🎩 What? Why?
The definition of the gem
decidim-templatesdoes not include thedbfolder meaning it cannot be installed from rubygems.org.This should fix it but requires to create a new version of the gem (see the backport for 0.23).
📌 Related Issues
Link your PR to an issue
Testing
Describe the best way to test or validate your PR.
📋 Checklist
🚨 Please review the guidelines for contributing to this repository.
docs/.📷 Screenshots
Please add screenshots of the changes you're proposing
