Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller_monkey.rb

Instance Method Summary collapse

Instance Method Details

#set_themeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/action_controller_monkey.rb', line 6

def set_theme
  session["run_count"] = 0 unless session["run_count"].present?
  session["run_count"] += 1

  if session["run_count"] <= 1
    affirmation_path = "./" + SelfSysteem.test_dir + "/system/support/affirmations/" + ENV["SYSTEEM"] + ".yml"

    if File.exist?(affirmation_path)
      affirmation_requirements = YAML.load_file(affirmation_path)[:requirements].last

      session_path = ("./" + SelfSysteem.test_dir + "/system/support/affirmations/" +
                                       affirmation_requirements.to_s +
                                       "_session.yml")

      db_path = ("./" + SelfSysteem.test_dir + "/system/support/affirmations/" +
                                       affirmation_requirements.to_s +
                                       "_db.yml")

      if File.exist?(session_path)
        systeem_session = YAML.load_file(session_path)

        systeem_session.each_pair do |k, v|
          unless ["session_id", "_csrf_token"].include?(k)
            session[k] ||= systeem_session[k]
          end
        end
      end

      if File.exist?(db_path)
        YamlDbSynch.load(db_path)
      end
    else
      Rails.application.load_seed
    end

  end

end