Skip to content
Browse files

added a feature for tags and specs for articles and users

  • Loading branch information...
1 parent 3b6ad2a commit e3fe4ecab54d472fecdaf9d84c2ed8e227603e03 @raw1z committed
View
6 app/views/cargo_wiki/articles/index.html.haml
@@ -4,11 +4,13 @@
.toolbar
= link_to 'New Article', new_article_path
-.articles= render 'articles', :articles => @articles
+.articles
+ = render 'articles', :articles => @articles
- if signed_in? and current_user.admin?
- unless @unpublished_articles.empty?
%br
%h1.title #{@tag.blank? ? 'Unpublished Articles' : @tag.name + ' - Unpublished Articles'}
- .unpublished-articles= render 'articles', :articles => @unpublished_articles
+ .unpublished-articles
+ = render 'articles', :articles => @unpublished_articles
View
15 features/article_tags.feature
@@ -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
View
11 features/step_definitions/article_tags_steps.rb
@@ -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
View
8 spec/models/cargo_wiki/article_spec.rb
@@ -1,5 +1,9 @@
require 'spec_helper'
-describe Article do
- pending "add some examples to (or delete) #{__FILE__}"
+describe CargoWiki::Article do
+ 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
View
12 spec/models/cargo_wiki/user_spec.rb
@@ -22,4 +22,16 @@
user.save.should == false
user.errors.messages[:role].should include("can't be blank")
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

0 comments on commit e3fe4ec

Please sign in to comment.
Something went wrong with that request. Please try again.