-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update specs and correct some problems.
- Loading branch information
1 parent
55b68f8
commit a705172
Showing
17 changed files
with
370 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default: --format progress features --tags ~@proposed,~@in_progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Sets up the Rails environment for Cucumber | ||
ENV["RAILS_ENV"] = "test" | ||
# Extension root | ||
extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment') | ||
require extension_env+'.rb' | ||
|
||
Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step} | ||
|
||
Cucumber::Rails::World.class_eval do | ||
include Dataset | ||
datasets_directory "#{RADIANT_ROOT}/spec/datasets" | ||
Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets') | ||
self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset" | ||
|
||
# dataset :scheduler | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
def path_to(page_name) | ||
case page_name | ||
|
||
when /the homepage/i | ||
root_path | ||
|
||
when /login/i | ||
login_path | ||
# Add more page name => path mappings here | ||
|
||
else | ||
raise "Can't find mapping from \"#{page_name}\" to a path." | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
module Scheduler::ControllerExtensions | ||
def self.included(base) | ||
base.class_eval { alias_method_chain :process_page, :scheduling } | ||
base.class_eval { around_filter :filter_with_scheduler } | ||
end | ||
|
||
def process_page_with_scheduling(page) | ||
|
||
protected | ||
def filter_with_scheduler | ||
if live? | ||
Page.with_published_only { process_page_without_scheduling(page) } | ||
Page.with_published_only { yield } | ||
else | ||
process_page_without_scheduling(page) | ||
yield | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require File.dirname(__FILE__) + "/../spec_helper" | ||
|
||
describe "Scheduler::ControllerExtensions", :type => :controller do | ||
dataset :pages_with_scheduling | ||
controller_name :site | ||
|
||
it "should not render invisible pages in live mode" do | ||
get :show_page, :url => ['expired'] | ||
response.should_not be_success | ||
end | ||
|
||
it "should render invisible pages in dev mode" do | ||
request.host = "dev.example.com" | ||
get :show_page, :url => ['expired'] | ||
response.should be_success | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class PagesWithSchedulingDataset < Dataset::Base | ||
uses :pages | ||
|
||
def load | ||
create_page "Expired", :appears_on => 2.days.ago.to_date, :expires_on => Date.yesterday | ||
create_page "Expired blank start", :expires_on => Date.yesterday | ||
create_page "Blank schedule" | ||
create_page "Visible blank start", :expires_on => Date.tomorrow | ||
create_page "Visible", :appears_on => Date.yesterday, :expires_on => Date.tomorrow | ||
create_page "Visible blank end", :appears_on => Date.yesterday | ||
create_page "Unappeared blank end", :appears_on => Date.tomorrow | ||
create_page "Unappeared", :appears_on => Date.tomorrow, :expires_on => 2.days.from_now.to_date | ||
end | ||
end |
Oops, something went wrong.
@seancribbs surprise! somebody is still using that code you wrote 8 years ago :)
Every so many requests, the scope is not applied. I first thought it had to do with the Date.today not being lambda'd and server processes older than the expires_on date, but after patching that the problem persists.
Seems to happen when the server is busier... It looks like @with_published can not be false again before the block is yielded, yet that seems to be what's happening...
I don't understand why the instance variable was introduced in the first place... do you happen to remember how things could go bad if I was to strip out the whole if clause? Any other thoughts?