Skip to content

Commit

Permalink
Merge defc0d9 into 10b2aae
Browse files Browse the repository at this point in the history
  • Loading branch information
ariejan committed Apr 15, 2016
2 parents 10b2aae + defc0d9 commit e685c5f
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env
Expand Up @@ -24,4 +24,4 @@ SERVE_STATIC_ASSETS="true"
# Session secrets - do not change unless you want all sessions to expire
WEB_SESSIONS_SECRET="<< `rake secret` >>"
API_SESSIONS_SECRET="<< `rake secret` >>"
ADMIN_SESSIONS_SECRET="<< `rake secret` >>"
ADMIN_SESSIONS_SECRET="<< `rake secret` >>"
3 changes: 2 additions & 1 deletion .env.test
@@ -1,7 +1,8 @@
# Define ENV variables for test environment

# Database URI
FIREFLY_DATABASE_URL="sqlite://db/firefly_test.sqlite"
DB="sqlite"
FIREFLY_DATABASE_URL="$DB://db/firefly_test.sqlite"
FIREFLY_REDIS_URL=redis://localhost:6379/0

# Top level, short domain name
Expand Down
27 changes: 27 additions & 0 deletions .env.test.mysql
@@ -0,0 +1,27 @@
# Define ENV variables for test environment

# Database URI
FIREFLY_DATABASE_URL="mysql://root@localhost/firefly_test"
FIREFLY_REDIS_URL=redis://localhost:6379/0

# Top level, short domain name
FIREFLY_SHORT_TLD="test.host"

# Should firefly enforce HTTPS? true/false
FIREFLY_SSL_ENABLED="false"

# Admin username/password
ADMIN_USERNAME="admin"
ADMIN_PASSWORD="password"

# API token used by third-party apps to shorten URLs
FIREFLY_API_TOKEN="token"

# Service static assets through Firefly (set to "false" if you have a
# web server sitting in front of Firefly taking care of this.
SERVE_STATIC_ASSETS="true"

# Session secrets - do not change unless you want all sessions to expire
WEB_SESSIONS_SECRET="18746306638e0cbbf9e6963e555c9f4dc855e87213e524d7c8f6feee67f06e23"
API_SESSIONS_SECRET="629d421db660c33840b7c77b2d44e87b907c7853e6c8d0b08bbeacff54a5d45e"
ADMIN_SESSIONS_SECRET="5cb43bc6e474b4bce1f24c4aecba214152cf99b9bebefbb6071697b90e47b8ba"
28 changes: 28 additions & 0 deletions .env.test.sqlite
@@ -0,0 +1,28 @@
# Define ENV variables for test environment

# Database URI
DB="sqlite"
FIREFLY_DATABASE_URL="$DB://db/firefly_test.sqlite"
FIREFLY_REDIS_URL=redis://localhost:6379/0

# Top level, short domain name
FIREFLY_SHORT_TLD="test.host"

# Should firefly enforce HTTPS? true/false
FIREFLY_SSL_ENABLED="false"

# Admin username/password
ADMIN_USERNAME="admin"
ADMIN_PASSWORD="password"

# API token used by third-party apps to shorten URLs
FIREFLY_API_TOKEN="token"

# Service static assets through Firefly (set to "false" if you have a
# web server sitting in front of Firefly taking care of this.
SERVE_STATIC_ASSETS="true"

# Session secrets - do not change unless you want all sessions to expire
WEB_SESSIONS_SECRET="18746306638e0cbbf9e6963e555c9f4dc855e87213e524d7c8f6feee67f06e23"
API_SESSIONS_SECRET="629d421db660c33840b7c77b2d44e87b907c7853e6c8d0b08bbeacff54a5d45e"
ADMIN_SESSIONS_SECRET="5cb43bc6e474b4bce1f24c4aecba214152cf99b9bebefbb6071697b90e47b8ba"
7 changes: 7 additions & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,9 @@ sudo: false
cache: bundler
install: bundle install --jobs=3 --retry=3 --without production

before_script:
- cp .env.test.$DB .env.test

script:
- 'HANAMI_ENV=test bundle exec hanami db create'
- 'HANAMI_ENV=test bundle exec hanami db migrate'
Expand All @@ -13,6 +16,10 @@ rvm:
- 2.3.0
- ruby-head

env:
- DB=sqlite
- DB=mysql

matrix:
allow_failures:
- rvm: ruby-head
8 changes: 7 additions & 1 deletion Gemfile
Expand Up @@ -8,7 +8,13 @@ gem 'hanami-model', '~> 0.5'
gem 'haml'
gem 'sass'

gem 'sqlite3'
case ENV['DB']
when 'mysql'
gem 'mysql'
else
gem 'sqlite3'
end

gem 'redis'

gem 'rqrcode'
Expand Down
2 changes: 1 addition & 1 deletion spec/admin/features/dashboard_spec.rb
Expand Up @@ -6,7 +6,7 @@

@items = []
10.times do |n|
@items << ItemRepository.create(Item.new(type: 'url', content: "https://devroom.io/page-#{n}"))
@items << url_item("https://devroom.io/page-#{n}", age: n)
end

basic_auth('admin', 'password')
Expand Down
4 changes: 2 additions & 2 deletions spec/firefly/repositories/item_repository_spec.rb
Expand Up @@ -4,8 +4,8 @@
before do
ItemRepository.clear

@item1 = url_item("http://test.host/1")
@item2 = url_item("http://test.host/2")
@item1 = url_item("http://test.host/1", age: 2)
@item2 = url_item("http://test.host/2", age: 1)
end

describe '.recent' do
Expand Down
14 changes: 12 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -24,6 +24,16 @@

Hanami::Application.preload!

def url_item(url = 'http://test.host/test')
CreateItemFromURL.new(url).call.item
def url_item(url = 'http://test.host/test', opts = {})
options = {
age: 0
}.merge!(opts)

params = {
type: 'url',
content: url,
created_at: Time.now - options[:age] * 3600
}

ItemRepository.create(Item.new(params))
end

0 comments on commit e685c5f

Please sign in to comment.