Skip to content

Commit

Permalink
Fixed whitespace in stories.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemens committed Sep 20, 2008
1 parent 6c36436 commit d129485
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 260 deletions.
3 changes: 1 addition & 2 deletions stories/factories/articles.rb
Expand Up @@ -29,7 +29,6 @@
:categories => lambda{ [Category.find_by_title('a category') || create_category] },
:tag_list => 'foo bar'

factory :published_article,
factory :published_article,
valid_article_attributes.update(:published_at => '2008-01-01 12:00:00'),
:class => :article

1 change: 0 additions & 1 deletion stories/factories/forum.rb
Expand Up @@ -18,4 +18,3 @@
:site => lambda{ Site.find(:first) || create_site },
:section => lambda{ (Forum.find(:first) || create_forum).id },
:author => lambda{ User.find(:first) || create_user }

10 changes: 4 additions & 6 deletions stories/factories/sections.rb
Expand Up @@ -4,16 +4,14 @@

factory :section,
:site => lambda{ Site.find(:first) || create_site },
:type => 'Section',
:type => 'Section',
:title => 'the Section title'

factory :blog, valid_section_attributes.update(:type => 'Blog', :title => 'the blog title'),
:class => :section

factory :wiki, valid_section_attributes.update(:type => 'Wiki', :title => 'the wiki title'),
:class => :section

factory :forum, valid_section_attributes.update(:type => 'Forum', :title => 'the forum title'),
:class => :section


1 change: 0 additions & 1 deletion stories/factories/site.rb
Expand Up @@ -4,4 +4,3 @@
:name => 'name',
:title => 'title',
:host => 'www.example.com'

15 changes: 7 additions & 8 deletions stories/factories/user.rb
@@ -1,19 +1,18 @@
User.delete_all

factory :user,
:name => 'name',
:email => 'email@email.org',
factory :user,
:name => 'name',
:email => 'email@email.org',
:login => 'login',
:password => 'password',
:password => 'password',
:password_confirmation => 'password'

factory :author, valid_user_attributes, :class => :user

factory :verified_user, valid_user_attributes.update(:verified_at => '2008-01-01 12:00:00'), :class => :user

Anonymous.delete_all

# factory :anonymous,
# :name => 'anonymous',
# factory :anonymous,
# :name => 'anonymous',
# :email => 'anonymous@email.org'

2 changes: 1 addition & 1 deletion stories/factories/wikipages.rb
Expand Up @@ -10,4 +10,4 @@
:section => lambda{ Wiki.find(:first) || create_wiki },
:author => lambda{ User.find(:first) || create_user },
:categories => lambda{ [Category.find_by_title('a category') || create_category] },
:tag_list => 'foo bar'
:tag_list => 'foo bar'
2 changes: 1 addition & 1 deletion stories/helper.rb
Expand Up @@ -56,5 +56,5 @@ def have_form_putting_to(url_or_path)
have_tag("form[method=post][action=#{url_or_path}]").matches?(response)
have_tag("input[name=_method][type=hidden][value=put]").matches?(response)
end
end
end
end
2 changes: 1 addition & 1 deletion stories/run.rb
Expand Up @@ -9,5 +9,5 @@
paths.each do |path|
with_steps_for *steps(:all) do
run path, :type => RailsStory
end
end
end
22 changes: 11 additions & 11 deletions stories/steps/article.rb
Expand Up @@ -4,26 +4,26 @@
Given 'the article does not allow commenting' do
@article.update_attributes! :comment_age => -1
end

Given "the article has no comments" do
@article.comments.clear
end

Given "the article has a comment" do
Comment.delete_all
@comment = create_comment :commentable => @article
end

Given "the article has an approved comment" do
Given "the article has a comment"
@comment.update_attributes! :approved => true
end

Given "the article has an unapproved comment" do
Given "the article has a comment"
@comment.update_attributes! :approved => false
end

Then "the article has an unapproved comment" do
@article.unapproved_comments.count.should == 1
@comment = @article.unapproved_comments.first
Expand All @@ -38,15 +38,15 @@
raise "step expects @article_count to be set" unless @article_count
(@article_count - 1).should == Article.find(:all).size
end

# ADMIN VIEW

When "the user visits the admin $section articles list page" do |section|
raise "step expects the variable @blog or @section to be set" unless @blog or @section
section = @blog || @section
get admin_articles_path(section.site, section)
end

