You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by as...@apache.org on 2008/08/20 07:48:36 UTC
svn commit: r687248 - in /ode/sandbox/singleshot:
config/initializers/locale/en-US.rb lib/tasks/development.rake
lib/tasks/setup.rake spec/controllers/activity_controller_spec.rb
spec/people.rb
Author: assaf
Date: Tue Aug 19 22:48:35 2008
New Revision: 687248
URL: http://svn.apache.org/viewvc?rev=687248&view=rev
Log:
Merge branch 'dev'
Modified:
ode/sandbox/singleshot/config/initializers/locale/en-US.rb
ode/sandbox/singleshot/lib/tasks/development.rake
ode/sandbox/singleshot/lib/tasks/setup.rake
ode/sandbox/singleshot/spec/controllers/activity_controller_spec.rb
ode/sandbox/singleshot/spec/people.rb
Modified: ode/sandbox/singleshot/config/initializers/locale/en-US.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/initializers/locale/en-US.rb?rev=687248&r1=687247&r2=687248&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/initializers/locale/en-US.rb (original)
+++ ode/sandbox/singleshot/config/initializers/locale/en-US.rb Tue Aug 19 22:48:35 2008
@@ -1,8 +1,17 @@
I18n.backend.store_translations :'en-US', {
- :activities => {
+ :activity => {
:index => {
:title => "Activities",
:subtitle => "Activity from all tasks you own or observe"
- }
+ },
+ :name => {
+ :created => "created",
+ :owner => "is owner of"
+ },
+ :entry => {
+ :text => "{{person}} {{names}} {{task}}",
+ :html => "{{person}} {{names}} {{task}}"
+ },
+ :sentence => "{{person}} {{list}} {{task}}"
}
}
Modified: ode/sandbox/singleshot/lib/tasks/development.rake
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/lib/tasks/development.rake?rev=687248&r1=687247&r2=687248&view=diff
==============================================================================
--- ode/sandbox/singleshot/lib/tasks/development.rake (original)
+++ ode/sandbox/singleshot/lib/tasks/development.rake Tue Aug 19 22:48:35 2008
@@ -1,10 +1,15 @@
desc 'Run development server on port 3000'
task 'run' do
at_exit do
- puts 'Stopping Thin ...'
- system 'thin stop -s2'
+ task('stop').invoke
end
puts 'Starting Thin ...'
- system "thin start -d -s2 -p #{ENV['PORT'] || '3000'}"
+ system "thin start -s2 -p #{ENV['PORT'] || '3000'} -a localhost"
system 'tail -f log/development.log'
end
+
+desc 'Stop development server (if running)'
+task 'stop' do
+ puts 'Stopping Thin ...'
+ system 'thin stop -s2'
+end
\ No newline at end of file
Modified: ode/sandbox/singleshot/lib/tasks/setup.rake
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/lib/tasks/setup.rake?rev=687248&r1=687247&r2=687248&view=diff
==============================================================================
--- ode/sandbox/singleshot/lib/tasks/setup.rake (original)
+++ ode/sandbox/singleshot/lib/tasks/setup.rake Tue Aug 19 22:48:35 2008
@@ -9,4 +9,25 @@
end
desc 'Run this task first to setup your test/development environment'
-task 'setup'=>['secret.key', 'gems:install', 'db:create', 'db:test:clone', 'db:populate']
+task 'setup'=>['gems:install', 'plugins:install', 'secret.key', 'db:create', 'db:test:clone', 'db:populate']
+
+namespace 'plugins' do
+ task 'install' do
+ rb_bin = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+ puts "Installing rspec plugin from Github"
+ system 'rb_bin', 'script/plugin', 'git://github.com/dchelimsky/rspec.git'
+ system 'rb_bin', 'script/plugin', 'git://github.com/dchelimsky/rspec-rails.git'
+ end
+
+ task 'list' do
+ plugins = Dir["#{Rails.root}/vendor/plugins/*"].map { |path| Rails::Plugin.new(path) }
+ plugins.each do |plugin|
+ puts "Plugin: #{plugin.name}\n(#{plugin.directory})"
+ width = plugin.about.keys.map(&:size).max
+ plugin.about.each do |key, value|
+ puts " %#{width}s: %s" % [key, value]
+ end
+ puts
+ end
+ end
+end
Modified: ode/sandbox/singleshot/spec/controllers/activity_controller_spec.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/spec/controllers/activity_controller_spec.rb?rev=687248&r1=687247&r2=687248&view=diff
==============================================================================
--- ode/sandbox/singleshot/spec/controllers/activity_controller_spec.rb (original)
+++ ode/sandbox/singleshot/spec/controllers/activity_controller_spec.rb Tue Aug 19 22:48:35 2008
@@ -28,19 +28,67 @@
response.should redirect_to(session_url)
end
- describe 'response' do
- before :each do
- authenticate
- get 'index'
- end
-
- it "should have 'Activities' in the title" do
- assigns[:title].should == 'Activities'
- end
-
- it "should expand on the title in the subtitle" do
- assigns[:subtitle].should == "Activity from all tasks you own or observe"
- end
+ it "should have 'Activities' in the title" do
+ authenticate ; get 'index'
+ assigns[:title].should == 'Activities'
+ end
+
+ it "should expand on the title in the subtitle" do
+ authenticate ; get 'index'
+ assigns[:subtitle].should == "Activity from all tasks you own or observe"
+ end
+
+ it 'should return activities for stakeholder with dependents and pagination' do
+ paginated = (with_dependents = (for_stakeholder = Activity.for_stakeholder(person))).paginate(:page=>nil)
+ Activity.should_receive(:for_stakeholder).with(person).and_return(for_stakeholder)
+ for_stakeholder.should_receive(:with_dependents).and_return(with_dependents)
+ with_dependents.should_receive(:paginate).and_return(paginated)
+ authenticate ; get 'index'
+ assigns[:activities].should == paginated
+ end
+
+ it "should paginate using query parameter 'page' and 50 items per page" do
+ paginated = (with_dependents = (for_stakeholder = Activity.for_stakeholder(person))).paginate(:page=>nil)
+ Activity.should_receive(:for_stakeholder).with(person).and_return(for_stakeholder)
+ for_stakeholder.should_receive(:with_dependents).and_return(with_dependents)
+ with_dependents.should_receive(:paginate).with(:page=>'5', :per_page=>50).and_return(paginated)
+ authenticate ; get 'index', :page=>'5'
+ end
+
+ it 'should provide link to next result page (HTML only)' do
+ paginated = mock('activities')
+ Activity.stub!(:for_stakeholder).and_return(paginated)
+ paginated.stub!(:method_missing).and_return(paginated)
+ paginated.stub!(:next_page).and_return(2)
+ authenticate ; get 'index', :page=>'1'
+ assigns[:next].should == activity_url(:page=>'2')
end
+ it 'should provide link to previous result page (HTML only)' do
+ paginated = mock('activities')
+ Activity.stub!(:for_stakeholder).and_return(paginated)
+ paginated.stub!(:method_missing).and_return(paginated)
+ paginated.stub!(:previous_page).and_return(1)
+ authenticate ; get 'index', :page=>'2'
+ assigns[:previous].should == activity_url(:page=>'1')
+ end
+
+ it 'should provide link to Atom feed (HTML only)' do
+ authenticate ; get 'index', :page=>'2'
+ assigns[:atom_feed_url].should == formatted_activity_url(:format=>:atom, :access_key=>authenticated.access_key)
+ end
+
+ it 'should include graph with all activities in the past month (HTML only)' do
+ for_stakeholder = Activity.for_stakeholder(person)
+ Activity.should_receive(:for_stakeholder).and_return(for_stakeholder)
+ graph = for_stakeholder.for_dates(Date.current - 1.month)
+ for_stakeholder.should_receive(:for_dates).and_return(graph)
+ authenticate ; get 'index'
+ assigns[:graph].should == graph
+ end
+
+ it 'should set root_url to /activities (Atom onlu)' do
+ authenticate ; get 'index', :format=>'atom'
+ assigns[:root_url].should == activity_url
+ end
end
Modified: ode/sandbox/singleshot/spec/people.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/spec/people.rb?rev=687248&r1=687247&r2=687248&view=diff
==============================================================================
--- ode/sandbox/singleshot/spec/people.rb (original)
+++ ode/sandbox/singleshot/spec/people.rb Tue Aug 19 22:48:35 2008
@@ -7,7 +7,7 @@
end
end
- def person(identity)
+ def person(identity = 'person')
Person.identify(identity) rescue Person.create!(:email=>"#{identity}@apache.org", :password=>'secret')
end
@@ -28,13 +28,16 @@
#
# Without arguments, authenticates as 'person'.
def authenticate(person = person('person'))
- previous, session[:person_id] = session[:person_id], person.id
if block_given?
begin
+ previous, session[:person_id] = session[:person_id], person.id
yield
ensure
session[:person_id] = previous
end
+ else
+ session[:person_id] = person.id
+ person
end
end