Module: BcmsSupport::Shared

Included in:
Cucumber, Test
Defined in:
lib/bcms_support/shared.rb

Constant Summary collapse

TABLES_WITH_SEED_DATA =
%w[connectors content_type_groups content_types group_permissions group_sections 
group_type_permissions group_types groups html_block_versions html_blocks pages
page_versions permissions section_nodes sections sites user_group_memberships 
users]
SEEDS_PATH =
File.join(File.dirname(__FILE__), '..','..','seeds')

Instance Method Summary collapse

Instance Method Details

#publish_all_pagesObject



11
12
13
# File 'lib/bcms_support/shared.rb', line 11

def publish_all_pages
  Page.all.each(&:publish)
end

#seed_bcms_dataObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bcms_support/shared.rb', line 15

def seed_bcms_data
  TABLES_WITH_SEED_DATA.each do |t|
    ActiveRecord::Base.transaction do 
      YAML.load_file(SEEDS_PATH + "/#{t}.yml").each do |f|
        sql =  "INSERT INTO #{t} (#{f.keys.join(",")})"
        sql << "VALUES (#{f.values.map { |v| ActiveRecord::Base.connection.quote(v) }.join(",")})"
        ActiveRecord::Base.connection.execute(sql) 
      end        
    end         
  end
end