Refactoring: developer_mode should not be active in test environment

The `rails zammad:bootstrap:{init,reset}` rake tasks
worked for RAILS_ENV=development (default), but not RAILS_ENV=test.

The problem was that the DB seed data would set

    Setting.get('developer_mode')  # false

but then `contrib/auto_wizard_test.json` would re-set it to `true`.
This caused some tests to fail (e.g., spec/models/channel/driver/sms)
where application behavior varied based on the "developer_mode" setting.

This commit ensures that "developer_mode" is only set to `true`
in development by setting it dynamically during DB seeding,
and leaving it alone during the auto-wizard.
This commit is contained in:
Ryan Lue 2020-02-18 15:06:02 +01:00 committed by Thorsten Eckel
parent 52baaea5a8
commit 212e07e322
4 changed files with 5 additions and 9 deletions

View file

@ -58,10 +58,6 @@
} }
], ],
"Settings": [ "Settings": [
{
"name": "developer_mode",
"value": true
},
{ {
"name": "product_name", "name": "product_name",
"value": "Zammad Test System" "value": "Zammad Test System"

View file

@ -72,7 +72,7 @@ Setting.create_if_not_exists(
area: 'Core::Develop', area: 'Core::Develop',
description: 'Defines if application is in developer mode (useful for developer, all users have the same password, password reset will work without email delivery).', description: 'Defines if application is in developer mode (useful for developer, all users have the same password, password reset will work without email delivery).',
options: {}, options: {},
state: false, state: Rails.env.development?,
preferences: { online_service_disable: true }, preferences: { online_service_disable: true },
frontend: true frontend: true
) )

View file

@ -787,14 +787,14 @@ App.Auth.login({
var authWithSession = function() { var authWithSession = function() {
App.Auth.login({ App.Auth.login({
data: { data: {
username: 'nicole.braun@zammad.org', username: 'master@example.com',
password: 'test', password: 'test',
}, },
success: function(data) { success: function(data) {
test('auth - existing user', function() { test('auth - existing user', function() {
ok(true, 'authenticated') ok(true, 'authenticated')
var user = App.Session.get('login') var user = App.Session.get('login')
equal('nicole.braun@zammad.org', user, 'session login') equal('master@example.com', user, 'session login')
}) })
}, },
error: function() { error: function() {
@ -805,4 +805,4 @@ var authWithSession = function() {
}); });
} }
} }

View file

@ -6,7 +6,7 @@ RSpec.describe 'Ticket Create', type: :system do
context 'when applying ticket templates' do context 'when applying ticket templates' do
# Regression test for issue #2424 - Unavailable ticket template attributes get applied # Regression test for issue #2424 - Unavailable ticket template attributes get applied
it 'unavailable attributes do not get applied', authenticated: false do it 'unavailable attributes do not get applied', authenticated: false do
user = create(:agent_user) user = create(:agent_user, password: 'test')
permitted_group = create(:group) permitted_group = create(:group)
unpermitted_group = create(:group) unpermitted_group = create(:group)