Skip to content
Permalink
Browse files

Fix generators issue (#3684)

* Add change log entry

* Move `with_original_env` out of generators

* Remove unexistent file from rubocop exclusions

* Let binstubs respect current folder

* Fix generated apps not including optional plugins
  • Loading branch information...
deivid-rodriguez authored and mrcasals committed Jul 4, 2018
1 parent d15fd65 commit a41d0fd3c7b76591f2a5bdeb465f780482c9c6df
@@ -1206,7 +1206,6 @@ RSpec/DescribeClass:
Exclude:
- spec/bundle_spec.rb
- spec/i18n_spec.rb
- spec/generator_spec.rb
- decidim-admin/spec/bundles_spec.rb
- decidim-comments/spec/bundle_spec.rb
- decidim-core/spec/lib/global_engines_spec.rb
@@ -8,6 +8,9 @@

**Fixed**:

- **decidim-generators**: Generated application not including bootsnap.
- **decidim-generators**: Generated application not including optional gems.

**Removed**:

## Previous versions
@@ -83,7 +83,7 @@ desc "Bundle all Gemfiles"
task :bundle do
[".", "decidim-generators", "decidim_app-design"].each do |dir|
Bundler.with_original_env do
Dir.chdir(dir) { sh "BUNDLE_GEMFILE=Gemfile bundle install" }
Dir.chdir(dir) { sh "bundle install" }
end
end
end
@@ -47,8 +47,6 @@ m = Module.new do
end

def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile

activate_bundler(bundler_version)
end

@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

load File.expand_path("bundle", __dir__)

require "rubygems"
@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

load File.expand_path("bundle", __dir__)

require "rubygems"
@@ -35,15 +35,17 @@ namespace :decidim do

desc "Generates a dummy app for trying out external modules"
task :generate_external_development_app do
generate_decidim_app(
"development_app",
"--app_name",
"#{base_app_name}_development_app",
"--path",
"..",
"--recreate_db",
"--seed_db",
"--demo"
)
Bundler.with_original_env do
generate_decidim_app(
"development_app",
"--app_name",
"#{base_app_name}_development_app",
"--path",
"..",
"--recreate_db",
"--seed_db",
"--demo"
)
end
end
end
@@ -5,6 +5,8 @@ source "https://rubygems.org"
ruby RUBY_VERSION

gem "decidim", path: ".."
gem "decidim-consultations", path: ".."
gem "decidim-initiatives", path: ".."

gem "bootsnap", "~> 1.3"

@@ -56,6 +56,10 @@ PATH
decidim-comments (0.14.0.dev)
decidim-core (~> 0.14.a)
jquery-rails (~> 4.0)
decidim-consultations (0.14.0.dev)
decidim-admin (~> 0.14.a)
decidim-comments (~> 0.14.a)
decidim-core (~> 0.14.a)
decidim-core (0.14.0.dev)
active_link_to (~> 1.0)
autoprefixer-rails (~> 8.0)
@@ -129,6 +133,14 @@ PATH
wisper-rspec (~> 1.0)
decidim-generators (0.14.0.dev)
decidim-core (~> 0.14.a)
decidim-initiatives (0.14.0.dev)
decidim-admin (~> 0.14.a)
decidim-comments (~> 0.14.a)
decidim-core (~> 0.14.a)
decidim-verifications (~> 0.14.a)
kaminari (~> 1.0)
social-share-button (~> 1.0)
wicked (~> 1.3)
decidim-meetings (0.14.0.dev)
cells-erb (~> 0.1.0)
cells-rails (~> 0.0.9)
@@ -679,6 +691,8 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
wicked (1.3.2)
railties (>= 3.0.7)
wisper (2.0.0)
wisper-rspec (1.1.0)
xpath (3.1.0)
@@ -691,7 +705,9 @@ DEPENDENCIES
bootsnap (~> 1.3)
byebug (~> 10.0)
decidim!
decidim-consultations!
decidim-dev!
decidim-initiatives!
faker (~> 1.8)
letter_opener_web (~> 1.3)
listen (~> 3.1)
@@ -112,7 +112,7 @@ def gemfile
end
end

Bundler.with_original_env { run "bundle install" }
run "bundle install"
end

def tweak_bootsnap
@@ -148,20 +148,12 @@ def recreate_db

# Runs rails commands in a subprocess, and aborts if it doesn't suceeed
def rails(*args)
with_original_env do
abort unless system("bin/rails", *args)
end
abort unless system("bin/rails", *args)
end

# Runs rails commands in a subprocess silencing errors, and ignores status
def soft_rails(*args)
with_original_env do
system("bin/rails", *args, err: File::NULL)
end
end

def with_original_env
options[:skip_gemfile] ? yield : Bundler.with_original_env { yield }
system("bin/rails", *args, err: File::NULL)
end

def scss_variables
@@ -23,12 +23,6 @@ module Decidim
Bundler.with_original_env { GemManager.capture(command, env: env) }
end

shared_examples_for "a sane generator" do
it "successfully generates application" do
expect(result[1]).to be_success, result[0]
end
end

# rubocop:disable RSpec/BeforeAfterAll
before(:all) do
Decidim::GemManager.install_all(out: File::NULL)
@@ -44,34 +38,54 @@ module Decidim

after { FileUtils.rm_rf(test_app) }

shared_examples_for "a new production application" do
it "includes optional plugins commented out in Gemfile" do
expect(result[1]).to be_success, result[0]

expect(File.read("#{test_app}/Gemfile"))
.to match(/^# gem "decidim-initiatives"/)
.and match(/^# gem "decidim-consultations"/)
end
end

shared_examples_for "a new development application" do
it "includes optional plugins uncommented in Gemfile" do
expect(result[1]).to be_success, result[0]

expect(File.read("#{test_app}/Gemfile"))
.to match(/^gem "decidim-initiatives"/)
.and match(/^gem "decidim-consultations"/)
end
end

context "without flags" do
let(:command) { "decidim #{test_app}" }

it_behaves_like "a sane generator"
it_behaves_like "a new production application"
end

context "with --edge flag" do
let(:command) { "decidim --edge #{test_app}" }

it_behaves_like "a sane generator"
it_behaves_like "a new production application"
end

context "with --branch flag" do
let(:command) { "decidim --branch master #{test_app}" }

it_behaves_like "a sane generator"
it_behaves_like "a new production application"
end

context "with --path flag" do
let(:command) { "decidim --path #{repo_root} #{test_app}" }

it_behaves_like "a sane generator"
it_behaves_like "a new production application"
end

context "with a development application" do
let(:command) { "decidim --path #{repo_root} #{test_app} --recreate_db --seed_db" }
let(:command) { "decidim --path #{repo_root} #{test_app} --recreate_db --seed_db --demo" }

it_behaves_like "a sane generator"
it_behaves_like "a new development application"
end
end

@@ -81,7 +95,9 @@ module Decidim

after { FileUtils.rm_rf("decidim-module-#{test_component}") }

it_behaves_like "a sane generator"
it "suceeeds" do
expect(result[1]).to be_success, result[0]
end
end

private

0 comments on commit a41d0fd

Please sign in to comment.
You can’t perform that action at this time.