Permalink
Browse files

Fix chart data

  • Loading branch information...
1 parent 6410f01 commit 4140939c9710112db1da8963324413f5edf78f54 @ignar committed Oct 23, 2012
@@ -31,8 +31,13 @@ def visit
current_user.toggle_visiting(@country)
format.html { redirect_to(countries_path, :flash => { :notice => message }) }
- # TODO it display wrong number of not visited countries
- format.json { render :json => {:message => message, :status => status, :"Visited" => current_user.countries.count, :"Not Visited" => Country.count} }
+ format.json { render :json => {
+ :message => message,
+ :status => status,
+ :"Visited" => current_user.countries.count,
+ :"Not Visited" => Country.count - current_user.countries.count
+ }
+ }
end
end
@@ -30,8 +30,13 @@ def collect
status = "Not Collected"
end
format.html{ redirect_to currencies_path, :flash => {:notice => message} }
- # TODO it display wrong number of not collected currencies
- format.json{ render :json => {:message => message, :status => status, :"Collected" => current_user.currencies.count, :"Not Collected" => Currency.count} }
+ format.json{ render :json => {
+ :message => message,
+ :status => status,
+ :"Collected" => current_user.currencies.count,
+ :"Not Collected" => Currency.count - current_user.currencies.count
+ }
+ }
end
end
end
View
@@ -1,10 +1,10 @@
#+STARTUP: showall
#+BEGIN: clocktable :maxlevel 2 :scope file
-Clock summary at [2012-10-23 Tue 13:03]
+Clock summary at [2012-10-23 Tue 14:22]
| Headline | Time |
|----------------------------------------------------------------------------------+---------|
-| *Total time* | *11:17* |
+| *Total time* | *12:20* |
|----------------------------------------------------------------------------------+---------|
| DONE Setup. Understand the task. Read existed code. | 0:37 |
| DONE Rake task | 0:07 |
@@ -24,6 +24,8 @@ Clock summary at [2012-10-23 Tue 13:03]
| DONE Collecting currencies on user model level | 0:17 |
| DONE Currencies index and show page | 0:13 |
| DONE Visit country on collection update | 0:52 |
+| DONE Give user opportunity to mark currency as selected | 0:57 |
+| DONE Fix chart data | 0:06 |
#+END:
#+STARTUP: hidestars
#+STARTUP: logdone
@@ -95,3 +97,6 @@ Clock summary at [2012-10-23 Tue 13:03]
* DONE Give user opportunity to mark currency as selected
CLOSED: [2012-10-23 Tue 14:07]
CLOCK: [2012-10-23 Tue 13:10]--[2012-10-23 Tue 14:07] => 0:57
+* DONE Fix chart data
+ CLOSED: [2012-10-23 Tue 14:21]
+ CLOCK: [2012-10-23 Tue 14:15]--[2012-10-23 Tue 14:21] => 0:06
@@ -21,8 +21,8 @@
$('.simple_pie_chart').each(function() {
chart = SimplePieChart.initialize(this);
chart.sets = {
- visited: data["Visited"],
- not_visited: data["Not Visited"]
+ "Visited": data["Visited"],
+ "Not Visited": data["Not Visited"]
};
chart.render();
});
@@ -21,8 +21,8 @@
$('.simple_pie_chart').each(function() {
chart = SimplePieChart.initialize(this);
chart.sets = {
- visited: data["Collected"],
- not_visited: data["Not Collected"]
+ "Collected": data["Collected"],
+ "Not Collected": data["Not Collected"]
};
chart.render();
});
@@ -40,8 +40,8 @@
json = ActiveSupport::JSON.decode(response.body)
json["message"].should eq("Country was successfully marked as visited")
json["status"].should eq("Visited")
- json["Visited"].should be_kind_of(Numeric)
- json["Not Visited"].should be_kind_of(Numeric)
+ json["Visited"].should eq(user.countries.count)
+ json["Not Visited"].should eq(Country.count - user.countries.count)
end
it "should mark country as unvisited if it was so" do
@@ -50,8 +50,8 @@
json = ActiveSupport::JSON.decode(response.body)
json["message"].should eq("Country was successfully marked as not visited")
json["status"].should eq("Not Visited")
- json["Visited"].should be_kind_of(Numeric)
- json["Not Visited"].should be_kind_of(Numeric)
+ json["Visited"].should eq(user.countries.count)
+ json["Not Visited"].should eq(Country.count - user.countries.count)
end
end
end
@@ -41,8 +41,8 @@
json = ActiveSupport::JSON.decode(response.body)
json["message"].should eq("Currency was successfully as collected")
json["status"].should eq("Collected")
- json["Collected"].should be_kind_of(Numeric)
- json["Not Collected"].should be_kind_of(Numeric)
+ json["Collected"].should eq(user.currencies.count)
+ json["Not Collected"].should eq(Currency.count - user.currencies.count)
end
it "should set currency as not collecte" do
@@ -51,8 +51,8 @@
json = ActiveSupport::JSON.decode(response.body)
json["message"].should eq("Currency was successfully as not collected")
json["status"].should eq("Not Collected")
- json["Collected"].should be_kind_of(Numeric)
- json["Not Collected"].should be_kind_of(Numeric)
+ json["Collected"].should eq(user.currencies.count)
+ json["Not Collected"].should eq(Currency.count - user.currencies.count)
end
end
end

0 comments on commit 4140939

Please sign in to comment.