fixes specs

This commit is contained in:
rgarcia
2016-05-17 23:36:20 +02:00
committed by Javi Martín
parent 0d9ff07ff5
commit b628631769
6 changed files with 13 additions and 39 deletions

View File

@@ -31,23 +31,13 @@ describe Admin::Api::StatsController do
it "returns single events formated for working with c3.js" do
sign_in user
get :show, params: { events: "foo" }
get :show, params: { event: "foo" }
expect(response).to be_ok
data = JSON.parse(response.body)
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
end
it "returns combined comma separated events formated for working with c3.js" do
sign_in user
get :show, params: { events: "foo,bar" }
expect(response).to be_ok
data = JSON.parse(response.body)
expect(data).to eq "x" => ["2015-01-01", "2015-01-02", "2015-01-03"], "Foo" => [2, 1, 0], "Bar" => [1, 0, 2]
end
end
context "visits present" do
@@ -69,29 +59,6 @@ describe Admin::Api::StatsController do
end
end
context "visits and events present" do
it "returns combined events and visits formated for working with c3.js" do
time_1 = Time.zone.local(2015, 01, 01)
time_2 = Time.zone.local(2015, 01, 02)
create :ahoy_event, name: "foo", time: time_1
create :ahoy_event, name: "foo", time: time_2
create :ahoy_event, name: "foo", time: time_2
create :visit, started_at: time_1
create :visit, started_at: time_1
create :visit, started_at: time_2
sign_in user
get :show, params: { events: "foo", visits: true }
expect(response).to be_ok
data = JSON.parse(response.body)
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [1, 2], "Visits" => [2, 1]
end
end
context "budget investments present" do
it "returns budget investments formated for working with c3.js" do
time_1 = Time.zone.local(2017, 04, 01)