Browse Source

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.
Ryan Lue 5 years ago
parent
commit
212e07e322

+ 0 - 4
contrib/auto_wizard_test.json

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

+ 1 - 1
db/seeds/settings.rb

@@ -72,7 +72,7 @@ Setting.create_if_not_exists(
   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).',
   options:     {},
-  state:       false,
+  state:       Rails.env.development?,
   preferences: { online_service_disable: true },
   frontend:    true
 )

+ 3 - 3
public/assets/tests/core.js

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

+ 1 - 1
spec/system/ticket/create_spec.rb

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