Module: MediawikiSelenium::UserFactoryHelper

Defined in:
lib/mediawiki_selenium/helpers/user_factory_helper.rb

Overview

Provisions user accounts automatically using the MW API upon their first reference.

Note you must explicitly enable this functionality by setting user_factory to true in your environments.yml configuration file.

Instance Method Summary collapse

Instance Method Details

#passwordObject

Create account upon the first reference to its username or password.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mediawiki_selenium/helpers/user_factory_helper.rb', line 22

[:user, :password].each do |name|
  config_key = :"mediawiki_#{name}"

  define_method(name) do |id = nil|
    return super(id) unless lookup(:user_factory, default: false)

    alt_id = current_alternative(config_key)

    # When in the context of an alternative, try the explicit value first
    if !alt_id.nil? && alt_id == id
      lookup(config_key, default: -> { factory.create(alt_id)[name] })
    else
      factory.create(id || alt_id)[name]
    end
  end
end

#userObject

Create account upon the first reference to its username or password.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mediawiki_selenium/helpers/user_factory_helper.rb', line 22

[:user, :password].each do |name|
  config_key = :"mediawiki_#{name}"

  define_method(name) do |id = nil|
    return super(id) unless lookup(:user_factory, default: false)

    alt_id = current_alternative(config_key)

    # When in the context of an alternative, try the explicit value first
    if !alt_id.nil? && alt_id == id
      lookup(config_key, default: -> { factory.create(alt_id)[name] })
    else
      factory.create(id || alt_id)[name]
    end
  end
end