|
14 | 14 | expect(generator.instance_variable_get(:@selected_authentication)).to eq("devise") |
15 | 15 | expect(generator.instance_variable_get(:@selected_payment_method)).to eq("paypal") |
16 | 16 | expect(generator.instance_variable_get(:@run_migrations)).to eq(true) |
17 | | - expect(generator.instance_variable_get(:@load_seed_data)).to eq(true) |
18 | | - expect(generator.instance_variable_get(:@load_sample_data)).to eq(true) |
| 17 | + expect(generator.instance_variable_get(:@run_seeds)).to eq(false) |
| 18 | + expect(generator.instance_variable_get(:@run_sample)).to eq(true) |
19 | 19 | end |
20 | 20 | end |
21 | 21 |
|
|
36 | 36 |
|
37 | 37 | aggregate_failures do |
38 | 38 | expect(generator.instance_variable_get(:@run_migrations)).to eq(false) |
39 | | - expect(generator.instance_variable_get(:@load_seed_data)).to eq(false) |
40 | | - expect(generator.instance_variable_get(:@load_sample_data)).to eq(false) |
| 39 | + expect(generator.instance_variable_get(:@run_seeds)).to eq(false) |
| 40 | + expect(generator.instance_variable_get(:@run_sample)).to eq(false) |
| 41 | + end |
| 42 | + end |
| 43 | + |
| 44 | + it 'disables "seeds" when "sample" is enabled' do |
| 45 | + generator = described_class.new([], ['--auto-accept', '--sample=true']) |
| 46 | + generator.prepare_options |
| 47 | + |
| 48 | + aggregate_failures do |
| 49 | + expect(generator.instance_variable_get(:@run_migrations)).to eq(true) |
| 50 | + expect(generator.instance_variable_get(:@run_seeds)).to eq(false) |
| 51 | + expect(generator.instance_variable_get(:@run_sample)).to eq(true) |
41 | 52 | end |
42 | 53 | end |
43 | 54 |
|
|
68 | 79 | generator.prepare_options |
69 | 80 |
|
70 | 81 | expect(generator.instance_variable_get(:@run_migrations)).to eq(false) |
71 | | - expect(generator.instance_variable_get(:@load_seed_data)).to eq(false) |
72 | | - expect(generator.instance_variable_get(:@load_sample_data)).to eq(false) |
73 | | - end |
74 | | - |
75 | | - it 'skips sample data if seeds are disabled' do |
76 | | - generator = described_class.new([], ['--auto-accept', '--seed=false']) |
77 | | - generator.prepare_options |
78 | | - |
79 | | - expect(generator.instance_variable_get(:@run_migrations)).to eq(true) |
80 | | - expect(generator.instance_variable_get(:@load_seed_data)).to eq(false) |
81 | | - expect(generator.instance_variable_get(:@load_sample_data)).to eq(false) |
| 82 | + expect(generator.instance_variable_get(:@run_seeds)).to eq(false) |
| 83 | + expect(generator.instance_variable_get(:@run_sample)).to eq(false) |
82 | 84 | end |
83 | 85 |
|
84 | 86 | context 'supports legacy frontend option names' do |
|
130 | 132 | end |
131 | 133 | end |
132 | 134 |
|
| 135 | + describe "#run_data_loaders" do |
| 136 | + it "executes spree_sample:load task only when sample and seed are enabled" do |
| 137 | + generator = described_class.new([], ['--auto-accept', '--sample=true', '--seed=true']) |
| 138 | + allow(generator).to receive(:say_status_and_run_task) |
| 139 | + |
| 140 | + generator.prepare_options |
| 141 | + generator.run_data_loaders |
| 142 | + |
| 143 | + aggregate_failures do |
| 144 | + expect(generator).to have_received(:say_status_and_run_task).with("seed and sample data", "spree_sample:load") |
| 145 | + expect(generator).not_to have_received(:say_status_and_run_task).with("seed data", "db:seed") |
| 146 | + end |
| 147 | + end |
| 148 | + |
| 149 | + it "does not execute spree_sample:load task when sample is disabled" do |
| 150 | + generator = described_class.new([], ['--auto-accept', '--sample=false', '--seed=true']) |
| 151 | + allow(generator).to receive(:say_status_and_run_task) |
| 152 | + allow(generator).to receive(:say_status) |
| 153 | + |
| 154 | + generator.prepare_options |
| 155 | + generator.run_data_loaders |
| 156 | + |
| 157 | + aggregate_failures do |
| 158 | + expect(generator).to have_received(:say_status_and_run_task).with("seed data", "db:seed AUTO_ACCEPT=1") |
| 159 | + expect(generator).to have_received(:say_status).with(:skipping, "sample data (you can always run rake spree_sample:load)") |
| 160 | + end |
| 161 | + end |
| 162 | + |
| 163 | + it "skips both spree_sample:load and db:seed tasks when task and sample are disabled" do |
| 164 | + generator = described_class.new([], ['--auto-accept', '--sample=false', '--seed=false']) |
| 165 | + allow(generator).to receive(:say_status_and_run_task) |
| 166 | + allow(generator).to receive(:say_status) |
| 167 | + |
| 168 | + generator.prepare_options |
| 169 | + generator.run_data_loaders |
| 170 | + |
| 171 | + aggregate_failures do |
| 172 | + expect(generator).to have_received(:say_status).with(:skipping, "seed data (you can always run rake db:seed)") |
| 173 | + expect(generator).to have_received(:say_status).with(:skipping, "sample data (you can always run rake spree_sample:load)") |
| 174 | + end |
| 175 | + end |
| 176 | + |
| 177 | + it "includes expected rake options for db:seed" do |
| 178 | + generator = described_class.new([], ['--auto-accept', '--sample=false', '--seed=true', '--admin_email=test@solidus.io', '--admin_password=P@55word!']) |
| 179 | + allow(generator).to receive(:say_status_and_run_task) |
| 180 | + allow(generator).to receive(:say_status) |
| 181 | + |
| 182 | + generator.prepare_options |
| 183 | + generator.run_data_loaders |
| 184 | + |
| 185 | + expect(generator).to have_received(:say_status_and_run_task).with("seed data", "db:seed AUTO_ACCEPT=1 ADMIN_EMAIL=test@solidus.io ADMIN_PASSWORD=P@55word!") |
| 186 | + end |
| 187 | + end |
| 188 | + |
133 | 189 | private |
134 | 190 |
|
135 | 191 | def strip_ansi(string) |
|
0 commit comments