qcourses 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --backtrace
@@ -1,11 +1,12 @@
1
1
 
2
2
  desc "project console"
3
3
  task :console => :environment do
4
- sh "irb -I #{File.expand_path('lib', File.dirname(__FILE__)) } -r qcourses"
4
+ sh "irb -I #{File.expand_path('../../lib', File.dirname(__FILE__)) } -r qcourses"
5
5
  end
6
6
 
7
7
  desc "project environment"
8
8
  task :environment do
9
+ p "setting environment"
9
10
  ENV['RACK_ENV'] ||= 'development'
10
11
  end
11
12
 
@@ -13,7 +14,7 @@ namespace :db do
13
14
  desc "migrate the database"
14
15
  task :migrate, [:version] => :environment do |t, args|
15
16
  migration_dir = File.expand_path('../../db/migrations', File.dirname(__FILE__))
16
- command = ["sequel -E config/database.yml -m #{migration_dir}"]
17
+ command = ["sequel -e #{ENV['RACK_ENV']} -E config/database.yml -m #{migration_dir}"]
17
18
  command << "-M #{args[:version]}" if args[:version]
18
19
  sh command.join(' ')
19
20
  end
@@ -1,3 +1,3 @@
1
1
  module Qcourses
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -31,6 +31,11 @@ module Qcourses
31
31
  end
32
32
  end
33
33
 
34
+ def event_registration_link(event)
35
+ return "closed" unless event.open
36
+ haml "%a{ :href=> url('/registrations/new/#{event.id}') } register"
37
+ end
38
+
34
39
  def input_for(object, attribute_name, options={})
35
40
  object = instance_variable_get("@#{object}") if object.is_a?(Symbol)
36
41
  return '' unless object
@@ -4,7 +4,9 @@ module Qcourses
4
4
  describe ViewHelpers do
5
5
  require 'sinatra'
6
6
  let(:template_cache) { Tilt::Cache.new }
7
+ let(:app) { Sinatra::Base.new }
7
8
  include Sinatra::Templates
9
+ include Sinatra::Helpers
8
10
  include ViewHelpers
9
11
 
10
12
  describe 'human_period' do
@@ -116,5 +118,24 @@ module Qcourses
116
118
  end
117
119
  end
118
120
  end
121
+
122
+ describe "event_registration_link", :focus => true do
123
+ def html_for(result)
124
+ Capybara.string(result)
125
+ end
126
+ def url(addr = nil, absolute = true, add_script_name = true)
127
+ addr
128
+ end
129
+ let(:event) { Rubory.build :event }
130
+ it "contains a registration link" do
131
+ p event
132
+ html_for(event_registration_link(event)).should have_selector("a[href='/registrations/new/#{event.id}']")
133
+ end
134
+ it "contains no registration link if event is closed" do
135
+ event.open = false
136
+ html_for(event_registration_link(event)).should_not have_selector("a[href='/registrations/new/#{event.id}']")
137
+ html_for(event_registration_link(event)).should have_content("closed")
138
+ end
139
+ end
119
140
  end
120
141
  end
@@ -10,7 +10,7 @@
10
10
  .event_subtitle
11
11
  = event.subtitle
12
12
  .event_registration
13
- %a{ :href=> url("/registrations/new/#{event.id}") } register
13
+ = event_registration_link(event)
14
14
  .event_date_location
15
15
  = human_period event.from, event.to
16
16
  %br
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qcourses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-25 00:00:00.000000000Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubyforge_project: qcourses
246
- rubygems_version: 1.8.18
246
+ rubygems_version: 1.8.21
247
247
  signing_key:
248
248
  specification_version: 3
249
249
  summary: Small course event module for sinatra site