concen 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  .DS_Store
2
2
  .bundle/
3
3
  .rvmrc
4
+ .rbenv-version
4
5
  *.gem
5
6
  log/*.log
6
7
  app/stylesheets/.sass-cache
data/Gemfile CHANGED
@@ -2,14 +2,17 @@ source "http://rubygems.org"
2
2
 
3
3
  gem "rails", ">= 3.1.0"
4
4
 
5
- gem "sass-rails", "~> 3.1.0"
6
5
  gem "compass", "~> 0.12.alpha"
6
+ gem "sass-rails", "~> 3.1.3"
7
+
8
+ # gemspec.
7
9
  gem "haml", "~> 3.1.0"
8
10
  gem "mustache", "~> 0.99.4"
9
11
  gem "redcarpet", "2.0.0b5"
10
- gem "mongoid", "~> 2.0.0"
12
+ gem "mongoid", "~> 2.2.2"
13
+ gem "mongo", "~> 1.4.0"
14
+ gem "bson_ext", "~> 1.4.0"
11
15
  gem "mongo-rails-instrumentation", "~> 0.2.4"
12
- gem "bson_ext", "~> 1.3.0"
13
16
  gem "rack-gridfs", "~> 0.4.1"
14
17
  gem "chronic", "~> 0.6.3"
15
18
  gem "mime-types", "~> 1.16"
@@ -20,5 +23,4 @@ gem "domainatrix", "~> 0.0.10"
20
23
  gem "capybara", ">= 0.4.0"
21
24
  gem "fabrication", "1.1.0"
22
25
  gem "database_cleaner", "0.6.0"
23
- gem "ansi"
24
- gem "turn"
26
+ gem "minitest", "~> 2.6.1"
data/Gemfile.lock CHANGED
@@ -31,11 +31,10 @@ GEM
31
31
  activesupport (3.1.0)
32
32
  multi_json (~> 1.0)
33
33
  addressable (2.2.6)
34
- ansi (1.2.5)
35
34
  arel (2.2.1)
36
35
  bcrypt-ruby (3.0.0)
37
- bson (1.3.1)
38
- bson_ext (1.3.1)
36
+ bson (1.4.0)
37
+ bson_ext (1.4.0)
39
38
  builder (3.0.0)
40
39
  capybara (1.0.0)
41
40
  mime-types (>= 1.16)
@@ -68,10 +67,11 @@ GEM
68
67
  mime-types (~> 1.16)
69
68
  treetop (~> 1.4.8)
70
69
  mime-types (1.16)
71
- mongo (1.3.1)
72
- bson (>= 1.3.1)
70
+ minitest (2.6.1)
71
+ mongo (1.4.0)
72
+ bson (= 1.4.0)
73
73
  mongo-rails-instrumentation (0.2.4)
74
- mongoid (2.0.2)
74
+ mongoid (2.2.2)
75
75
  activemodel (~> 3.0)
76
76
  mongo (~> 1.3)
77
77
  tzinfo (~> 0.3.22)
@@ -112,10 +112,12 @@ GEM
112
112
  redcarpet (2.0.0b5)
113
113
  rubyzip (0.9.4)
114
114
  sass (3.1.7)
115
- sass-rails (3.1.0)
115
+ sass-rails (3.1.3)
116
116
  actionpack (~> 3.1.0)
117
117
  railties (~> 3.1.0)
118
118
  sass (>= 3.1.4)
119
+ sprockets (~> 2.0.0)
120
+ tilt (~> 1.3.2)
119
121
  selenium-webdriver (0.2.1)
120
122
  childprocess (>= 0.1.7)
121
123
  ffi (>= 1.0.7)
@@ -124,14 +126,12 @@ GEM
124
126
  sprockets (2.0.0)
125
127
  hike (~> 1.2)
126
128
  rack (~> 1.0)
127
- tilt (!= 1.3.0, ~> 1.1)
129
+ tilt (~> 1.1, != 1.3.0)
128
130
  thor (0.14.6)
129
131
  tilt (1.3.3)
130
132
  treetop (1.4.10)
131
133
  polyglot
132
134
  polyglot (>= 0.3.1)
133
- turn (0.8.2)
134
- ansi (>= 1.2.2)
135
135
  tzinfo (0.3.29)
136
136
  xpath (0.1.4)
137
137
  nokogiri (~> 1.3)
@@ -140,9 +140,8 @@ PLATFORMS
140
140
  ruby
141
141
 
142
142
  DEPENDENCIES
143
- ansi
144
143
  bcrypt-ruby (~> 3.0.0)
145
- bson_ext (~> 1.3.0)
144
+ bson_ext (~> 1.4.0)
146
145
  capybara (>= 0.4.0)
147
146
  chronic (~> 0.6.3)
148
147
  compass (~> 0.12.alpha)
@@ -151,11 +150,12 @@ DEPENDENCIES
151
150
  fabrication (= 1.1.0)
152
151
  haml (~> 3.1.0)
153
152
  mime-types (~> 1.16)
153
+ minitest (~> 2.6.1)
154
+ mongo (~> 1.4.0)
154
155
  mongo-rails-instrumentation (~> 0.2.4)
155
- mongoid (~> 2.0.0)
156
+ mongoid (~> 2.2.2)
156
157
  mustache (~> 0.99.4)
157
158
  rack-gridfs (~> 0.4.1)
158
159
  rails (>= 3.1.0)
159
160
  redcarpet (= 2.0.0b5)
160
- sass-rails (~> 3.1.0)
161
- turn
161
+ sass-rails (~> 3.1.3)
data/README.md CHANGED
@@ -134,6 +134,14 @@ If you have used Concen for any of your websites and would like to be listed her
134
134
 
135
135
  ## Version History
136
136
 
137
+ - **0.2.3**:
138
+
139
+ - Update Mongoid version (2.2.2).
140
+ - UI design enhancements.
141
+ - Tests are now using MiniTest.
142
+ - Add ancestor_slugs field for Page model.
143
+ - Page is given a default title if none is present.
144
+
137
145
  - **0.2.2**:
138
146
 
139
147
  - Update Chronic gem dependency.
data/Rakefile CHANGED
@@ -7,13 +7,13 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  require "rake"
10
- require "rake/rdoctask"
10
+ require "rdoc/task"
11
11
  require "rake/testtask"
12
12
 
13
13
  Rake::TestTask.new(:test) do |t|
14
14
  t.libs << "lib"
15
15
  t.libs << "test"
16
- t.pattern = "test/**/*_test.rb"
16
+ t.test_files = Dir.glob("test/**/*_test.rb")
17
17
  t.verbose = false
