Sha256: f40e591733442924b465304d6dd3c3ba345bcb01ca5d95a05630c99f4d41b8b6

Contents?: true

Size: 962 Bytes

Versions: 8

Compression:

Stored size: 962 Bytes

Contents

# Read about factories at https://github.com/thoughtbot/factory_girl

FactoryGirl.define do
  factory :adhoq_query, class: 'Adhoq::Query' do
    name        'A query'
    description 'Simple simple SELECT'
    query       'SELECT 1'

    trait :complex do
      name        'adhoq current use'
      description 'Simple analysys: count execution per query'
      query <<-SQL.strip_heredoc
        SELECT
          q.id
         ,q.name
         ,(
            SELECT COUNT(*)
            FROM  adhoq_executions exec
            INNER JOIN adhoq_reports r ON r.execution_id = exec.id
            WHERE exec.query_id = q.id
          ) AS use_count
        FROM
          adhoq_queries q
        ORDER BY
          use_count DESC, id ASC
      SQL
    end

    trait :greeting do
      name        'greeting'
      description 'Static query for testing data'
      query       'SELECT "hello" AS name ,"English greeting message" AS description'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
adhoq-0.2.0 spec/factories/adhoq_queries.rb
adhoq-0.1.2 spec/factories/adhoq_queries.rb
adhoq-0.1.1 spec/factories/adhoq_queries.rb
adhoq-0.1.0 spec/factories/adhoq_queries.rb
adhoq-0.0.7 spec/factories/adhoq_queries.rb
adhoq-0.0.6 spec/factories/adhoq_queries.rb
adhoq-0.0.5 spec/factories/adhoq_queries.rb
adhoq-0.0.4 spec/factories/adhoq_queries.rb