Skip to content

Commit

Permalink
Merge pull request publify#2 from jeady/master
Browse files Browse the repository at this point in the history
Add cucumber starter features, merge in fdv/typo
  • Loading branch information
Richard Xia committed Aug 9, 2012
2 parents a47e282 + eb2362a commit 396d8ee
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 28 deletions.
7 changes: 1 addition & 6 deletions app/controllers/admin/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ def destroy

def new_or_edit
@categories = Category.find(:all)
@category = case params[:id]
when nil
Category.new
else
Category.find(params[:id])
end
@category = Category.find(params[:id])
@category.attributes = params[:category]
if request.post?
respond_to do |format|
Expand Down
6 changes: 6 additions & 0 deletions features/create_blog.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ Feature: Create Blog
Given I am on the home page
Then I should see "Welcome"
And I should see "My Shiny Weblog!"

Scenario: Create blog page not shown when blog created
Given the blog is set up
When I am on the home page
Then I should not see "My Shiny Weblog!"
And I should see "Teh Blag"
24 changes: 24 additions & 0 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ def with_scope(locator)
end
World(WithinHelpers)

Given /^the blog is set up$/ do
Blog.default.update_attributes!({:blog_name => 'Teh Blag',
:base_url => 'http://localhost:3000'});
Blog.default.save!
User.create!({:login => 'admin',
:password => 'aaaaaaaa',
:email => 'joe@snow.com',
:profile_id => 1,
:name => 'admin',
:state => 'active'})
end

And /^I am logged into the admin panel$/ do
visit '/accounts/login'
fill_in 'user_login', :with => 'admin'
fill_in 'user_password', :with => 'aaaaaaaa'
click_button 'Login'
if page.respond_to? :should
page.should have_content('Login successful')
else
assert page.has_content?('Login successful')
end
end

# Single-line step scoper
When /^(.*) within (.*[^:])$/ do |step, parent|
with_scope(parent) { When step }
Expand Down
2 changes: 2 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def path_to(page_name)

when /^the home\s?page$/
'/'
when /^the new article page$/
'/admin/content/new'

# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
Expand Down
19 changes: 19 additions & 0 deletions features/write_article.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: Write Articles
As a blog administrator
In order to share my thoughts with the world
I want to be able to add articles to my blog

Background:
Given the blog is set up
And I am logged into the admin panel

Scenario: Successfully write articles
Given I am on the new article page
When I fill in "article_title" with "Foobar"
And I fill in "article__body_and_extended_editor" with "Lorem Ipsum"
And I press "Publish"
Then I should be on the admin content page
When I go to the home page
Then I should see "Foobar"
When I follow "Foobar"
Then I should see "Lorem Ipsum"
22 changes: 0 additions & 22 deletions spec/controllers/admin/categories_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,6 @@
assert_response :redirect, :action => 'index'
end

it "test_create" do
cat = Factory(:category)
Category.should_receive(:find).with(:all).and_return([])
Category.should_receive(:new).and_return(cat)
cat.should_receive(:save!).and_return(true)
post :edit, 'category' => { :name => "test category" }
assert_response :redirect
assert_redirected_to :action => 'new'
end

describe "test_new" do
before(:each) do
get :new
end

it 'should render template view' do
assert_template 'new'
assert_tag :tag => "table",
:attributes => { :id => "category_container" }
end
end

describe "test_edit" do
before(:each) do
get :edit, :id => Factory(:category).id
Expand Down

0 comments on commit 396d8ee

Please sign in to comment.