Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Aug 12, 2024
1 parent 9d72be5 commit ffadb84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/models/experiment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def self.ransackable_attributes(auth_object = nil)
["created_at", "description", "ends_at", "id", "is_test", "name", "owner_id", "starts_at", "status", "updated_at"]
end

def active
active?
end

def active?
(!starts_at || Time.now >= starts_at) && (!ends_at || Time.now <= ends_at)
Expand Down
4 changes: 0 additions & 4 deletions spec/requests/v0/experiments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
name: "test experiment",
description: "a test experiment",
is_test: false,
active: true,
starts_at: "2024-01-01T00:00:00Z",
ends_at: "2024-06-30T23:59:59Z",
device_ids: [ device.id ]
Expand Down Expand Up @@ -65,7 +64,6 @@
expect(created.name).to eq(valid_params[:name])
expect(created.description).to eq(valid_params[:description])
expect(created.is_test).to eq(valid_params[:is_test])
expect(created.active).to eq(valid_params[:active])
expect(created.starts_at).to eq(Time.parse(valid_params[:starts_at]))
expect(created.ends_at).to eq(Time.parse(valid_params[:ends_at]))
expect(created.device_ids).to eq(valid_params[:device_ids])
Expand Down Expand Up @@ -102,7 +100,6 @@
expect(updated.name).to eq(valid_params[:name])
expect(updated.description).to eq(valid_params[:description])
expect(updated.is_test).to eq(valid_params[:is_test])
expect(updated.active).to eq(valid_params[:active])
expect(updated.starts_at).to eq(Time.parse(valid_params[:starts_at]))
expect(updated.ends_at).to eq(Time.parse(valid_params[:ends_at]))
expect(updated.device_ids).to eq(valid_params[:device_ids])
Expand All @@ -127,7 +124,6 @@
expect(updated.name).to eq(valid_params[:name])
expect(updated.description).to eq(valid_params[:description])
expect(updated.is_test).to eq(valid_params[:is_test])
expect(updated.active).to eq(valid_params[:active])
expect(updated.starts_at).to eq(Time.parse(valid_params[:starts_at]))
expect(updated.ends_at).to eq(Time.parse(valid_params[:ends_at]))
expect(updated.device_ids).to eq(valid_params[:device_ids])
Expand Down

0 comments on commit ffadb84

Please sign in to comment.