Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwohiou committed Mar 17, 2017
1 parent df2f88d commit 7d03cfd
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/cms/abstract_file_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class AbstractFileBlock < ActiveRecord::Base

def self.with_parent_id(parent_id)
if parent_id == 'all'
where(true) # Empty scope for chaining
self.all # Empty scope for chaining
else
self.includes({:attachments => :section_node})
.references(:section_node)
Expand Down
7 changes: 4 additions & 3 deletions lib/cms/behaviors/attaching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ def validates_attachment_size(name, options = {})
def validates_attachment_presence(name, options = {})
message = options[:message] || "Must provide at least one #{name}"
validate do |record|
return if record.deleted?
unless record.attachments.any? { |a| a.attachment_name == name.to_s }
record.errors.add(:attachment, message)
if !record.deleted?
unless record.attachments.any? { |a| a.attachment_name == name.to_s }
record.errors.add(:attachment, message)
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/cms/behaviors/versioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ def version_comment
def version_comment=(version_comment)
@version_comment = version_comment
#send(:changed_attributes)["version_comment"] = @version_comment
#attr_name = "version_comment"
#self.send("#{attr_name}_will_change!")
#self.version_comment = @version_comment
end

def different_from_last_draft?
Expand Down
2 changes: 1 addition & 1 deletion spec/cms/email_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

describe "#absolute_cms_url" do
it "should return a url which points to the cms admin version of a page" do
Rails.configuration.cms.expects(:site_domain).returns('www.example.com')
Rails.configuration.cms.expects(:site_domain).retu rns('www.example.com')
url = Cms::EmailMessage.absolute_cms_url("/some-path")
url.must_equal "http://cms.example.com/some-path"
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/helpers/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Cms::ApplicationHelper::EditButtonTest < ActionView::TestCase
# Scenario: Edit Buttons should:

test "generate a button without an explicit title by default" do
expected_html = '<a class="button disabled" href="#" id="edit_button"><span>&nbsp;Edit&nbsp;</span></a>'
expected_html = '<a id="edit_button" class="button disabled" href="#"><span>&nbsp;Edit&nbsp;</span></a>'
assert_equal expected_html, edit_button
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/models/file_block_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_table_name
@file_block.save!
assert_not_nil @file_block.file

found = Cms::FileBlock.find(@file_block)
found = Cms::FileBlock.find(@file_block.id)
assert_not_nil found.file
end

Expand Down
6 changes: 6 additions & 0 deletions test/unit/models/html_block_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class HtmlBlockTest < ActiveSupport::TestCase
blue = create(:html_block, name: 'blue')

results = Cms::HtmlBlock.paginate(page: 1, per_page: 1)

puts "this is red"
puts red
puts "this is results"
puts results.first
puts ""
assert_equal 1, results.size
assert_equal red, results.first
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/portlets/list_portlet_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), '/../../test_helper')
require 'test_helper'

class ListTest < ActiveSupport::TestCase

Expand Down

0 comments on commit 7d03cfd

Please sign in to comment.