When "the user creates and publishes a new article" do
lambda {
When "the user visits the admin blog article creation page"
Expand Down Expand Up @@ -104,7 +104,7 @@
request.request_uri.should =~ %r(/admin/sites/[\d]*/sections/[\d]*/articles)
response.should render_template("admin/blog/index")
end

Then "the user is redirected to the admin section articles page" do
request.request_uri.should =~ %r(/admin/sites/[\d]*/sections/[\d]*/articles)
response.should render_template("admin/articles/index")
Expand All @@ -118,10 +118,10 @@
Then "the 'Save as draft?' checkbox is checked by default" do
response.should have_tag("input#article-draft[type=?][value=?]", 'checkbox', 1)
end
# Then "the blog has sent pings" do

# Then "the blog has sent pings" do
# end

Then "the page displays the article" do
raise "step expects the variable @article to be set" unless @article
response.should have_tag("div#article_#{@article.id}.entry")
Expand Down
26 changes: 13 additions & 13 deletions stories/steps/asset.rb
Expand Up @@ -2,22 +2,22 @@
Given "a site with an asset" # do
# Given "a site"
#end

When "the user visits admin sites assets list page" do
raise "this step expects the variable @site to be set" unless @site
get admin_assets_path(@site)
end

When "the user fills in the admin asset creation form with valid values" do
attaches_file 'assets[0][uploaded_data]', RAILS_ROOT + '/public/images/rails.png'
fills_in 'assets[0][title]', :with => 'title'
fills_in 'assets[0][tag_list]', :with => 'foo bar'
end

When "the user fills in the admin asset edit form" do
fills_in 'asset[title]', :with => 'updated title'
end

When "the user adds an asset to the bucket" do
post "/admin/sites/#{@site.id}/assets/bucket?asset_id=#{@asset.id}"
end
Expand All @@ -28,7 +28,7 @@
response.should have_form_posting_to(action)
@asset_count = Asset.count
end

Then "a new asset is saved" do
raise "this step expects the variable @asset_count to be set" unless @asset_count
(@asset_count + 1).should == Asset.count
Expand All @@ -39,28 +39,28 @@
request.request_uri.should =~ %r(/admin/sites/[\d]*/assets)
response.should render_template("admin/assets/index")
end

Then "the page has a list of assets with at least one asset" do
response.should have_tag('#assets-list .assets-row div img')
end

Then "the page has an admin asset edit form" do
response.should have_form_putting_to(admin_asset_path(@site, @asset))
end

Then "the asset is updated" do
@asset.reload
@asset.title = 'updated title'
end
end

Then "the asset is deleted" do
Asset.exists?(@asset.id).should be_false
end
end

Then "the asset is added to the bucket" do
session[:bucket].keys.should include(@asset.id)
end

Then "the asset immediately shows up on the page" do
response.should have_text(%r(new Insertion.Bottom\("bucket-assets",.*#{@asset.filename}))
response.should_not have_text(%r(<html.*>)) # no layout
Expand Down
51 changes: 25 additions & 26 deletions stories/steps/authentication.rb
@@ -1,13 +1,13 @@
factories :user

steps_for :authentication do
Given "the user is logged in" do
Given "the user is logged in" do
Given "a user"
@user.verified!
@user.verified!
post "/session", :user => {:login => @user.login, :password => 'password'}
controller.authenticated?.should be_true
end

Given "the user is logged in as $role" do |role|
User.delete_all
@user = create_user :name => role, :email => "#{role}@email.org", :login => role
Expand All @@ -16,29 +16,29 @@
@site ||= Site.find(:first) || create_site
@site.users << @user
@user.roles << Role.build(role.to_sym, @site)
else
else
@user.roles << Role.build(role.to_sym)
end
@user.verified!

post "/session", :user => {:login => @user.login, :password => @user.password}
controller.authenticated?.should be_true
end
end

Given "a verified user" do
Given "a user"
Given "a user"
@user.verified!
end

Given "an unverified user" do
Given "a user"
Given "a user"
@user.update_attributes! :verified_at => nil
end

When "the user goes to the login page" do
get login_path
end

When "the user goes to the user registration page" do
get new_account_path
end
Expand All @@ -60,60 +60,59 @@
fills_in :password, :with => 'password'
fills_in "Password confirmation", :with => 'password'
end

When "the user verifies their account" do
token = @user.assign_token! 'verify'
AccountController.hidden_actions.delete 'verify'
AccountController.instance_variable_set(:@action_methods, nil)
get "/account/verify?token=#{@user.id}%3B#{token}"
@user = controller.current_user
end

Then "the user is verified" do
@user.verified?.should be_true
end

Then "an unverified user exists" do
@user = User.find(:first)
@user.verified?.should be_false
end
end

Then "the page has a login form" do
response.should have_form_posting_to(session_path)
end

Then "the page has a user registration form" do
response.should have_form_posting_to(account_path)
end

Then "the system authenticates the user" do
controller.current_user.should == @user
end

Then "the system does not authenticate the user" do
controller.current_user.should be_nil
end

Then "the system authenticates the user as a known anonymous" do
controller.current_user.should == @anonymous
end

Then "the anonymous id is saved to a cookie" do
cookies['aid'].should == @anonymous.id.to_s
end

Then "the system authenticates the user as $role" do |role|
Then "the system authenticates the user"
@user.has_role?(role.to_sym).should be_true
end

Then "a verification email is sent to the user's email address" do
ActionMailer::Base.deliveries.first.should_not be_nil
end

Then "the user sees the login page" do
request.request_uri.should == login_path
response.should render_template('session/new')
end

end

0 comments on commit d129485

Please sign in to comment.