Skip to content

Commit

Permalink
ISO 8601 only!
Browse files Browse the repository at this point in the history
  • Loading branch information
eee-c committed Jul 21, 2009
1 parent 3d83f33 commit f2acc30
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions eee.rb
Expand Up @@ -79,8 +79,8 @@

get %r{/meals/(\d+)/(\d+)} do |year, month|
url = "#{@@db}/_design/meals/_view/by_date?" +
"startkey=%22#{year}/#{month}/00%22&" +
"endkey=%22#{year}/#{month}/99%22"
"startkey=%22#{year}-#{month}-00%22&" +
"endkey=%22#{year}-#{month}-99%22"
data = RestClient.get url
@meals = JSON.parse(data)['rows'].map{|r| r['value']}
@month = "#{year}-#{month}"
Expand All @@ -94,8 +94,8 @@

get %r{/meals/(\d+)} do |year|
url = "#{@@db}/_design/meals/_view/by_date?" +
"startkey=%22#{year}/00/00%22&" +
"endkey=%22#{year}/99/99%22"
"startkey=%22#{year}-00-00%22&" +
"endkey=%22#{year}-99-99%22"
data = RestClient.get url
@meals = JSON.parse(data)['rows'].map{|r| r['value']}
@year = year
Expand Down
44 changes: 22 additions & 22 deletions spec/eee_spec.rb
Expand Up @@ -113,16 +113,16 @@
RestClient.
stub!(:get).
and_return('{"rows": [' +
'{"key":"2009-06-10","value":["2009-06-10","Foo"]},' +
'{"key":"2009-06-09","value":["2009-06-09","Foo"]},' +
'{"key":"2009-06-08","value":["2009-06-08","Foo"]},' +
'{"key":"2009-06-07","value":["2009-06-07","Foo"]},' +
'{"key":"2009-06-06","value":["2009-06-06","Foo"]},' +
'{"key":"2009-06-05","value":["2009-06-05","Foo"]},' +
'{"key":"2009-06-04","value":["2009-06-04","Foo"]},' +
'{"key":"2009-06-03","value":["2009-06-03","Foo"]},' +
'{"key":"2009-06-02","value":["2009-06-02","Foo"]},' +
'{"key":"2009-06-01","value":["2009-06-01","Foo"]}' +
'{"id":"2009-06-10","value":["2009-06-10","Foo"]},' +
'{"id":"2009-06-09","value":["2009-06-09","Foo"]},' +
'{"id":"2009-06-08","value":["2009-06-08","Foo"]},' +
'{"id":"2009-06-07","value":["2009-06-07","Foo"]},' +
'{"id":"2009-06-06","value":["2009-06-06","Foo"]},' +
'{"id":"2009-06-05","value":["2009-06-05","Foo"]},' +
'{"id":"2009-06-04","value":["2009-06-04","Foo"]},' +
'{"id":"2009-06-03","value":["2009-06-03","Foo"]},' +
'{"id":"2009-06-02","value":["2009-06-02","Foo"]},' +
'{"id":"2009-06-01","value":["2009-06-01","Foo"]}' +
']}')

RestClient.
Expand All @@ -148,7 +148,7 @@
it "should ask CouchDB for meal from year YYYY" do
RestClient.
should_receive(:get).
with(%r{by_date.+startkey=.+2009/00/00.+endkey=.+2009/99/99}).
with(%r{by_date.+startkey=.+2009-00-00.+endkey=.+2009-99-99}).
and_return('{"rows": [] }')

get "/meals/2009"
Expand All @@ -174,7 +174,7 @@
it "should ask CouchDB for meals from year YYYY and month MM" do
RestClient.
should_receive(:get).
with(%r{by_date.+startkey=.+2009/05/00.+endkey=.+2009/05/99}).
with(%r{by_date.+startkey=.+2009-05-00.+endkey=.+2009-05-99}).
and_return('{"rows": [] }')

get "/meals/2009/05"
Expand Down Expand Up @@ -482,16 +482,16 @@
RestClient.
stub!(:get).
and_return('{"rows": [' +
'{"key":"2009-06-10","value":["2009-06-10","Foo"]},' +
'{"key":"2009-06-09","value":["2009-06-09","Foo"]},' +
'{"key":"2009-06-08","value":["2009-06-08","Foo"]},' +
'{"key":"2009-06-07","value":["2009-06-07","Foo"]},' +
'{"key":"2009-06-06","value":["2009-06-06","Foo"]},' +
'{"key":"2009-06-05","value":["2009-06-05","Foo"]},' +
'{"key":"2009-06-04","value":["2009-06-04","Foo"]},' +
'{"key":"2009-06-03","value":["2009-06-03","Foo"]},' +
'{"key":"2009-06-02","value":["2009-06-02","Foo"]},' +
'{"key":"2009-06-01","value":["2009-06-01","Foo"]}' +
'{"id":"2009-06-10","value":["2009-06-10","Foo"]},' +
'{"id":"2009-06-09","value":["2009-06-09","Foo"]},' +
'{"id":"2009-06-08","value":["2009-06-08","Foo"]},' +
'{"id":"2009-06-07","value":["2009-06-07","Foo"]},' +
'{"id":"2009-06-06","value":["2009-06-06","Foo"]},' +
'{"id":"2009-06-05","value":["2009-06-05","Foo"]},' +
'{"id":"2009-06-04","value":["2009-06-04","Foo"]},' +
'{"id":"2009-06-03","value":["2009-06-03","Foo"]},' +
'{"id":"2009-06-02","value":["2009-06-02","Foo"]},' +
'{"id":"2009-06-01","value":["2009-06-01","Foo"]}' +
']}')

RestClient.
Expand Down
4 changes: 2 additions & 2 deletions spec/views/meal.haml_spec.rb
Expand Up @@ -17,9 +17,9 @@
}

assigns[:meals_by_date] = [{ "key" => "2009-05-15",
"value" => ['2009-05-15', "Foo"] },
"value" => {'date' => '2009-05-15', 'title' => "Foo"} },
{ "key" => "2009-05-31",
"value" => ["2009-05-31", "Bar"] }]
"value" => {'date' => "2009-05-31", 'title' => "Bar"} }]

assigns[:recipes] = []

Expand Down

0 comments on commit f2acc30

Please sign in to comment.