Skip to content

Commit

Permalink
Fix all spec
Browse files Browse the repository at this point in the history
  • Loading branch information
shingara committed Mar 10, 2009
1 parent e626842 commit e4bd70a
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/models/article.rb
Expand Up @@ -215,7 +215,7 @@ def html_urls
def really_send_pings(serverurl = blog.base_url, articleurl = nil)
return unless blog.send_outbound_pings

articleurl ||= permalink_url(nil, false)
articleurl ||= permalink_url(nil)

weblogupdatesping_urls = blog.ping_urls.gsub(/ +/,'').split(/[\n\r]+/)
pingback_or_trackback_urls = self.html_urls
Expand Down
73 changes: 54 additions & 19 deletions spec/controllers/admin/tags_controller_spec.rb
Expand Up @@ -5,31 +5,66 @@
# Re-raise errors caught by the controller.
class Admin::TagsController; def rescue_action(e) raise e end; end


describe Admin::TagsController do
before do
request.session = { :user => users(:tobi).id }
end

def test_index
get :index
assert_template 'index'
assert_template_has 'tags'
describe 'index action' do
before :each do
get :index
end

it 'should be success' do
response.should be_success
end

it 'should render template index' do
response.should render_template('index')
end

end

def test_edit
get :edit, 'id' => contents(:article1).tags.first.id
assert_template 'edit'
assert_template_has 'tag'
assert_valid assigns(:tag)


describe 'edit action' do
before(:each) do
@tag_id = contents(:article1).tags.first.id
get :edit, :id => @tag_id
end

it 'should be success' do
response.should be_success
end

it 'should render template edit' do
response.should render_template('edit')
end

it 'should assigns value :tag' do
assert_valid assigns(:tag)
end

end

def test_update
tag = Tag.find_by_id(contents(:article1).tags.first.id)
post :edit, 'id' => tag.id, 'tag' => {:name => 'foobar', :display_name => 'Foo Bar'}
assert_response :redirect, :action => 'index'
tag = Tag.find_by_id(contents(:article1).tags.first.id)
assert_equal "foobar", tag.name
assert_equal "Foo Bar", tag.display_name


describe 'update action' do

before :each do
@tag = Tag.find_by_id(contents(:article1).tags.first.id)
post :edit, 'id' => @tag.id, 'tag' => {:name => 'foobar', :display_name => 'Foo Bar'}
end

it 'should redirect to index' do
response.should redirect_to(:action => 'index')
end

it 'should update tag' do
@tag.reload
@tag.name.should == 'foobar'
@tag.display_name == "Foo Bar"
end

end

end
end
4 changes: 2 additions & 2 deletions spec/controllers/comments_controller_spec.rb
Expand Up @@ -76,7 +76,7 @@ def make_the_request(comment = {:body => 'content', :author => 'bob'})

it "should redirect to the article" do
make_the_request
response.should redirect_to("#{blogs(:default).base_url}/#{contents(:article1).created_at.year}/#{sprintf("%.2d", contents(:article1).created_at.month)}/#{contents(:article1).created_at.day}/#{contents(:article1).permalink}")
response.should redirect_to("#{blogs(:default).base_url}/#{contents(:article1).created_at.year}/#{sprintf("%.2d", contents(:article1).created_at.month)}/#{sprintf("%.2d", contents(:article1).created_at.day)}/#{contents(:article1).permalink}")
end
end

Expand Down Expand Up @@ -108,7 +108,7 @@ def make_the_request(comment = {:body => 'content', :author => 'bob'})
it "GET 2007/10/11/slug/comments should redirect to /2007/10/11/slug#comments" do
#content(:article1) => Time.now - 2 days
get 'index', :article_id => @article.id
response.should redirect_to("#{blogs(:default).base_url}/#{contents(:article1).created_at.year}/#{sprintf("%.2d", contents(:article1).created_at.month)}/#{contents(:article1).created_at.day}/#{contents(:article1).permalink}#comments")
response.should redirect_to("#{blogs(:default).base_url}/#{contents(:article1).created_at.year}/#{sprintf("%.2d", contents(:article1).created_at.month)}/#{sprintf("%.2d", contents(:article1).created_at.day)}/#{contents(:article1).permalink}#comments")
end

it "GET /2007/10/11/slug/comments.atom should return an atom feed" do
Expand Down

1 comment on commit e4bd70a

@fdv
Copy link
Member

@fdv fdv commented on e4bd70a Mar 11, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job Cyril

Please sign in to comment.