Skip to content

Commit

Permalink
added a feature for tags and specs for articles and users
Browse files Browse the repository at this point in the history
  • Loading branch information
raw1z committed Feb 12, 2012
1 parent 3b6ad2a commit e3fe4ec
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/views/cargo_wiki/articles/index.html.haml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
.toolbar .toolbar
= link_to 'New Article', new_article_path = link_to 'New Article', new_article_path


.articles= render 'articles', :articles => @articles .articles
= render 'articles', :articles => @articles


- if signed_in? and current_user.admin? - if signed_in? and current_user.admin?
- unless @unpublished_articles.empty? - unless @unpublished_articles.empty?
%br %br


%h1.title #{@tag.blank? ? 'Unpublished Articles' : @tag.name + ' - Unpublished Articles'} %h1.title #{@tag.blank? ? 'Unpublished Articles' : @tag.name + ' - Unpublished Articles'}
.unpublished-articles= render 'articles', :articles => @unpublished_articles .unpublished-articles
= render 'articles', :articles => @unpublished_articles
15 changes: 15 additions & 0 deletions features/article_tags.feature
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,15 @@
@editor
Feature: Article tags
In order to organize the information
As an editor
I want to tag the articles

Scenario: Assign tags to an article
Given I visit the articles index page
And I click on 'New Article'
And I fill the new article form with valid data
And I tag the article with "foo, bar"
When I click on 'Create'
Then I should be redirected to the new article show page
And I should see the newly created article
And I should see the tags
11 changes: 11 additions & 0 deletions features/step_definitions/article_tags_steps.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,11 @@
Given /^I tag the article with "(.*)"$/ do |tags|
fill_in 'article_tag_list', :with => tags
end

Then /^I should see the tags$/ do
within('.article .tags_list') do
ActsAsTaggableOn::Tag.all.each do |tag|
page.should have_selector('.tag', :text => tag.name)
end
end
end
8 changes: 6 additions & 2 deletions spec/models/cargo_wiki/article_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,9 @@
require 'spec_helper' require 'spec_helper'


describe Article do describe CargoWiki::Article do
pending "add some examples to (or delete) #{__FILE__}" it "validates the presence of the title" do
@article = FactoryGirl.build(:article, :title => "")
@article.save.should == false
@article.errors.messages[:title].should include("can't be blank")
end
end end
12 changes: 12 additions & 0 deletions spec/models/cargo_wiki/user_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,4 +22,16 @@
user.save.should == false user.save.should == false
user.errors.messages[:role].should include("can't be blank") user.errors.messages[:role].should include("can't be blank")
end end

it "validates the presence of the password" do
user = FactoryGirl.build(:user, :password => "")
user.save.should == false
user.errors.messages[:password].should include("can't be blank")
end

it "validates the presence of the password confirmation" do
user = FactoryGirl.build(:user, :password_confirmation => "")
user.save.should == false
user.errors.messages[:password].should include("doesn't match confirmation")
end
end end

0 comments on commit e3fe4ec

Please sign in to comment.