18
18
  end
19
19
 
@@ -0,0 +1,12 @@
1
+ //= require concen/modernizr
2
+ //= require concen/jquery
3
+ //= require concen/jquery-ui/jquery.ui.core
4
+ //= require concen/jquery-ui/jquery.ui.widget
5
+ //= require concen/jquery-ui/jquery.ui.mouse
6
+ //= require concen/jquery-ui/jquery.ui.position
7
+ //= require concen/jquery-ui/jquery.ui.sortable
8
+ //= require concen/jquery-ui/jquery.ui.resizable
9
+ //= require concen/jquery-ui/jquery.ui.draggable
10
+ //= require concen/jquery-ui/jquery.ui.droppable
11
+ //= require concen/jquery.ui.nestedSortable
12
+ //= require concen/jquery_ujs
@@ -115,7 +115,7 @@ $(document).ready(function() {
115
115
  helper: "clone",
116
116
  handle: "span.handle",
117
117
  items: "li",
118
- maxLevels: 3,
118
+ maxLevels: 0,
119
119
  opacity: .6,
120
120
  placeholder: "placeholder",
121
121
  revert: 250,
@@ -122,9 +122,10 @@ ul.pages
122
122
  vertical-align: middle
123
123
  span, a
124
124
  vertical-align: middle
125
- ul
126
- p
127
- // background: $gray-90
125
+ color: $color-2
126
+ &.author
127
+ span, a
128
+ color: $color-1
128
129
  a, ul a
129
130
  margin-left: 4px
130
131
  ul
@@ -1,10 +1,10 @@
1
1
  // Colors.
2
2
 
3
- $color-1: hsl(230, 60%, 20%) // #141F52
4
- $color-2: hsl(230, 20%, 60%) // #858BAD
5
- $color-3: hsl(230, 20%, 94%) // #EDEEF3
6
- $color-4: hsl(230, 20%, 96%) // #F3F3F7
7
- $color-5: hsl(230, 20%, 88%) // #DADCE7
3
+ $color-1: hsl(220, 100%, 20%) // #002266
4
+ $color-2: hsl(220, 16%, 45%) // #606D85
5
+ $color-3: hsl(220, 16%, 90%) // #E1E4EA
6
+ $color-4: hsl(220, 16%, 95%) // #F0F2F4
7
+ $color-5: hsl(220, 16%, 88%) // #DCDFE5
8
8
  $gray-20: hsl(0, 0%, 20%)
9
9
  $gray-60: hsl(0, 0%, 60%)
10
10
  $gray-80: hsl(0, 0%, 80%)
@@ -15,7 +15,6 @@ module Concen
15
15
  else
16
16
  @page = Page.new
17
17
  end
18
- @page.level = params[:level].to_i if params[:level]
19
18
  end
20
19
 
21
20
  def create
@@ -19,6 +19,7 @@ module Concen
19
19
  field :title, :type => String
20
20
  field :description, :type => String
21
21
  field :slug, :type => String
22
+ field :ancestor_slugs, :type => Array, :default => []
22
23
  field :raw_text, :type => String
23
24
  field :content, :type => Hash, :default => {}
24
25
  field :position, :type => Integer
@@ -34,9 +35,12 @@ module Concen
34
35
  validates_uniqueness_of :slug, :scope => [:parent_id, :level], :case_sensitive => false
35
36
 
36
37
  before_validation :parse_raw_text
38
+ before_validation :set_title
37
39
  before_validation :set_slug
40
+ before_validation :set_position
41
+ before_validation :set_level
38
42
  before_save :set_publish_month
39
- before_create :set_position
43
+ before_save :set_ancestor_slugs
40
44
  after_save :unset_unused_dynamic_fields
41
45
  after_destroy :destroy_children
42
46
  after_destroy :destroy_grid_files
@@ -61,10 +65,10 @@ module Concen
61
65
 
62
66
  # Get the list of dynamic fields by checking againts this array.
63
67
  # Values should mirror the listed fields above.
64
- PREDEFINED_FIELDS = [:_id, :parent_id, :level, :created_at, :updated_at, :slug, :content, :raw_text, :position, :grid_files, :title, :description, :publish_time, :labels, :authors, :status]
68
+ PREDEFINED_FIELDS = [:_id, :parent_id, :level, :created_at, :updated_at, :slug, :ancestor_slugs, :content, :raw_text, :position, :grid_files, :title, :description, :publish_time, :labels, :authors, :status]
65
69
 
66
70
  # These fields can't be overwritten by user's meta data when parsing raw_text.
67
- PROTECTED_FIELDS = [:_id, :parent_id, :level, :created_at, :updated_at, :content, :raw_text, :position, :grid_files]
71
+ PROTECTED_FIELDS = [:_id, :parent_id, :level, :created_at, :updated_at, :content, :raw_text, :position, :grid_files, :ancestor_slugs]
68
72
 
69
73
  def content_in_html(key = "main", data={})
70
74
  if content = self.content.try(:[], key)
@@ -109,12 +113,16 @@ module Concen
109
113
  end
110
114
 
111
115
  def underscore_hash_keys(hash)
112
- new_hash = {}
113
- hash.each do |key, value|
114
- value = underscore_hash_keys(value) if value.is_a?(Hash)
115
- new_hash[key.gsub(" ","_").downcase.to_sym] = value
116
+ if hash.is_a? Hash
117
+ new_hash = {}
118
+ hash.each do |key, value|
119
+ value = underscore_hash_keys(value) if value.is_a?(Hash)
120
+ new_hash[key.gsub(" ","_").downcase.to_sym] = value
121
+ end
122
+ new_hash
123
+ else
124
+ return nil
116
125
  end
117
- new_hash
118
126
  end
119
127
 
120
128
  def parse_publish_time(publish_time_string)
@@ -222,33 +230,6 @@ module Concen
222
230
 
223
231
  protected
224
232
 
225
- def set_slug
226
- if self.slug.blank?
227
- self.slug = self.title.parameterize if self.title
228
- else
229
- self.slug = self.slug.parameterize
230
- end
231
- end
232
-
233
- def set_position
234
- siblings = Page.where :parent_id => self.parent_id
235
- if siblings.count > 0
236
- self.position = siblings.with_position.asc(:position).last.position + 1
237
- else
238
- self.position = 1
239
- end
240
- end
241
-
242
- def reset_position
243
- affected_pages = Page.with_position.where :parent_id => self.parent_id, :position.gt => self.position
244
- if affected_pages.count > 0
245
- for page in affected_pages
246
- page.position = page.position - 1
247
- page.save
248
- end
249
- end
250
- end
251
-
252
233
  def parse_raw_text
253
234
  if self.raw_text && self.raw_text.length > 0 && (self.new? || self.raw_text_changed?)
254
235
  self.content = {}
@@ -273,22 +254,23 @@ module Concen
273
254
  self.content = {}
274
255
  end
275
256
 
276
- # Set each value of meta data.
277
- meta_data = underscore_hash_keys(YAML.load(meta_data))
278
- meta_data.each do |key, value|
279
- unless PROTECTED_FIELDS.include?(key)
280
- if key == :publish_time
281
- self.parse_publish_time(value)
282
- else
283
- self.write_attribute(key, value)
257
+ if meta_data = underscore_hash_keys(YAML.load(meta_data))
258
+ # Set each value of meta data.
259
+ meta_data.each do |key, value|
260
+ unless PROTECTED_FIELDS.include?(key)
261
+ if key == :publish_time
262
+ self.parse_publish_time(value)
263
+ else
264
+ self.write_attribute(key, value)
265
+ end
284
266
  end
285
267
  end
286
- end
287
268
 
288
- # Set the field to nil if the value isn't present in meta data.
289
- # Except for authors.
290
- (self.attributes.keys.map{ |k| k.to_sym } - PROTECTED_FIELDS).each do |field|
291
- self[field] = nil if !meta_data.keys.include?(field) && field != :authors
269
+ # Set the field to nil if the value isn't present in meta data.
270
+ # Except for authors.
271
+ (self.attributes.keys.map{ |k| k.to_sym } - PROTECTED_FIELDS).each do |field|
272
+ self[field] = nil if !meta_data.keys.include?(field) && field != :authors
273
+ end
292
274
  end
293
275
 
294
276
  self.update_raw_text
@@ -311,18 +293,6 @@ module Concen
311
293
  self.raw_text = meta_data.join + self.raw_text.match(/(?:\r?\n-{3,}\r?\n)/).to_s + raw_text_array.join
312
294
  end
313
295
 
314
- def destroy_children
315
- for child in self.children
316
- child.destroy
317
- end
318
- end
319
-
320
- def destroy_grid_files
321
- for grid_file in self.grid_files
322
- grid_file.destroy
323
- end
324
- end
325
-
326
296
  def unset_unused_dynamic_fields
327
297
  target_fields = {}
328
298
  for field in self.attributes.keys
@@ -333,10 +303,92 @@ module Concen
333
303
  Page.collection.update({"_id" => self.id}, {"$unset" => target_fields})
334
304
  end
335
305
 
306
+ # Give default title ("Untitled n") when no title is given.
307
+ def set_title
308
+ unless self.title
309
+ if self.parent
310
+ if last_untitled_page = self.parent.children.where(:title => /Untitled /i).asc(:title).last
311
+ last_untitled_number = last_untitled_page.title.split(" ").last.to_i
312
+ self.title = "Untitled #{last_untitled_number+1}"
313
+ else
314
+ self.title = "Untitled 1"
315
+ end
316
+ else
317
+ self.title = "Untitled 1"
318
+ end
319
+ end
320
+ end
321
+
322
+ def set_slug
323
+ if self.slug.blank?
324
+ self.slug = self.title.parameterize if self.title
325
+ else
326
+ self.slug = self.slug.parameterize
327
+ end
328
+ end
329
+
330
+ def set_position
331
+ # Only set position for newly created record.
332
+ # It will be used by before_validation callback
333
+ # just in case this field is used to validate something.
334
+ unless self.persisted?
335
+ siblings = Page.where :parent_id => self.parent_id
336
+ if siblings.count > 0
337
+ self.position = siblings.with_position.asc(:position).last.position + 1
338
+ else
339
+ self.position = 1
340
+ end
341
+ end
342
+ end
343
+
344
+ def reset_position
345
+ affected_pages = Page.with_position.where :parent_id => self.parent_id, :position.gt => self.position
346
+ if affected_pages.count > 0
347
+ for page in affected_pages
348
+ page.position = page.position - 1
349
+ page.save
350
+ end
351
+ end
352
+ end
353
+
354
+ def set_level
355
+ # Only set level for newly created record.
356
+ # It will be used by before_validation callback
357
+ # because level is part of uniqness validation of :title and :slug.
358
+ unless self.persisted?
359
+ if self.parent_id
360
+ self.level = self.parent.level + 1
361
+ else
362
+ self.level = 0
363
+ end
364
+ end
365
+ end
366
+
336
367
  def set_publish_month
337
368
  if self.publish_time
338
369
  self.publish_month = Time.zone.local(self.publish_time.year, self.publish_time.month)
339
370
  end
340
371
  end
372
+
373
+ def set_ancestor_slugs
374
+ parent = self.parent
375
+ while parent
376
+ self.ancestor_slugs << parent.slug
377
+ parent = parent.parent
378
+ end
379
+ self.ancestor_slugs.reverse! if self.ancestor_slugs
380
+ end
381
+
382
+ def destroy_children
383
+ for child in self.children
384
+ child.destroy
385
+ end
386
+ end
387
+
388
+ def destroy_grid_files
389
+ for grid_file in self.grid_files
390
+ grid_file.destroy
391
+ end
392
+ end
341
393
  end
342
394
  end
@@ -10,7 +10,6 @@
10
10
  #text-editor
11
11
  = f.text_area :raw_text, :class => "text-editor-content hidden"
12
12
  = f.hidden_field :parent_id
13
- = f.hidden_field :level
14
13
  .actions.flush
15
14
  = f.submit "Save"
16
15
  - if @page.persisted?
@@ -5,11 +5,11 @@
5
5
  %ul{:class => children.first.level == 0 && "pages", :data => {:level => children.first.level}}
6
6
  - for child in children
7
7
  %li{:data => {:id => "page-#{child.id}"}}
8
- %p
8
+ %p{:class => "#{'author' if child.authors_as_user.map(&:_id).include? current_concen_user.id}"}
9
9
  %span.handle
10
10
  = link_to child.title, edit_concen_page_path(child), :class => "title"
11
- = link_to "Add", new_concen_page_path(:level => child.level + 1, :parent_id => child.id), :class => "link-button hidden"
11
+ = link_to "Add", new_concen_page_path(:parent_id => child.id), :class => "link-button hidden"
12
12
  = link_to "Edit", edit_concen_page_path(child), :class => "link-button hidden"
13
13
  = link_to "Delete", concen_page_path(child), :method => :delete, :confirm => "Are you sure?", :class => "link-button hidden"
14
14
  - if Concen::Page.where(:parent_id => child.id).count > 0
15
- = render :partial => "nested_list", :locals => {:page => child, :root => false}
15
+ = render :partial => "nested_list", :locals => {:page => child, :root => false}
@@ -6,7 +6,7 @@
6
6
  = one_line do
7
7
  %span Pages
8
8
  - unless @page
9
- = link_to "New Page", new_concen_page_path(:level => 0), :class => "link-button"
9
+ = link_to "New Page", new_concen_page_path, :class => "link-button"
10
10
 
11
11
  - if @page
12
12
  = render :partial => "nested_list", :locals => {:page => @page, :root => true}
data/concen.gemspec CHANGED
@@ -25,9 +25,10 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency("haml", "~> 3.1.0")
26
26
  s.add_dependency("mustache", "~> 0.99.4")
27
27
  s.add_dependency("redcarpet", "~> 2.0.0b5")
28
- s.add_dependency("mongoid", "~> 2.0.0")
28
+ s.add_dependency("mongoid", "~> 2.2.2")
29
+ s.add_dependency("mongo", "~> 1.4.0")
30
+ s.add_dependency("bson_ext", "~> 1.4.0")
29
31
  s.add_dependency("mongo-rails-instrumentation", "~> 0.2.4")
30
- s.add_dependency("bson_ext", "~> 1.3.0")
31
32
  s.add_dependency("rack-gridfs", "~> 0.4.1")
32
33
  s.add_dependency("chronic", "~> 0.6.3")
33
34
  s.add_dependency("mime-types", "~> 1.16")
@@ -1,2 +1,2 @@
1
1
  Rails.application.config.assets.precompile += ["concen/ie.css", "concen/non_ios.css"]
2
- Rails.application.config.assets.precompile += ["concen/pages.js", "concen/performances.js", "concen/statuses.js", "concen/traffics.js", "concen/users.js"]
2
+ Rails.application.config.assets.precompile += ["concen/pages.js", "concen/performances.js", "concen/statuses.js", "concen/traffics.js", "concen/users.js", "concen/excanvas.js"]
@@ -1,3 +1,3 @@
1
1
  module Concen
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -5,7 +5,6 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
5
  require File.expand_path("../fabricators.rb", __FILE__)
6
6
  require "rails/test_help"
7
7
  require "database_cleaner"
8
- require "turn"
9
8
 
10
9
  ActionMailer::Base.delivery_method = :test
11
10
  ActionMailer::Base.perform_deliveries = true
@@ -1,7 +1,13 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
+ require "minitest/spec"
3
+ require "minitest/autorun"
2
4
 
3
- class ConcenTest < ActiveSupport::TestCase
4
- test "truth" do
5
- assert_kind_of Module, Concen
5
+ describe Concen do
6
+ before do
7
+ DatabaseCleaner.clean
8
+ end
9
+
10
+ it "must be a Module" do
11
+ Concen.must_be_kind_of Module
6
12
  end
7
13
  end
@@ -1,41 +1,47 @@
1
1
  require "test_helper"
2
+ require "minitest/spec"
3
+ require "minitest/autorun"
2
4
 
3
- class GridFileTest < ActiveSupport::TestCase
4
- test "should store file in GridFS" do
5
+ describe Concen::GridFile do
6
+ before do
7
+ DatabaseCleaner.clean
8
+ end
9
+
10
+ it "can store file in GridFS" do
5
11
  page = Fabricate "concen/page"
6
12
  grid_file = page.grid_files.build
7
13
  grid_file.store File.read("#{Rails.root}/public/404.html"), "404.html"
8
- assert_equal grid_file.read, File.read("#{Rails.root}/public/404.html")
14
+ grid_file.read.must_equal File.read("#{Rails.root}/public/404.html")
9
15
  end
10
16
 
11
- test "should delete file from GridFS when page is deleted" do
17
+ it "must delete file from GridFS when page is deleted" do
12
18
  page = Fabricate "concen/page"
13
19
  grid_file = page.grid_files.build
14
20
  grid_file.store File.read("#{Rails.root}/public/404.html"), "404.html"
15
21
  grid_id = grid_file.grid_id.dup
16
22
  page.destroy
17
23
  grid = Mongo::Grid.new Mongoid.database
18
- assert_raise(Mongo::GridFileNotFound) { grid.get(grid_id).read }
24
+ lambda { grid.get(grid_id).read }.must_raise(Mongo::GridFileNotFound)
19
25
  end
20
26
 
21
- test "should delete associated grid_file when page is deleted" do
27
+ it "must delete associated grid_file when page is deleted" do
22
28
  page = Fabricate "concen/page"
23
29
  grid_file = page.grid_files.build
24
30
  grid_file.store File.read("#{Rails.root}/public/404.html"), "404.html"
25
31
  page.destroy
26
32
  end
27
33
 
28
- test "should store correct original_filename" do
34
+ it "must store correct original_filename" do
29
35
  page = Fabricate "concen/page"
30
36
  grid_file = page.grid_files.build
31
37
  grid_file.store File.read("#{Rails.root}/public/404.html"), "404.html"
32
- assert_equal grid_file.original_filename, "404.html"
38
+ grid_file.original_filename.must_equal "404.html"
33
39
  end
34
40
 
35
- test "should include id in filename" do
41
+ it "must include id in filename" do
36
42
  page = Fabricate "concen/page"
37
43
  grid_file = page.grid_files.build
38
44
  grid_file.store File.read("#{Rails.root}/public/404.html"), "404.html"
39
- assert grid_file.filename.include?(grid_file.grid_id.to_s), "Filename does not include grid_id."
45
+ grid_file.filename.must_include grid_file.grid_id.to_s
40
46
  end
41
47
  end
@@ -1,128 +1,164 @@
1
1
  require "test_helper"
2
+ require "minitest/spec"
3
+ require "minitest/autorun"
2
4
 
3
- class PageTest < ActiveSupport::TestCase
4
- test "should create page" do
5
+ describe Concen::Page do
6
+ before do
7
+ DatabaseCleaner.clean
8
+ end
9
+
10
+ it "can create page" do
5
11
  page = Fabricate "concen/page"
6
- assert_not_nil page.id
12
+ page.id.wont_be_nil
7
13
  end
8
14
 
9
- test "should create child page" do
15
+ it "can create child page" do
10
16
  page = Fabricate "concen/page"
11
17
  child_page = page.children.create :title => "1984"
12
- assert_not_nil child_page.id
13
- assert_equal page.id, child_page.parent.id
18
+ child_page.id.wont_be_nil
19
+ page.id.must_equal child_page.parent.id
14
20
  end
15
21
 
16
- test "should parse title from raw_text" do
22
+ it "must parse title from raw_text" do
17
23
  page = Fabricate "concen/page", :title => nil, :raw_text => "Title: Page Title"
18
- assert_equal page.title, "Page Title"
24
+ page.title.must_equal "Page Title"
25
+ end
26
+
27
+ it "must get default title when none is present" do
28
+ page = Fabricate "concen/page", :title => nil
29
+ page.title.must_equal "Untitled 1"
30
+ end
31
+
32
+ it "validates uniqueness of title" do
33
+ parent_page = Fabricate "concen/page", :title => "Parent"
34
+ child_page_1 = parent_page.children.create :title => "Child"
35
+ child_page_2 = parent_page.children.build :title => "Child"
36
+ lambda { child_page_2.save! }.must_raise(Mongoid::Errors::Validations)
37
+ child_page_2.errors[:title].first.must_equal "is already taken"
19
38
  end
20
39
 
21
- test "should parse publish_time from raw_text" do
40
+ it "must parse publish_time from raw_text" do
22
41
  raw_text = "Title: Page Title 2\n\nPublish Time: now"
23
42
  page = Fabricate "concen/page", :title => nil, :raw_text => raw_text
24
- assert_not_nil page.publish_time
25
- assert_not_equal page.raw_text, raw_text
43
+ page.publish_time.wont_be_nil
44
+ page.raw_text.wont_equal raw_text
26
45
  end
27
46
 
28
- test "should parse multi content from raw_text and conver to html correctly" do
47
+ it "must parse multi content from raw_text and conver to html correctly" do
29
48
  raw_text = File.read "#{File.dirname(__FILE__)}/../support/raw_text/multi_content.txt"
30
49
  html = File.read("#{File.dirname(__FILE__)}/../support/raw_text/multi_content.html")
31
50
  page = Fabricate "concen/page", :title => nil, :raw_text => raw_text
32
- assert_not_nil page.content
33
- assert_equal page.content.keys, ["part_1", "part_2"]
34
- assert_not_nil page.content_in_html("part_1")
35
- assert_not_nil page.content_in_html("part_2")
36
- assert_equal page.content_in_html("part_1") + page.content_in_html("part_2"), html
51
+ page.content.wont_be_nil
52
+ page.content.keys.must_equal ["part_1", "part_2"]
53
+ page.content_in_html("part_1").wont_be_nil
54
+ page.content_in_html("part_2").wont_be_nil
55
+ (page.content_in_html("part_1") + page.content_in_html("part_2")).must_equal html
37
56
  end
38
57
 
39
- test "should parse content with SmartyPants supported entities and convert to html correctly" do
58
+ it "must parse content with SmartyPants supported entities and convert to html correctly" do
40
59
  raw_text_smartypants = File.read "#{File.dirname(__FILE__)}/../support/raw_text/smartypants.txt"
41
60
  raw_text_smartypants_escape = File.read "#{File.dirname(__FILE__)}/../support/raw_text/smartypants_escape.txt"
42
- assert_not_nil raw_text_smartypants
43
- assert_not_nil raw_text_smartypants_escape
61
+ raw_text_smartypants.wont_be_nil
62
+ raw_text_smartypants_escape.wont_be_nil
44
63
 
45
64
  page1 = Fabricate "concen/page", :title => nil, :raw_text => raw_text_smartypants
46
- assert_equal page1.content_in_html, page1.content_in_html("main")
47
- assert_equal page1.content_in_html, File.read("#{File.dirname(__FILE__)}/../support/raw_text/smartypants.html")
65
+ page1.content_in_html.must_equal page1.content_in_html("main")
66
+ page1.content_in_html.must_equal File.read("#{File.dirname(__FILE__)}/../support/raw_text/smartypants.html")
48
67
 
49
68
  page2 = Fabricate "concen/page", :title => nil, :raw_text => raw_text_smartypants_escape
50
- assert_equal page2.content_in_html, page2.content_in_html("main")
51
- assert_equal page2.content_in_html, File.read("#{File.dirname(__FILE__)}/../support/raw_text/smartypants_escape.html")
69
+ page2.content_in_html.must_equal page2.content_in_html("main")
70
+ page2.content_in_html.must_equal File.read("#{File.dirname(__FILE__)}/../support/raw_text/smartypants_escape.html")
52
71
  end
53
72
 
54
- test "should parse content with code blocks and convert to html correctly" do
73
+ it "must parse content with code blocks and convert to html correctly" do
55
74
  raw_text_code_blocks = File.read "#{File.dirname(__FILE__)}/../support/raw_text/code_blocks.txt"
56
- assert_not_nil raw_text_code_blocks
75
+ raw_text_code_blocks.wont_be_nil
57
76
 
58
77
  page = Fabricate "concen/page", :title => nil, :raw_text => raw_text_code_blocks
59
- assert_equal page.content_in_html, page.content_in_html("main")
60
- assert_equal page.content_in_html, File.read("#{File.dirname(__FILE__)}/../support/raw_text/code_blocks.html")
78
+ page.content_in_html.must_equal page.content_in_html("main")
79
+ page.content_in_html.must_equal File.read("#{File.dirname(__FILE__)}/../support/raw_text/code_blocks.html")
61
80
  end
62
81
 
63
- test "should parse content with inline HTML and convert to html correctly" do
82
+ it "must parse content with inline HTML and convert to html correctly" do
64
83
  raw_text_code_blocks = File.read "#{File.dirname(__FILE__)}/../support/raw_text/inline_html.txt"
65
- assert_not_nil raw_text_code_blocks
84
+ raw_text_code_blocks.wont_be_nil
66
85
 
67
86
  page = Fabricate "concen/page", :title => nil, :raw_text => raw_text_code_blocks
68
- assert_equal page.content_in_html, page.content_in_html("main")
69
- assert_equal page.content_in_html, File.read("#{File.dirname(__FILE__)}/../support/raw_text/inline_html.html")
87
+ page.content_in_html.must_equal page.content_in_html("main")
88
+ page.content_in_html.must_equal File.read("#{File.dirname(__FILE__)}/../support/raw_text/inline_html.html")
70
89
  end
71
90
 
72
- test "should have slug automatically generated" do
91
+ it "has slug automatically generated" do
73
92
  page1 = Fabricate "concen/page", :title => "Something New"
74
- assert_equal page1.slug, "something-new"
93
+ page1.slug.must_equal "something-new"
75
94
 
76
95
  page2 = Fabricate.build "concen/page", :title => nil
77
96
  page2.raw_text = File.read "#{File.dirname(__FILE__)}/../support/raw_text/title.txt"
78
97
  page2.save
79
- assert_equal page2.slug, "something-new"
98
+ page2.slug.must_equal "something-new"
80
99
  end
81
100
 
82
- test "should be able to set slug from raw_text" do
101
+ it "must be able to set slug from raw_text" do
83
102
  page = Fabricate.build "concen/page", :title => nil
84
103
  page.raw_text = File.read "#{File.dirname(__FILE__)}/../support/raw_text/slug.txt"
85
104
  page.save
86
- assert_equal page.slug, "something-else"
105
+ page.slug.must_equal "something-else"
87
106
  end
88
107
 
89
- test "should not be created without title" do
90
- page = Fabricate.build "concen/page", :title => nil
91
- assert_raise(Mongoid::Errors::Validations) { page.save! }
92
- assert_equal page.errors[:title].first, "can't be blank"
93
- end
94
-
95
- test "should have authors" do
108
+ it "has authors" do
96
109
  page = Fabricate.build "concen/page", :authors => ["user1", "user2", "user3"]
97
- assert_equal page.authors.count, 3
110
+ page.authors.count.must_equal 3
98
111
  end
99
112
 
100
- test "should get correct author_as_user" do
113
+ it "must get correct author_as_user" do
101
114
  user = Fabricate "concen/user"
102
115
  page = Fabricate.build "concen/page", :authors => [user.username, "user2"]
103
- assert_equal page.authors.count, 2
104
- assert_equal page.authors_as_user.count, 1
105
- assert page.authors_as_user.include?(user.reload), "Does not include a correct user."
116
+ page.authors.count.must_equal 2
117
+ page.authors_as_user.count.must_equal 1
118
+ page.authors_as_user.must_include user.reload
106
119
  end
107
120
 
108
- test "should get the correct slug" do
121
+ it "must get the correct slug" do
109
122
  page = Fabricate "concen/page", :title => "New Title"
110
- assert_equal page.slug, "new-title"
123
+ page.slug.must_equal "new-title"
111
124
  page.write_attribute :slug, "new-slug"
112
125
  page.save
113
- assert_equal page.slug, "new-slug"
126
+ page.slug.must_equal "new-slug"
114
127
  end
115
128
 
116
- test "should get position set/reset correctly" do
129
+ it "must set/reset position correctly" do
117
130
  page = Fabricate "concen/page"
118
131
  child_page_1 = page.children.create :title => "Position 1"
119
- assert_equal child_page_1.position, 1
132
+ child_page_1.position.must_equal 1
133
+
120
134
  child_page_2 = page.children.create :title => "Position 2"
121
- assert_equal child_page_2.position, 2
135
+ child_page_2.position.must_equal 2
136
+
122
137
  child_page_3 = page.children.create :title => "Position 3"
123
- assert_equal child_page_3.position, 3
138
+ child_page_3.position.must_equal 3
124
139
 
125
140
  child_page_2.destroy
126
- assert_equal child_page_3.reload.position, 2
141
+ child_page_3.reload.position.must_equal 2
142
+ end
143
+
144
+ it "must have ancestor_slugs" do
145
+ page_1 = Fabricate "concen/page", :title => "A"
146
+
147
+ page_2 = page_1.children.create :title => "B"
148
+ page_2.ancestor_slugs.must_equal ["a"]
149
+
150
+ page_3 = page_2.children.create :title => "C"
151
+ page_3.ancestor_slugs.must_equal ["a", "b"]
152
+ end
153
+
154
+ it "must have level" do
155
+ page_1 = Fabricate "concen/page", :title => "A"
156
+ page_1.level.must_equal 0
157
+
158
+ page_2 = page_1.children.create :title => "B"
159
+ page_2.level.must_equal 1
160
+
161
+ page_3 = page_2.children.create :title => "C"
162
+ page_3.level.must_equal 2
127
163
  end
128
164
  end
@@ -1,42 +1,50 @@
1
1
  require "test_helper"
2
+ require "minitest/spec"
3
+ require "minitest/autorun"
2
4
 
3
- class UserTest < ActiveSupport::TestCase
4
- test "should create user" do
5
+ describe Concen::User do
6
+ before do
7
+ DatabaseCleaner.clean
8
+ end
9
+
10
+ it "can create user" do
5
11
  user = Fabricate "concen/user"
6
- assert_not_nil user.id
12
+ user.id.wont_be_nil
7
13
  end
8
14
 
9
- test "shoud have password_digest" do
15
+ it "has password_digest" do
10
16
  user = Fabricate "concen/user"
11
- assert_not_nil user.password_digest
17
+ user.password_digest.wont_be_nil
12
18
  end
13
19
 
14
- test "shoud have auth_token" do
20
+ it "has auth_token" do
15
21
  user = Fabricate "concen/user"
16
- assert_not_nil user.auth_token
22
+ user.auth_token.wont_be_nil
17
23
  end
18
24
 
19
- test "should have username" do
25
+ it "has username" do
20
26
  user = Fabricate.build "concen/user", :username => nil
21
- assert_raise(Mongoid::Errors::Validations) { user.save! }
22
- assert_equal user.errors[:username].first, "can't be blank"
27
+ lambda { user.save! }.must_raise(Mongoid::Errors::Validations)
28
+ user.errors[:username].first.must_equal "can't be blank"
23
29
  end
24
30
 
25
- test "should have email" do
31
+ it "has email" do
26
32
  user = Fabricate.build "concen/user", :email => nil
27
- assert_raise(Mongoid::Errors::Validations) { user.save! }
28
- assert_equal user.errors[:email].first, "can't be blank"
33
+ lambda { user.save! }.must_raise(Mongoid::Errors::Validations)
34
+ user.errors[:email].first.must_equal "can't be blank"
29
35
  end
30
36
 
31
- test "should have full_name" do
37
+ it "has full_name" do
32
38
  user = Fabricate.build("concen/user", :full_name => nil)
33
- assert_raise(Mongoid::Errors::Validations) { user.save! }
34
- assert_equal user.errors[:full_name].first, "can't be blank"
39
+ lambda { user.save! }.must_raise(Mongoid::Errors::Validations)
40
+ user.errors[:full_name].first.must_equal "can't be blank"
35
41
  end
36
42
 
37
- test "should authenticate user" do
43
+ it "must authenticate user" do
38
44
  password = {:password => "newpassword", :password_confirmation => "newpassword"}
39
45
  user = Fabricate "concen/user", password
40
- assert user.authenticate("newpassword"), "Cannot authenticate user."
46
+ authenticated_user = user.authenticate("newpassword")
47
+ authenticated_user.wont_equal false
48
+ authenticated_user.must_be_instance_of Concen::User
41
49
  end
42
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-19 00:00:00.000000000Z
12
+ date: 2011-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: compass
16
- requirement: &70181456877540 !ruby/object:Gem::Requirement
16
+ requirement: &70307512129060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.12.alpha
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70181456877540
24
+ version_requirements: *70307512129060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: haml
27
- requirement: &70181456876960 !ruby/object:Gem::Requirement
27
+ requirement: &70307512128260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70181456876960
35
+ version_requirements: *70307512128260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mustache
38
- requirement: &70181456876380 !ruby/object:Gem::Requirement
38
+ requirement: &70307512127260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.99.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70181456876380
46
+ version_requirements: *70307512127260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: redcarpet
49
- requirement: &70181456875800 !ruby/object:Gem::Requirement
49
+ requirement: &70307512125880 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,43 +54,54 @@ dependencies:
54
54
  version: 2.0.0b5
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70181456875800
57
+ version_requirements: *70307512125880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mongoid
60
- requirement: &70181456866080 !ruby/object:Gem::Requirement
60
+ requirement: &70307512125080 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: 2.0.0
65
+ version: 2.2.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70181456866080
68
+ version_requirements: *70307512125080
69
69
  - !ruby/object:Gem::Dependency
70
- name: mongo-rails-instrumentation
71
- requirement: &70181456865600 !ruby/object:Gem::Requirement
70
+ name: mongo
71
+ requirement: &70307512124280 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: 0.2.4
76
+ version: 1.4.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70181456865600
79
+ version_requirements: *70307512124280
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: bson_ext
82
- requirement: &70181456865100 !ruby/object:Gem::Requirement
82
+ requirement: &70307512123400 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
86
86
  - !ruby/object:Gem::Version
87
- version: 1.3.0
87
+ version: 1.4.0
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *70307512123400
91
+ - !ruby/object:Gem::Dependency
92
+ name: mongo-rails-instrumentation
93
+ requirement: &70307512154900 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.2.4
88
99
  type: :runtime
89
100
  prerelease: false
90
- version_requirements: *70181456865100
101
+ version_requirements: *70307512154900
91
102
  - !ruby/object:Gem::Dependency
92
103
  name: rack-gridfs
93
- requirement: &70181456864520 !ruby/object:Gem::Requirement
104
+ requirement: &70307512154380 !ruby/object:Gem::Requirement
94
105
  none: false
95
106
  requirements:
96
107
  - - ~>
@@ -98,10 +109,10 @@ dependencies:
98
109
  version: 0.4.1
99
110
  type: :runtime
100
111
  prerelease: false
101
- version_requirements: *70181456864520
112
+ version_requirements: *70307512154380
102
113
  - !ruby/object:Gem::Dependency
103
114
  name: chronic
104
- requirement: &70181456863940 !ruby/object:Gem::Requirement
115
+ requirement: &70307512153820 !ruby/object:Gem::Requirement
105
116
  none: false
106
117
  requirements:
107
118
  - - ~>
@@ -109,10 +120,10 @@ dependencies:
109
120
  version: 0.6.3
110
121
  type: :runtime
111
122
  prerelease: false
112
- version_requirements: *70181456863940
123
+ version_requirements: *70307512153820
113
124
  - !ruby/object:Gem::Dependency
114
125
  name: mime-types
115
- requirement: &70181456863360 !ruby/object:Gem::Requirement
126
+ requirement: &70307512153260 !ruby/object:Gem::Requirement
116
127
  none: false
117
128
  requirements:
118
129
  - - ~>
@@ -120,10 +131,10 @@ dependencies:
120
131
  version: '1.16'
121
132
  type: :runtime
122
133
  prerelease: false
123
- version_requirements: *70181456863360
134
+ version_requirements: *70307512153260
124
135
  - !ruby/object:Gem::Dependency
125
136
  name: bcrypt-ruby
126
- requirement: &70181456862800 !ruby/object:Gem::Requirement
137
+ requirement: &70307512152700 !ruby/object:Gem::Requirement
127
138
  none: false
128
139
  requirements:
129
140
  - - ~>
@@ -131,10 +142,10 @@ dependencies:
131
142
  version: 3.0.0
132
143
  type: :runtime
133
144
  prerelease: false
134
- version_requirements: *70181456862800
145
+ version_requirements: *70307512152700
135
146
  - !ruby/object:Gem::Dependency
136
147
  name: domainatrix
137
- requirement: &70181456862220 !ruby/object:Gem::Requirement
148
+ requirement: &70307512152080 !ruby/object:Gem::Requirement
138
149
  none: false
139
150
  requirements:
140
151
  - - ~>
@@ -142,7 +153,7 @@ dependencies:
142
153
  version: 0.0.10
143
154
  type: :runtime
144
155
  prerelease: false
145
- version_requirements: *70181456862220
156
+ version_requirements: *70307512152080
146
157
  description: A Rails Engine to control and monitor Rails application from a web interface.
147
158
  It includes content capturing system, real-time traffic monitoring, and real-time
148
159
  performance monitoring. It is built to be flexible and customizable.
@@ -185,7 +196,7 @@ files:
185
196
  - app/assets/images/concen/original/search-field.png
186
197
  - app/assets/images/concen/record-visit.gif
187
198
  - app/assets/images/concen/search-field.png
188
- - app/assets/javascripts/concen/application.js.coffee
199
+ - app/assets/javascripts/concen/application.js
189
200
  - app/assets/javascripts/concen/pages.js
190
201
  - app/assets/javascripts/concen/performances.js
191
202
  - app/assets/javascripts/concen/statuses.js
@@ -404,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
404
415
  version: 1.3.6
405
416
  requirements: []
406
417
  rubyforge_project: concen
407
- rubygems_version: 1.8.9
418
+ rubygems_version: 1.8.10
408
419
  signing_key:
409
420
  specification_version: 3
410
421
  summary: Control and monitor Rails application.
@@ -1,12 +0,0 @@
1
- #= require concen/modernizr
2
- #= require concen/jquery
3
- #= require concen/jquery-ui/jquery.ui.core
4
- #= require concen/jquery-ui/jquery.ui.widget
5
- #= require concen/jquery-ui/jquery.ui.mouse
6
- #= require concen/jquery-ui/jquery.ui.position
7
- #= require concen/jquery-ui/jquery.ui.sortable
8
- #= require concen/jquery-ui/jquery.ui.resizable
9
- #= require concen/jquery-ui/jquery.ui.draggable
10
- #= require concen/jquery-ui/jquery.ui.droppable
11
- #= require concen/jquery.ui.nestedSortable
12
- #= require concen/jquery_ujs