mist 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mist (0.6.2)
4
+ mist (0.6.3)
5
5
  activegist (~> 0.6)
6
6
  git (~> 1.2)
7
7
  github-markup (~> 0.7)
@@ -67,6 +67,7 @@ class Mist::PostsController < ApplicationController
67
67
  # POST /posts.json
68
68
  def create
69
69
  redirect_to posts_path and return unless Mist.authorized?(:create_post, self)
70
+ coerce_date(params[:post], 'published_at')
70
71
  @post = Mist::Post.new(params[:post])
71
72
 
72
73
  respond_to do |format|
@@ -87,6 +88,7 @@ class Mist::PostsController < ApplicationController
87
88
  @post = Mist::Post.find(params[:id])
88
89
 
89
90
  respond_to do |format|
91
+ coerce_date(params[:post], 'published_at')
90
92
  if @post.update_attributes(params[:post])
91
93
  format.html { redirect_to @post, :notice => 'Post was successfully updated.' }
92
94
  format.json { head :ok }
@@ -111,6 +113,21 @@ class Mist::PostsController < ApplicationController
111
113
  end
112
114
 
113
115
  private
116
+ def coerce_date(hash, key)
117
+ date = hash[key]
118
+ unless date.respond_to?(:strftime) || date.blank?
119
+ if date =~ /^.{2}-.{2}-.{4}$/
120
+ hash[key] = DateTime.strptime(date, "%m-%d-%Y")
121
+ elsif date =~ /^.{4}-.{2}-.{2}/
122
+ hash[key] = DateTime.strptime(date, "%Y-%m-%d")
123
+ else
124
+ hash[key] = DateTime.strptime(date, "%a %b %d %H:%M:%S %z %Y")
125
+ end
126
+ end
127
+ rescue
128
+ raise "Couldn't parse date: #{date.inspect}"
129
+ end
130
+
114
131
  def cache_path
115
132
  options = Mist.authorized_actions.inject(ActiveSupport::OrderedHash.new) do |hash, key|
116
133
  hash[key] = true if Mist.authorized?(key, self)
@@ -6,7 +6,7 @@
6
6
 
7
7
  <%= authorized_links admin_link_separator,
8
8
  [:edit_post, 'Edit', edit_post_path(post.id)],
9
- [:destroy_post, 'Destroy', post.id, {:confirm => 'Are you sure?', :method => :delete}] %>
9
+ [:destroy_post, 'Destroy', post_path(post.id), {:confirm => 'Are you sure?', :method => :delete}] %>
10
10
  </div>
11
11
 
12
12
  <%= yield :subcaption %>
@@ -9,14 +9,14 @@ Feature: Recent posts
9
9
 
10
10
  Scenario: Most recent of 7
11
11
  Given I have published these posts:
12
- | title |
13
- | one |
14
- | two |
15
- | three |
16
- | four |
17
- | five |
18
- | six |
19
- | seven |
12
+ | title | published_at |
13
+ | one | 01-01-2011 |
14
+ | two | 01-02-2011 |
15
+ | three | 01-03-2011 |
16
+ | four | 01-04-2011 |
17
+ | five | 01-05-2011 |
18
+ | six | 01-06-2011 |
19
+ | seven | 01-07-2011 |
20
20
  When I go to the posts page
21
21
  Then the "recent posts" sidebar should contain:
22
22
  | title |
@@ -1,6 +1,6 @@
1
1
  module Mist
2
2
  module Version
3
- MAJOR, MINOR, PATCH = 0, 6, 2
3
+ MAJOR, MINOR, PATCH = 0, 6, 3
4
4
  STRING = [MAJOR, MINOR, PATCH].join('.')
5
5
  end
6
6
 
@@ -31,27 +31,39 @@ describe Mist::PostsController do
31
31
  assigns(:posts).should eq([post])
32
32
  end
33
33
 
34
- describe "with 7 posts" do
34
+ describe "with posts" do
35
35
  before do
36
- @one = create(:post, :title => "one", :published_at => 1.day.ago)
37
- @two = create(:post, :title => "two", :published_at => 5.days.ago)
38
- @three = create(:post, :title => "three", :published_at => 1.day.from_now)
39
- @four = create(:post, :title => "four", :published_at => nil)
40
- @five = create(:post, :title => "five", :published_at => 2.days.from_now)
41
- @six = create(:post, :title => "six", :published_at => Time.now)
42
- @seven = create(:post, :title => "seven", :published_at => 2.days.ago)
36
+ post :create, :post => attributes_for(:post, :title => "one", :published_at => '01-26-2012')
37
+ post :create, :post => attributes_for(:post, :title => "two", :published_at => '01-22-2012')
38
+ post :create, :post => attributes_for(:post, :title => "three", :published_at => '01-29-2012')
39
+ post :create, :post => attributes_for(:post, :title => "four", :published_at => nil)
40
+ post :create, :post => attributes_for(:post, :title => "five", :published_at => '01-30-2012')
41
+ post :create, :post => attributes_for(:post, :title => "six", :published_at => '01-28-2012')
42
+ post :create, :post => attributes_for(:post, :title => "seven", :published_at => '01-25-2012')
43
+ post :create, :post => attributes_for(:post, :title => "eight", :published_at => "09-24-2010")
44
+ post :create, :post => attributes_for(:post, :title => "nine", :published_at => "01-27-2012")
45
+
46
+ @one = Mist::Post.find("one")
47
+ @two = Mist::Post.find("two")
48
+ @three = Mist::Post.find("three")
49
+ @four = Mist::Post.find("four")
50
+ @five = Mist::Post.find("five")
51
+ @six = Mist::Post.find("six")
52
+ @seven = Mist::Post.find("seven")
53
+ @eight = Mist::Post.find("eight")
54
+ @nine = Mist::Post.find("nine")
43
55
  end
44
56
 
45
57
  it "assigns the posts in order" do
46
58
  get :index, {:use_route => :mist}, valid_session
47
- assigns(:posts).collect { |p| p.id }.should eq([@four.id, @five.id, @three.id, @six.id, @one.id, @seven.id, @two.id])
59
+ assigns(:posts).collect { |p| p.id }.should eq([@four.id, @five.id, @three.id, @six.id, @nine.id, @one.id, @seven.id, @two.id, @eight.id])
48
60
  end
49
61
 
50
62
  describe "when not authorized" do
51
63
  before { Mist.authorize { false } }
52
64
  it "assigns the posts in order, omitting unpublished" do
53
65
  get :index, {:use_route => :mist}, valid_session
54
- assigns(:posts).collect { |p| p.id }.should eq([@five.id, @three.id, @six.id, @one.id, @seven.id, @two.id])
66
+ assigns(:posts).collect { |p| p.id }.should eq([@five.id, @three.id, @six.id, @nine.id, @one.id, @seven.id, @two.id, @eight.id])
55
67
  end
56
68
  end
57
69
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mist
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Colin MacKenzie IV
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-28 00:00:00 Z
18
+ date: 2012-01-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement