1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-26 18:18:51 +01:00

Rename Problem to Translation

This commit is contained in:
2014-12-13 17:00:00 +01:00
parent 94087d31d2
commit e13b82ad1f
34 changed files with 244 additions and 239 deletions

View File

@@ -1,53 +0,0 @@
require 'test_helper'
class ProblemsControllerTest < ActionController::TestCase
setup do
@problem = problems(:one)
@update = {
title: 'New title',
content: 'This is the new content'
}
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:problems)
end
test "should get new" do
get :new
assert_response :success
end
test "should create problem" do
assert_difference('Problem.count') do
post :create, problem: @update
end
assert_redirected_to problem_path(assigns(:problem))
end
test "should show problem" do
get :show, id: @problem
assert_response :success
end
test "should get edit" do
get :edit, id: @problem
assert_response :success
end
test "should update problem" do
patch :update, id: @problem, problem: @update
assert_redirected_to problem_path(assigns(:problem))
end
test "should destroy problem" do
assert_difference('Problem.count', -1) do
delete :destroy, id: @problem
end
assert_redirected_to problems_path
end
end

View File

@@ -0,0 +1,53 @@
require 'test_helper'
class TranslationsControllerTest < ActionController::TestCase
setup do
@translation = translations(:one)
@update = {
title: 'New title',
content: 'This is the new content'
}
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:translations)
end
test "should get new" do
get :new
assert_response :success
end
test "should create translation" do
assert_difference('Translation.count') do
post :create, translation: @update
end
assert_redirected_to translation_path(assigns(:translation))
end
test "should show translation" do
get :show, id: @translation
assert_response :success
end
test "should get edit" do
get :edit, id: @translation
assert_response :success
end
test "should update translation" do
patch :update, id: @translation, translation: @update
assert_redirected_to translation_path(assigns(:translation))
end
test "should destroy translation" do
assert_difference('Translation.count', -1) do
delete :destroy, id: @translation
end
assert_redirected_to translations_path
end
end

View File

@@ -2,8 +2,8 @@
one:
title: First title
content: The content of the problem
content: The content of the translation
two:
title: Second title
content: The content of the second problem
content: The content of the second translation

View File

@@ -1,4 +0,0 @@
require 'test_helper'
class ProblemsHelperTest < ActionView::TestCase
end

View File

@@ -0,0 +1,4 @@
require 'test_helper'
class TranslationsHelperTest < ActionView::TestCase
end

View File

@@ -1,34 +0,0 @@
require 'test_helper'
class ProblemTest < ActiveSupport::TestCase
test "should not save problem without title" do
problem = Problem.new(content: 'This is some content')
assert_not problem.save
end
test "should not save problem without content" do
problem = Problem.new(title: 'Problem title')
assert_not problem.save
end
test "should not save problem with duplicate title" do
problem = Problem.new(
title: problems(:one).title,
content: 'This is some content'
)
assert_not problem.save
end
test "should save correct problem" do
problem = Problem.new(
title: 'A unique title',
content: 'Some content'
)
assert problem.save
end
test "should have correct original url" do
first = Problem.first
assert_equal "https://projecteuler.net/problem=#{first.id}", first.original_url
end
end

View File

@@ -0,0 +1,34 @@
require 'test_helper'
class TranslationTest < ActiveSupport::TestCase
test "should not save translation without title" do
translation = Translation.new(content: 'This is some content')
assert_not translation.save
end
test "should not save translation without content" do
translation = Translation.new(title: 'Translation title')
assert_not translation.save
end
test "should not save translation with duplicate title" do
translation = Translation.new(
title: translations(:one).title,
content: 'This is some content'
)
assert_not translation.save
end
test "should save correct translation" do
translation = Translation.new(
title: 'A unique title',
content: 'Some content'
)
assert translation.save
end
test "should have correct original url" do
first = Translation.first
assert_equal "https://projecteuler.net/problem=#{first.id}", first.original_url
end
end