Skip to content

Commit

Permalink
Continues fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtwohiou committed Mar 23, 2017
1 parent 1a17d48 commit afc0cca
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ group :development do
gem 'quiet_assets'
gem 'better_errors'
gem 'binding_of_caller'
gem 'pry'
end
group :test, :development do
gem 'minitest', '~>5.3.3'
gem "test-unit", "~> 3.0"
gem 'minitest-rails', '~>2.0.0'
gem 'minitest-reporters', '~>1.0.0'
end
Expand Down
14 changes: 12 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PATH
paperclip (~> 3.4)
rails (~> 4.2.0)
sass-rails
simple_form (>= 3.0.0.rc, < 3.1)
simple_form (~> 3.1.0)
term-ansicolor
underscore-rails (~> 1.4)
will_paginate (~> 3.0.0)
Expand Down Expand Up @@ -206,6 +206,11 @@ GEM
capybara (~> 2.1.0)
faye-websocket (>= 0.4.4, < 0.5.0)
http_parser.rb (~> 0.5.3)
power_assert (1.0.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rack (1.6.5)
Expand Down Expand Up @@ -252,11 +257,12 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
simple_form (3.1.0.rc2)
simple_form (3.1.1)
actionpack (~> 4.0)
activemodel (~> 4.0)
single_test (0.6.0)
rake
slop (3.6.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -269,6 +275,8 @@ GEM
sqlite3 (>= 1.3.3)
term-ansicolor (1.4.0)
tins (~> 1.0)
test-unit (3.2.3)
power_assert
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
Expand Down Expand Up @@ -312,13 +320,15 @@ DEPENDENCIES
mocha
mysql2
poltergeist
pry
quiet_assets
rake
ruby-prof
sass-rails (~> 5.0.0)
single_test
sprockets-rails (~> 2.3.1)
sqlite3-ruby
test-unit (~> 3.0)
thin
uglifier
yard
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def run_tests(tests_to_run)
Rake::Task[task].invoke
nil
rescue => e
puts e
{:task => task, :exception => e}
end
end.compact
Expand Down
4 changes: 2 additions & 2 deletions app/models/cms/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ def connectable_count_for_container(container)
end

def name_with_section_path
a = ancestors
(a[1..a.size].map { |a| a.name } + [name]).join(" / ")
anc = ancestors
(anc[1..anc.size].map { |a| a.name } + [name]).join(" / ")
end

# @return [Boolean] true if this page is the home page of the site.
Expand Down
2 changes: 1 addition & 1 deletion browsercms.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Gem::Specification.new do |s|
s.add_dependency("panoramic")
s.add_dependency("will_paginate", "~>3.0.0")
s.add_dependency("actionpack-page_caching", "~>1.0")
s.add_dependency("simple_form", ">= 3.0.0.rc", "< 3.1")
s.add_dependency("simple_form", "~>3.1.0")

# Required only for bcms-upgrade
s.add_dependency "term-ansicolor"
Expand Down
2 changes: 1 addition & 1 deletion features/commands/generate_module.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Generate Module
@known-bug
Scenario: Create a BrowserCMS module
When I create a module named "bcms_store"
Then a rails engine named "bcms_store" should exist
Then "bcms_store" should exist
And BrowserCMS should be added the .gemspec file
And a file named "bcms_store/test/dummy/app/views/layouts/templates/default.html.erb" should exist

Expand Down
4 changes: 4 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#Capybara.javascript_driver = :poltergeist
#Capybara.default_driver = :poltergeist



Before do
# Configure where Aruba generates files.
# You can't generate rails projects within rails projects', so it needs to be parallel to the browsercms project
Expand Down Expand Up @@ -84,3 +86,5 @@
require File.join(File.dirname(__FILE__), '../../db/seeds.rb')
end

require 'test/unit/assertions'
World Test::Unit::Assertions
2 changes: 2 additions & 0 deletions features/support/minitest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'minitest/unit'
World(MiniTest::Assertions)
3 changes: 1 addition & 2 deletions lib/cms/behaviors/publishing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def is_publishable(options={})
module ClassMethods
end
module InstanceMethods

# Can specify whether to save this block as a draft using a terser syntax.
# These two calls behave identically
# - Cms::HtmlBlock.create(name: "Shorter", as: :draft)
Expand Down Expand Up @@ -152,7 +151,7 @@ def publish!
self.class.connection.update(
"UPDATE #{self.class.quoted_table_name} " +
"SET published = #{self.class.connection.quote(true, self.class.columns_hash["published"])} " +
"WHERE #{self.class.connection.quote_column_name(self.class.primary_key)} = #{self.class.quote_value(id)}",
"WHERE #{self.class.connection.quote_column_name(self.class.primary_key)} = #{self.class.quote_value(id, nil)}",
"#{self.class.name.demodulize} Publish"
)
did_publish = true
Expand Down
2 changes: 1 addition & 1 deletion lib/cms/behaviors/soft_deleting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def mark_as_deleted!
end

def destroy!
transaction { super.destroy }
transaction { super.destroy if super!=true }
end

def destroyed?
Expand Down
2 changes: 2 additions & 0 deletions lib/cms/behaviors/taggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def tag_list
end

def tag_list=(tag_names)
self.send("#{attributes.keys.last}_will_change!")
@tag_list = tag_names unless @tag_list == tag_names

end

def save_tags
Expand Down
11 changes: 7 additions & 4 deletions lib/cms/behaviors/versioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Behaviors

# Represents a record as of a specific version in the versions table.
module VersionRecord

require 'pry'
# Create an original 'record' of the Versioned about as it existed as of this VersionRecord.
#
# @return [Object] i.e. HtmlBlock
Expand Down Expand Up @@ -222,6 +222,7 @@ def default_version_comment
def create_or_update
logger.debug { "#{self.class}#create_or_update called. Published = #{!!publish_on_save}" }
self.skip_callbacks = false
#binding.pry
unless different_from_last_draft?
logger.debug { "No difference between this version and last. Skipping save" }
self.skip_callbacks = true
Expand Down Expand Up @@ -344,10 +345,12 @@ def version_comment

def version_comment=(version_comment)
@version_comment = version_comment
# This is not a great solution. We need to rethink how versioning is done, but for the time being
# forcing a random field on the object as dirty should solve the problem of attempting to write to
# the frozen changed attributes hash.
self.updated_by_id_will_change!
#binding.pry
#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/form_fields_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "minitest_helper"
require 'mocha'
require 'mocha/setup'
describe Cms::FormField do

describe '.permitted_params' do
Expand Down
3 changes: 0 additions & 3 deletions spec/concerns/addressable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ def create_testing_table(name, &block)
WannabeAddressable.expects(:has_one)
WannabeAddressable.expects(:after_save)
WannabeAddressable.expects(:after_validation)
puts "heres info"
puts WannabeAddressable.class
puts WannabeAddressable.to_yaml
WannabeAddressable.is_addressable
WannabeAddressable.new.must_respond_to :parent
end
Expand Down
5 changes: 4 additions & 1 deletion test/functional/cms/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ def test_url_with_cms_domain_prefix_with_cms_site_www
@request.path = "/cms"
assert_equal "http://www.cms.foo.com/cms", @controller.send(:url_with_cms_domain_prefix)
end

require 'pry'
def test_redirected_to_cms_site_if_public_site
binding.pry
@request.host = "foo.com"
binding.pry
get :index
binding.pry
assert_redirected_to "http://foo.com/cms/login"
end

Expand Down
2 changes: 1 addition & 1 deletion test/minitest_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Minitest::Spec
include FactoryHelpers
end

require 'mocha'
require 'mocha/setup'


#class MiniTest::Rails::ActiveSupport::TestCase
Expand Down
4 changes: 2 additions & 2 deletions test/unit/behaviors/dynamic_attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setup
test "can just call properties into existance" do
@thing.price = 1

assert_equal(1, @thing.price)
assert_equal(1, @thing.price.to_i)
end

test "Can persist String properties" do
Expand All @@ -62,7 +62,7 @@ def setup

test "can bulk set attributes=" do
@thing.attributes=({:price=>1, :description=>"Paper"})
assert_equal(1, @thing.price)
assert_equal(1, @thing.price.to_i)
assert_equal("Paper", @thing.description)
end

Expand Down
10 changes: 5 additions & 5 deletions test/unit/models/task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def setup
end

class CreateTaskTest < TaskTest
test "An email is sent when a task is created" do
deliveries_before_task_creation = ActionMailer::Base.deliveries.size
create_the_task!
assert_equal 1, ActionMailer::Base.deliveries.size - deliveries_before_task_creation
end

def test_create_task
assert_that_you_can_assign_a_task_to_yourself
Expand Down Expand Up @@ -43,11 +48,6 @@ def test_create_task
assert_equal "http://cms.browsercms.org#{@page.path}\n\n#{@task.comment}", email.body
end

test "An email is sent when a task is created" do
create_the_task!

assert_equal 1, ActionMailer::Base.deliveries.size
end

protected

Expand Down

0 comments on commit afc0cca

Please sign in to comment.