- | <%= ban.user_name %> |
+ <%= ban.user.name %> |
<%= ban.expires_at %> |
<%= ban.reason %> |
diff --git a/app/views/bans/new.html.erb b/app/views/bans/new.html.erb
index 3f8b1a03a..8c5eaa8e9 100644
--- a/app/views/bans/new.html.erb
+++ b/app/views/bans/new.html.erb
@@ -1,7 +1,7 @@
New Ban
- <%= render "form", :locals => {:ban => @ban} %>
+ <%= render :partial => "form", :locals => {:ban => @ban} %>
diff --git a/app/views/bans/show.html.erb b/app/views/bans/show.html.erb
index a75e157ce..7e2f4f594 100644
--- a/app/views/bans/show.html.erb
+++ b/app/views/bans/show.html.erb
@@ -2,7 +2,7 @@
Show Ban
- - User: <%= @ban.user_name %>
+ - User: <%= @ban.user.name %>
- Expires: <%= @ban.expires_at %>
- Reason: <%= @ban.reason %>
diff --git a/app/views/comment_votes/create.js.erb b/app/views/comment_votes/create.js.erb
new file mode 100644
index 000000000..20f465b7e
--- /dev/null
+++ b/app/views/comment_votes/create.js.erb
@@ -0,0 +1,3 @@
+<% if @error %>
+ alert(<%= escape_javascript(@error.to_s) %>);
+<% end %>
diff --git a/app/views/comment_votes/create.js.rjs b/app/views/comment_votes/create.js.rjs
deleted file mode 100644
index 450cfa6f7..000000000
--- a/app/views/comment_votes/create.js.rjs
+++ /dev/null
@@ -1,3 +0,0 @@
-if @error
- page.alert(@error.to_s)
-end
diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb
index 282a244c0..d2fb5dbf9 100644
--- a/app/views/comments/index.html.erb
+++ b/app/views/comments/index.html.erb
@@ -5,7 +5,7 @@
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
- <%= render "comments/partials/index/list", :locals => {:post => post, :comments => post.comments.recent.reverse, :show_header => true} %>
+ <%= render :partial => "comments/partials/index/list", :locals => {:post => post, :comments => post.comments.recent.reverse, :show_header => true} %>
<% end %>
diff --git a/test/factories/ban.rb b/test/factories/ban.rb
index c7a37f859..9ef20b80e 100644
--- a/test/factories/ban.rb
+++ b/test/factories/ban.rb
@@ -1,6 +1,6 @@
Factory.define(:ban) do |f|
f.user {|x| x.association(:user)}
f.banner {|x| x.association(:admin_user)}
- f.reason {Faker::Lorem.words}
+ f.reason {Faker::Lorem.words.join(" ")}
f.duration 60
end
diff --git a/test/factories/comment.rb b/test/factories/comment.rb
index 54afc3b76..173ed472e 100644
--- a/test/factories/comment.rb
+++ b/test/factories/comment.rb
@@ -1,5 +1,5 @@
Factory.define(:comment) do |f|
f.post {|x| x.association(:post)}
- f.body {Faker::Lorem.sentences}
+ f.body {Faker::Lorem.sentences.join(" ")}
f.score 0
end
diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb
index 9a8ec84ac..d181ee7a2 100644
--- a/test/functional/artists_controller_test.rb
+++ b/test/functional/artists_controller_test.rb
@@ -1,8 +1,59 @@
require 'test_helper'
class ArtistsControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+ context "An artists controller" do
+ setup do
+ CurrentUser.user = Factory.create(:user)
+ CurrentUser.ip_addr = "127.0.0.1"
+ @artist = Factory.create(:artist)
+ @user = Factory.create(:user)
+ end
+
+ teardown do
+ CurrentUser.user = nil
+ CurrentUser.ip_addr = nil
+ end
+
+ should "render the new page" do
+ get :new, {}, {:user_id => @user.id}
+ assert_response :success
+ end
+
+ should "render the edit page" do
+ get :edit, {:id => @artist.id}, {:user_id => @user.id}
+ assert_response :success
+ end
+
+ should "render the show page" do
+ get :show, {:id => @artist.id}
+ assert_response :success
+ end
+
+ should "render the index page" do
+ get :index
+ assert_response :success
+ end
+
+ should "create an artist" do
+ assert_difference("Artist.count", 1) do
+ post :create, {:artist => Factory.attributes_for(:artist)}, {:user_id => @user.id}
+ end
+ artist = Artist.last
+ assert_redirected_to(artist_path(artist))
+ end
+
+ should "update an artist" do
+ post :update, {:id => @artist.id, :artist => {:name => "xxx"}}, {:user_id => @user.id}
+ artist = Artist.last
+ assert_equal("xxx", artist.name)
+ assert_redirected_to(artist_path(artist))
+ end
+
+ should "revert an artist" do
+ @artist.update_attributes(:name => "xyz")
+ @artist.update_attributes(:name => "abc")
+ version = @artist.versions.first
+ post :revert, {:id => @artist.id, :version_id => version.id}
+ end
end
end
diff --git a/test/functional/bans_controller_test.rb b/test/functional/bans_controller_test.rb
index 31c8c3c93..a9dd3a875 100644
--- a/test/functional/bans_controller_test.rb
+++ b/test/functional/bans_controller_test.rb
@@ -1,8 +1,59 @@
require 'test_helper'
class BansControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+ context "A bans controller" do
+ setup do
+ CurrentUser.user = Factory.create(:user)
+ CurrentUser.ip_addr = "127.0.0.1"
+ @ban = Factory.create(:ban)
+ @user = Factory.create(:moderator_user)
+ end
+
+ teardown do
+ CurrentUser.user = nil
+ CurrentUser.ip_addr = nil
+ end
+
+ should "render the new page" do
+ get :new, {}, {:user_id => @user.id}
+ assert_response :success
+ end
+
+ should "render the edit page" do
+ get :edit, {:id => @ban.id}, {:user_id => @user.id}
+ assert_response :success
+ end
+
+ should "render the show page" do
+ get :show, {:id => @ban.id}
+ assert_response :success
+ end
+
+ should "render the index page" do
+ get :index
+ assert_response :success
+ end
+
+ should "create a ban" do
+ assert_difference("Ban.count", 1) do
+ post :create, {:ban => Factory.attributes_for(:ban)}, {:user_id => @user.id}
+ end
+ ban = Ban.last
+ assert_redirected_to(ban_path(ban))
+ end
+
+ should "update a ban" do
+ post :update, {:id => @ban.id, :ban => {:reason => "xxx"}}, {:user_id => @user.id}
+ ban = Ban.last
+ assert_equal("xxx", ban.reason)
+ assert_redirected_to(ban_path(ban))
+ end
+
+ should "destroy a ban" do
+ assert_difference("Ban.count", -1) do
+ post :destroy, {:id => @ban.id}, {:user_id => @user.id}
+ end
+ assert_redirected_to(bans_path)
+ end
end
end
diff --git a/test/functional/comment_votes_controller_test.rb b/test/functional/comment_votes_controller_test.rb
index d9feaa808..bb5b1922f 100644
--- a/test/functional/comment_votes_controller_test.rb
+++ b/test/functional/comment_votes_controller_test.rb
@@ -1,8 +1,24 @@
require 'test_helper'
class CommentVotesControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+ context "A comment votes controller" do
+ setup do
+ CurrentUser.user = Factory.create(:user)
+ CurrentUser.ip_addr = "127.0.0.1"
+ @comment = Factory.create(:comment)
+ @user = Factory.create(:user)
+ end
+
+ teardown do
+ CurrentUser.user = nil
+ CurrentUser.ip_addr = nil
+ end
+
+ should "create a vote" do
+ assert_difference("CommentVote.count", 1) do
+ post :create, {:format => "js", :comment_id => @comment.id}, {:user_id => @user.id}
+ assert_response :success
+ end
+ end
end
end
diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb
index 8a86af59b..7246864ad 100644
--- a/test/functional/comments_controller_test.rb
+++ b/test/functional/comments_controller_test.rb
@@ -1,8 +1,36 @@
require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+ context "A comments controller" do
+ setup do
+ CurrentUser.user = Factory.create(:user)
+ CurrentUser.ip_addr = "127.0.0.1"
+ @comment = Factory.create(:comment)
+ @user = Factory.create(:moderator_user)
+ end
+
+ teardown do
+ CurrentUser.user = nil
+ CurrentUser.ip_addr = nil
+ end
+
+ should "render the index page" do
+ get :index
+ assert_response :success
+ end
+
+ should "update a comment" do
+ post :update, {:id => @comment.id, :comment => {:body => "abc"}}, {:user_id => @comment.creator_id}
+ assert_redirected_to comment_path(@comment)
+ end
+
+ should "create a comment" do
+ p = Factory.create(:post)
+ assert_difference("Comment.count", 1) do
+ post :create, {:comment => Factory.attributes_for(:comment, :post_id => p.id)}, {:user_id => @user.id}
+ end
+ comment = Comment.last
+ assert_redirected_to post_path(comment.post)
+ end
end
end
|