This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

factory for site setting and a simple test

  • Loading branch information...
james cook
james cook committed Apr 28, 2009
1 parent 8592dcf commit fe12f43aedea4c3977cc57b64bfe6c1ede47823f
Showing with 39 additions and 3 deletions.
  1. +20 −0 test/factories.rb
  2. +19 −3 test/unit/site_setting_test.rb
@@ -15,6 +15,18 @@
c.association :commentable, :factory => :page
end

Factory.sequence :site_setting_name do |ssn|
"ANSUZ-#{ssn}"
end

Factory.sequence :site_setting_user_theme_name do |tn|
"ANSUZ-THEME-#{tn}"
end

Factory.sequence :site_setting_site_title do |st|
"ANSUZ-SITE-TITLE-#{st}"
end

Factory.define :page do |p|
p.name { Factory.next(:page_name)}
p.title "Home"
@@ -30,3 +42,11 @@
u.password_confirmation 'test1234'
u.email{ Factory.next(:user_email) }
end

Factory.define :site_setting do |ss|
ss.name { Factory.next(:site_setting_name) }
ss.user_theme_name { Factory.next(:site_setting_user_theme_name)}
ss.site_title { Factory.next(:site_setting_site_title) }
ss.show_inline_edit_links false
ss.custom_css ""
end
@@ -1,8 +1,24 @@
require 'test/test_helper'

class SiteSettingTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_truth
assert true
context "An instance of site setting" do
setup do
@site_setting = Factory(:site_setting, :user_theme_name => "Test")
end

context "with a valid theme name" do
should "respond to get_theme_setting appropriately" do
assert_equal("Test", @site_setting.get_theme_setting)
end
end

context "with a no theme name" do
setup do
@site_setting.user_theme_name = ""
end
should "respond to get_theme_setting appropriately" do
assert_equal("default", @site_setting.get_theme_setting)
end
end
end
end

0 comments on commit fe12f43

Please sign in to comment.