From f253a4f1ebf889de9b11e7bdd070a022a549048a Mon Sep 17 00:00:00 2001
From: Diego Araújo
Date: Tue, 27 Jan 2015 16:21:55 -0200
Subject: [PATCH] Renamed MezuroRanges to KalibroRanges
---
app/controllers/base_metric_configurations_controller.rb | 2 +-
app/controllers/kalibro_ranges_controller.rb | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
app/controllers/mezuro_ranges_controller.rb | 90 ------------------------------------------------------------------------------------------
app/helpers/kalibro_ranges_helper.rb | 5 +++++
app/helpers/mezuro_ranges_helper.rb | 5 -----
app/models/kalibro_range.rb | 2 ++
app/models/mezuro_range.rb | 2 --
app/views/compound_metric_configurations/show.html.erb | 6 +++---
app/views/kalibro_ranges/_form.html.erb | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
app/views/kalibro_ranges/_no_readings.html.erb | 10 ++++++++++
app/views/kalibro_ranges/edit.html.erb | 6 ++++++
app/views/kalibro_ranges/new.html.erb | 6 ++++++
app/views/metric_configurations/_ranges.html.erb | 16 ++++++++--------
app/views/metric_configurations/show.html.erb | 10 +++++-----
app/views/mezuro_ranges/_form.html.erb | 74 --------------------------------------------------------------------------
app/views/mezuro_ranges/_no_readings.html.erb | 10 ----------
app/views/mezuro_ranges/edit.html.erb | 6 ------
app/views/mezuro_ranges/new.html.erb | 6 ------
config/routes.rb | 6 +++---
features/kalibro_range/create.feature | 185 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
features/kalibro_range/deletion.feature | 30 ++++++++++++++++++++++++++++++
features/kalibro_range/edit.feature | 36 ++++++++++++++++++++++++++++++++++++
features/mezuro_range/create.feature | 185 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
features/mezuro_range/deletion.feature | 30 ------------------------------
features/mezuro_range/edit.feature | 36 ------------------------------------
features/step_definitions/compound_metric_configuration_steps.rb | 4 ++--
features/step_definitions/kalibro_range_steps.rb | 39 +++++++++++++++++++++++++++++++++++++++
features/step_definitions/mezuro_range_steps.rb | 39 ---------------------------------------
features/step_definitions/repository_steps.rb | 2 +-
spec/controllers/base_metric_configurations_controller_spec.rb | 10 +++++-----
spec/controllers/compound_metric_configurations_controller_spec.rb | 4 ++--
spec/controllers/kalibro_ranges_controller_spec.rb | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
spec/controllers/metric_configurations_controller_spec.rb | 4 ++--
spec/controllers/mezuro_ranges_controller_spec.rb | 206 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
spec/factories/kalibro_ranges.rb | 36 ++++++++++++++++++++++++++++++++++++
spec/factories/mezuro_ranges.rb | 31 -------------------------------
spec/helpers/kalibro_ranges_helper_spec.rb | 11 +++++++++++
spec/helpers/mezuro_ranges_helper_spec.rb | 11 -----------
spec/routing/kalibro_ranges_routing_spec.rb | 20 ++++++++++++++++++++
spec/routing/mezuro_ranges_routing_spec.rb | 20 --------------------
40 files changed, 788 insertions(+), 783 deletions(-)
create mode 100644 app/controllers/kalibro_ranges_controller.rb
delete mode 100644 app/controllers/mezuro_ranges_controller.rb
create mode 100644 app/helpers/kalibro_ranges_helper.rb
delete mode 100644 app/helpers/mezuro_ranges_helper.rb
create mode 100644 app/models/kalibro_range.rb
delete mode 100644 app/models/mezuro_range.rb
create mode 100644 app/views/kalibro_ranges/_form.html.erb
create mode 100644 app/views/kalibro_ranges/_no_readings.html.erb
create mode 100644 app/views/kalibro_ranges/edit.html.erb
create mode 100644 app/views/kalibro_ranges/new.html.erb
delete mode 100644 app/views/mezuro_ranges/_form.html.erb
delete mode 100644 app/views/mezuro_ranges/_no_readings.html.erb
delete mode 100644 app/views/mezuro_ranges/edit.html.erb
delete mode 100644 app/views/mezuro_ranges/new.html.erb
create mode 100644 features/kalibro_range/create.feature
create mode 100644 features/kalibro_range/deletion.feature
create mode 100644 features/kalibro_range/edit.feature
delete mode 100644 features/mezuro_range/create.feature
delete mode 100644 features/mezuro_range/deletion.feature
delete mode 100644 features/mezuro_range/edit.feature
create mode 100644 features/step_definitions/kalibro_range_steps.rb
delete mode 100644 features/step_definitions/mezuro_range_steps.rb
create mode 100644 spec/controllers/kalibro_ranges_controller_spec.rb
delete mode 100644 spec/controllers/mezuro_ranges_controller_spec.rb
create mode 100644 spec/factories/kalibro_ranges.rb
delete mode 100644 spec/factories/mezuro_ranges.rb
create mode 100644 spec/helpers/kalibro_ranges_helper_spec.rb
delete mode 100644 spec/helpers/mezuro_ranges_helper_spec.rb
create mode 100644 spec/routing/kalibro_ranges_routing_spec.rb
delete mode 100644 spec/routing/mezuro_ranges_routing_spec.rb
diff --git a/app/controllers/base_metric_configurations_controller.rb b/app/controllers/base_metric_configurations_controller.rb
index 281d6f5..d918cee 100644
--- a/app/controllers/base_metric_configurations_controller.rb
+++ b/app/controllers/base_metric_configurations_controller.rb
@@ -15,7 +15,7 @@ class BaseMetricConfigurationsController < ApplicationController
def show
if metric_configuration
@reading_group = ReadingGroup.find(metric_configuration.reading_group_id)
- @mezuro_ranges = metric_configuration.kalibro_ranges
+ @kalibro_ranges = metric_configuration.kalibro_ranges
else
raise NotImplementedError
end
diff --git a/app/controllers/kalibro_ranges_controller.rb b/app/controllers/kalibro_ranges_controller.rb
new file mode 100644
index 0000000..0fdf5bb
--- /dev/null
+++ b/app/controllers/kalibro_ranges_controller.rb
@@ -0,0 +1,90 @@
+include OwnershipAuthentication
+include ResourceFinder
+
+class KalibroRangesController < ApplicationController
+ before_action :authenticate_user!, except: [:show]
+ before_action :metric_configuration_owner?, only: [:new, :create, :destroy, :edit, :update]
+ before_action :get_url_params, only: [:update, :create, :destroy]
+ before_action :set_kalibro_range, only: [:edit, :update, :destroy]
+
+ def new
+ @kalibro_range = KalibroRange.new
+ before_form
+ end
+
+ def create
+ @kalibro_range = KalibroRange.new(kalibro_range_params)
+ @kalibro_range.metric_configuration_id = params[:metric_configuration_id].to_i
+ respond_to do |format|
+ create_and_redir(format)
+ end
+ end
+
+ def destroy
+ @kalibro_range.destroy
+ respond_to do |format|
+ format.html { redirect_to kalibro_configuration_metric_configuration_path(
+ @kalibro_configuration_id, @metric_configuration_id) }
+ format.json { head :no_content }
+ end
+ end
+
+ def edit
+ before_form
+ end
+
+ def update
+ respond_to do |format|
+ @kalibro_range.metric_configuration_id = @metric_configuration_id
+ if @kalibro_range.update(kalibro_range_params)
+ format.html { redirect_to kalibro_configuration_metric_configuration_path(
+ @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully edited.' }
+ format.json { head :no_content }
+ else
+ failed_action(format, 'edit')
+ end
+ end
+ end
+
+ private
+
+ def kalibro_range_params
+ params[:kalibro_range][:beginning] = params[:kalibro_range][:beginning].to_f.to_s if numeric?(params[:kalibro_range][:beginning]) # this is necessary for the beginning validator
+ params[:kalibro_range]
+ end
+
+ def create_and_redir(format)
+ if @kalibro_range.save
+ format.html { redirect_to kalibro_configuration_metric_configuration_path(
+ @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully created.' }
+ else
+ failed_action(format, 'new')
+ end
+ end
+
+ def failed_action(format, destiny_action)
+ before_form
+ format.html { render action: destiny_action }
+ format.json { render json: @kalibro_range.errors, status: :unprocessable_entity }
+ end
+
+ def before_form
+ get_url_params
+ @reading_group_id = MetricConfiguration.find(@metric_configuration_id).reading_group_id
+ @readings = Reading.readings_of(@reading_group_id)
+ end
+
+ def get_url_params
+ @kalibro_configuration_id = params[:kalibro_configuration_id].to_i
+ @metric_configuration_id = params[:metric_configuration_id].to_i
+ end
+
+ # used on kalibro_range_params
+ def numeric?(text)
+ Float(text) != nil rescue false
+ end
+
+ def set_kalibro_range
+ @kalibro_range = find_resource(KalibroRange, params[:id].to_i)
+ end
+end
diff --git a/app/controllers/mezuro_ranges_controller.rb b/app/controllers/mezuro_ranges_controller.rb
deleted file mode 100644
index dc92a70..0000000
--- a/app/controllers/mezuro_ranges_controller.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-include OwnershipAuthentication
-include ResourceFinder
-
-class MezuroRangesController < ApplicationController
- before_action :authenticate_user!, except: [:show]
- before_action :metric_configuration_owner?, only: [:new, :create, :destroy, :edit, :update]
- before_action :get_url_params, only: [:update, :create, :destroy]
- before_action :set_mezuro_range, only: [:edit, :update, :destroy]
-
- def new
- @mezuro_range = MezuroRange.new
- before_form
- end
-
- def create
- @mezuro_range = MezuroRange.new(mezuro_range_params)
- @mezuro_range.metric_configuration_id = params[:metric_configuration_id].to_i
- respond_to do |format|
- create_and_redir(format)
- end
- end
-
- def destroy
- @mezuro_range.destroy
- respond_to do |format|
- format.html { redirect_to kalibro_configuration_metric_configuration_path(
- @kalibro_configuration_id, @metric_configuration_id) }
- format.json { head :no_content }
- end
- end
-
- def edit
- before_form
- end
-
- def update
- respond_to do |format|
- @mezuro_range.metric_configuration_id = @metric_configuration_id
- if @mezuro_range.update(mezuro_range_params)
- format.html { redirect_to kalibro_configuration_metric_configuration_path(
- @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully edited.' }
- format.json { head :no_content }
- else
- failed_action(format, 'edit')
- end
- end
- end
-
- private
-
- def mezuro_range_params
- params[:mezuro_range][:beginning] = params[:mezuro_range][:beginning].to_f.to_s if numeric?(params[:mezuro_range][:beginning]) # this is necessary for the beginning validator
- params[:mezuro_range]
- end
-
- def create_and_redir(format)
- if @mezuro_range.save
- format.html { redirect_to kalibro_configuration_metric_configuration_path(
- @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully created.' }
- else
- failed_action(format, 'new')
- end
- end
-
- def failed_action(format, destiny_action)
- before_form
- format.html { render action: destiny_action }
- format.json { render json: @mezuro_range.errors, status: :unprocessable_entity }
- end
-
- def before_form
- get_url_params
- @reading_group_id = MetricConfiguration.find(@metric_configuration_id).reading_group_id
- @readings = Reading.readings_of(@reading_group_id)
- end
-
- def get_url_params
- @kalibro_configuration_id = params[:kalibro_configuration_id].to_i
- @metric_configuration_id = params[:metric_configuration_id].to_i
- end
-
- # used on mezuro_range_params
- def numeric?(text)
- Float(text) != nil rescue false
- end
-
- def set_mezuro_range
- @mezuro_range = find_resource(MezuroRange, params[:id].to_i)
- end
-end
diff --git a/app/helpers/kalibro_ranges_helper.rb b/app/helpers/kalibro_ranges_helper.rb
new file mode 100644
index 0000000..a90b669
--- /dev/null
+++ b/app/helpers/kalibro_ranges_helper.rb
@@ -0,0 +1,5 @@
+module KalibroRangesHelper
+ def readings_options(readings)
+ readings.map { |reading| [reading.label, reading.id] }
+ end
+end
\ No newline at end of file
diff --git a/app/helpers/mezuro_ranges_helper.rb b/app/helpers/mezuro_ranges_helper.rb
deleted file mode 100644
index 63e0a21..0000000
--- a/app/helpers/mezuro_ranges_helper.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module MezuroRangesHelper
- def readings_options(readings)
- readings.map { |reading| [reading.label, reading.id] }
- end
-end
\ No newline at end of file
diff --git a/app/models/kalibro_range.rb b/app/models/kalibro_range.rb
new file mode 100644
index 0000000..3a0b133
--- /dev/null
+++ b/app/models/kalibro_range.rb
@@ -0,0 +1,2 @@
+class KalibroRange < KalibroClient::Entities::Configurations::KalibroRange
+end
diff --git a/app/models/mezuro_range.rb b/app/models/mezuro_range.rb
deleted file mode 100644
index d93db36..0000000
--- a/app/models/mezuro_range.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class MezuroRange < KalibroClient::Entities::Configurations::KalibroRange
-end
diff --git a/app/views/compound_metric_configurations/show.html.erb b/app/views/compound_metric_configurations/show.html.erb
index 5102b29..b149420 100644
--- a/app/views/compound_metric_configurations/show.html.erb
+++ b/app/views/compound_metric_configurations/show.html.erb
@@ -45,7 +45,7 @@
Ranges
<% if kalibro_configuration_owner? @compound_metric_configuration.configuration_id %>
- <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_mezuro_range_path(@compound_metric_configuration.configuration_id,
+ <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_kalibro_range_path(@compound_metric_configuration.configuration_id,
@compound_metric_configuration.id), class: 'btn btn-info' %>
<% end %>
@@ -58,10 +58,10 @@
- <% if @mezuro_ranges.empty? %>
+ <% if @kalibro_ranges.empty? %>
<%= render partial: 'metric_configurations/no_ranges' %>
<% else %>
- <%= render partial: 'metric_configurations/ranges', collection: @mezuro_ranges, as: :mezuro_range %>
+ <%= render partial: 'metric_configurations/ranges', collection: @kalibro_ranges, as: :kalibro_range %>
<% end %>
diff --git a/app/views/kalibro_ranges/_form.html.erb b/app/views/kalibro_ranges/_form.html.erb
new file mode 100644
index 0000000..7ac59be
--- /dev/null
+++ b/app/views/kalibro_ranges/_form.html.erb
@@ -0,0 +1,74 @@
+ <%= render :partial => 'shared/form_errors', :locals => {:object => @kalibro_range} %>
+
+
+
+
+ <%= f.submit 'Save', class: 'btn btn-primary' %>
+ <%= link_to 'Back', kalibro_configuration_metric_configuration_path(@kalibro_configuration_id, @metric_configuration_id), class: 'btn btn-default' %>
+
diff --git a/app/views/kalibro_ranges/_no_readings.html.erb b/app/views/kalibro_ranges/_no_readings.html.erb
new file mode 100644
index 0000000..edba299
--- /dev/null
+++ b/app/views/kalibro_ranges/_no_readings.html.erb
@@ -0,0 +1,10 @@
+
+
You must have Readings within your associated Reading Group to create a new Range.
+
+ <% if reading_groups_owner? @reading_group_id %>
+
<%= link_to 'Create New Reading', new_reading_group_reading_path(@reading_group_id), class: 'btn btn-danger' %>
+ <% else %>
+
The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it.
+ <% end %>
+
+
diff --git a/app/views/kalibro_ranges/edit.html.erb b/app/views/kalibro_ranges/edit.html.erb
new file mode 100644
index 0000000..eada199
--- /dev/null
+++ b/app/views/kalibro_ranges/edit.html.erb
@@ -0,0 +1,6 @@
+Edit Range
+
+<%= form_for(@kalibro_range, :url => kalibro_configuration_metric_configuration_kalibro_range_update_url(
+ @kalibro_configuration_id, @metric_configuration_id, @kalibro_range.id), method: :put) do |f| %>
+ <%= render partial: 'form', locals: {f: f} %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/kalibro_ranges/new.html.erb b/app/views/kalibro_ranges/new.html.erb
new file mode 100644
index 0000000..774353f
--- /dev/null
+++ b/app/views/kalibro_ranges/new.html.erb
@@ -0,0 +1,6 @@
+New Range
+
+<%= form_for(@kalibro_range, :url => kalibro_configuration_metric_configuration_kalibro_ranges_path(
+ @kalibro_configuration_id, @metric_configuration_id)) do |f| %>
+ <%= render partial: 'form', locals: {f: f} %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/metric_configurations/_ranges.html.erb b/app/views/metric_configurations/_ranges.html.erb
index 8aed95e..50857b2 100644
--- a/app/views/metric_configurations/_ranges.html.erb
+++ b/app/views/metric_configurations/_ranges.html.erb
@@ -1,18 +1,18 @@
-
- <%= mezuro_range.label %>
+
+ <%= kalibro_range.label %>
|
- <%= mezuro_range.beginning %> |
- <%= mezuro_range.end %> |
+ <%= kalibro_range.beginning %> |
+ <%= kalibro_range.end %> |
<% if kalibro_configuration_owner? @metric_configuration.configuration_id %>
- <%= link_to 'Edit', edit_kalibro_configuration_metric_configuration_mezuro_range_path(
- @metric_configuration.configuration_id, @metric_configuration.id, mezuro_range.id), class: 'btn btn-info' %>
- <%= link_to 'Destroy', kalibro_configuration_metric_configuration_mezuro_range_path(@metric_configuration.configuration_id,
- @metric_configuration.id, mezuro_range.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Range?' },
+ <%= link_to 'Edit', edit_kalibro_configuration_metric_configuration_kalibro_range_path(
+ @metric_configuration.configuration_id, @metric_configuration.id, kalibro_range.id), class: 'btn btn-info' %>
+ <%= link_to 'Destroy', kalibro_configuration_metric_configuration_kalibro_range_path(@metric_configuration.configuration_id,
+ @metric_configuration.id, kalibro_range.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Range?' },
class: 'btn btn-danger' %>
<% end %>
|
diff --git a/app/views/metric_configurations/show.html.erb b/app/views/metric_configurations/show.html.erb
index a924946..b455c69 100644
--- a/app/views/metric_configurations/show.html.erb
+++ b/app/views/metric_configurations/show.html.erb
@@ -42,7 +42,7 @@
<% if @metric_configuration.metric.description.nil? %>
<%= "There is no description available." %>
<% else %>
- <%= @metric_configuration.metric.description %>
+ <%= @metric_configuration.metric.description %>
<% end %>
@@ -50,7 +50,7 @@
Ranges
<% if kalibro_configuration_owner? @metric_configuration.configuration_id %>
- <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_mezuro_range_path(@metric_configuration.configuration_id,
+ <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_kalibro_range_path(@metric_configuration.configuration_id,
@metric_configuration.id), class: 'btn btn-info' %>
<% end %>
@@ -63,10 +63,10 @@
- <% if @mezuro_ranges.empty? %>
+ <% if @kalibro_ranges.empty? %>
<%= render partial: 'no_ranges' %>
<% else %>
- <%= render partial: 'ranges', collection: @mezuro_ranges, as: :mezuro_range %>
+ <%= render partial: 'ranges', collection: @kalibro_ranges, as: :kalibro_range %>
<% end %>
@@ -75,7 +75,7 @@
<%= link_to 'Back', kalibro_configuration_path(@metric_configuration.configuration_id), class: 'btn btn-default' %>
<% if kalibro_configuration_owner? @metric_configuration.configuration_id %>
<%= link_to 'Destroy Metric Configuration', kalibro_configuration_metric_configuration_path(@metric_configuration.configuration_id,
- @metric_configuration.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Metric Configuration?' },
+ @metric_configuration.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Metric Configuration?' },
class: 'btn btn-danger' %>
<% end %>
diff --git a/app/views/mezuro_ranges/_form.html.erb b/app/views/mezuro_ranges/_form.html.erb
deleted file mode 100644
index 329446e..0000000
--- a/app/views/mezuro_ranges/_form.html.erb
+++ /dev/null
@@ -1,74 +0,0 @@
- <%= render :partial => 'shared/form_errors', :locals => {:object => @mezuro_range} %>
-
-
-
-
- <%= f.submit 'Save', class: 'btn btn-primary' %>
- <%= link_to 'Back', kalibro_configuration_metric_configuration_path(@kalibro_configuration_id, @metric_configuration_id), class: 'btn btn-default' %>
-
diff --git a/app/views/mezuro_ranges/_no_readings.html.erb b/app/views/mezuro_ranges/_no_readings.html.erb
deleted file mode 100644
index edba299..0000000
--- a/app/views/mezuro_ranges/_no_readings.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
You must have Readings within your associated Reading Group to create a new Range.
-
- <% if reading_groups_owner? @reading_group_id %>
-
<%= link_to 'Create New Reading', new_reading_group_reading_path(@reading_group_id), class: 'btn btn-danger' %>
- <% else %>
-
The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it.
- <% end %>
-
-
diff --git a/app/views/mezuro_ranges/edit.html.erb b/app/views/mezuro_ranges/edit.html.erb
deleted file mode 100644
index 1453383..0000000
--- a/app/views/mezuro_ranges/edit.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-Edit Range
-
-<%= form_for(@mezuro_range, :url => kalibro_configuration_metric_configuration_mezuro_range_update_url(
- @kalibro_configuration_id, @metric_configuration_id, @mezuro_range.id), method: :put) do |f| %>
- <%= render partial: 'form', locals: {f: f} %>
-<% end %>
\ No newline at end of file
diff --git a/app/views/mezuro_ranges/new.html.erb b/app/views/mezuro_ranges/new.html.erb
deleted file mode 100644
index 8e9bc09..0000000
--- a/app/views/mezuro_ranges/new.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-New Range
-
-<%= form_for(@mezuro_range, :url => kalibro_configuration_metric_configuration_mezuro_ranges_path(
- @kalibro_configuration_id, @metric_configuration_id)) do |f| %>
- <%= render partial: 'form', locals: {f: f} %>
-<% end %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 8c5b7b2..43f177c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -13,9 +13,9 @@ Rails.application.routes.draw do
resources :kalibro_configurations do
get '/metric_configurations/choose_metric' => 'metric_configurations#choose_metric', as: :choose_metric
resources :metric_configurations, except: [:update, :new] do
- get '/mezuro_ranges/new' => 'mezuro_ranges#new', as: :new_mezuro_range
- resources :mezuro_ranges, except: [:update, :new]
- put '/mezuro_ranges/:id' => 'mezuro_ranges#update', as: :mezuro_range_update
+ get '/kalibro_ranges/new' => 'kalibro_ranges#new', as: :new_kalibro_range
+ resources :kalibro_ranges, except: [:update, :new]
+ put '/kalibro_ranges/:id' => 'kalibro_ranges#update', as: :kalibro_range_update
end
post '/metric_configurations/new' => 'metric_configurations#new', as: :new_metric_configuration
put '/metric_configurations/:id' => 'metric_configurations#update', as: :metric_configuration_update
diff --git a/features/kalibro_range/create.feature b/features/kalibro_range/create.feature
new file mode 100644
index 0000000..fd3d4b4
--- /dev/null
+++ b/features/kalibro_range/create.feature
@@ -0,0 +1,185 @@
+Feature: Create range
+ In order to be able to create new ranges
+ As a metric specialist
+ I should be able to fill up a form with its informations and submit it
+
+ @kalibro_configuration_restart
+ Scenario: Visiting range creation page when the user own an non-empty reading group
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I am at the sample metric configuration page
+ When I click the Add Range link
+ Then I should be at the New Range page
+ And I should see "Beginning"
+ And I should see "End"
+ And I should see "Comments"
+ And I should see "Reading"
+
+ @kalibro_configuration_restart
+ Scenario: Visiting range creation page when the user don't own the reading group and this reading group is empty
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I have a reading group named "Scholar"
+ And I have a sample metric configuration within the given mezuro configuration
+ And I am at the sample metric configuration page
+ When I click the Add Range link
+ Then I should be at the New Range page
+ And I should see "Beginning"
+ And I should see "End"
+ And I should see "Comments"
+ And I should see "You must have Readings within your associated Reading Group to create a new Range."
+ And I should see "The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it."
+
+ @kalibro_configuration_restart
+ Scenario: Visiting range creation page when the user own an empty reading group (testing link to New Reading)
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I am at the sample metric configuration page
+ When I click the Add Range link
+ Then I should be at the New Range page
+ And I should see "Beginning"
+ And I should see "End"
+ And I should see "Comments"
+ And I should see "You must have Readings within your associated Reading Group to create a new Range."
+ When I click the Create New Reading link
+ Then I should be at the New Reading page
+ And I should see "Label"
+ And I should see "Grade"
+ And I should see "Color"
+
+ @kalibro_configuration_restart
+ Scenario: With valid fields and owning a non-empty reading group
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I am at the New Range page
+ And I fill the Beginning field with "42"
+ And I fill the End field with "666"
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ When I press the Save button
+ Then I should be at metric configuration sample page
+
+ @kalibro_configuration_restart
+ Scenario: With invalid fields and owning a non-empty reading group (Beginning > End)
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I am at the New Range page
+ And I fill the Beginning field with "666"
+ And I fill the End field with "42"
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ When I press the Save button
+ Then I should be at the New Range page
+ And I should see "1 error prohibited this KalibroRange from being saved"
+ And I should see "[666.0, 42.0[ is not a valid range"
+
+ @kalibro_configuration_restart
+ Scenario: With an invalid beggining (not a number)
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I am at the New Range page
+ And I fill the Beginning field with "z"
+ And I fill the End field with "42"
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ When I press the Save button
+ Then I should be at the New Range page
+ And I should see "1 error prohibited this KalibroRange from being saved"
+ And I should see "Beginning is not a number"
+
+ @kalibro_configuration_restart
+ Scenario: With an invalid end (not a number)
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I am at the New Range page
+ And I fill the Beginning field with "42"
+ And I fill the End field with "z"
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ When I press the Save button
+ Then I should see "1 error prohibited this KalibroRange from being saved"
+ And I should be at the New Range page
+
+ @kalibro_configuration_restart
+ Scenario: With an already taken beginning
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I have a sample range within the sample metric configuration with beginning "2"
+ And I am at the New Range page
+ And I fill the Beginning field with "2"
+ And I fill the End field with "666"
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ When I press the Save button
+ Then I should be at the New Range page
+ And I should see "Beginning There is already a KalibroRange with beginning 2.0! Please, choose another one."
+
+ @kalibro_configuration_restart @javascript
+ Scenario: Should create range with [-INF, INF] threshold
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I am at the New Range page
+ And I click the -∞ link
+ And I click the ∞ link
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ When I press the Save button
+ Then I should be at metric configuration sample page
+ And I should see "-INF"
+ And I should see "INF"
+
+ @kalibro_configuration_restart @javascript
+ Scenario: Two valid ranges (one with INF)
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I am at the New Range page
+ And I fill the Beginning field with "2"
+ And I fill the End field with "666"
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ And I press the Save button
+ And I am at the New Range page
+ And I fill the Beginning field with "666"
+ And I click the ∞ link
+ And I fill the Comments field with "My Comment"
+ And I set the select field "Reading" as "My Reading"
+ When I press the Save button
+ Then I should be at metric configuration sample page
+ And I should see "666"
+ And I should see "INF"
\ No newline at end of file
diff --git a/features/kalibro_range/deletion.feature b/features/kalibro_range/deletion.feature
new file mode 100644
index 0000000..802083b
--- /dev/null
+++ b/features/kalibro_range/deletion.feature
@@ -0,0 +1,30 @@
+Feature: Range Deletion
+ In order to be able to remove a range
+ As a regular user
+ The system should have an interface to it
+
+ @kalibro_configuration_restart
+ Scenario: Should delete a range that I own
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I have a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I have a sample range within the sample metric configuration
+ And I am at the sample metric configuration page
+ When I click the Destroy link
+ Then I should be at metric configuration sample page
+ And I should see "There are no Ranges yet!"
+
+ @kalibro_configuration_restart
+ Scenario: Should not see the destroy range link in the range that I not own
+ Given I am a regular user
+ And I am signed in
+ And I have a sample configuration
+ And I have a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I have a sample range within the sample metric configuration
+ When I am at the sample metric configuration page
+ Then I should not see "Destroy"
diff --git a/features/kalibro_range/edit.feature b/features/kalibro_range/edit.feature
new file mode 100644
index 0000000..fa1f691
--- /dev/null
+++ b/features/kalibro_range/edit.feature
@@ -0,0 +1,36 @@
+Feature: Kalibro Range Edit
+ In Order to be able to update my kalibro range info
+ As a regular user
+ I should be able to edit my kalibro ranges
+
+ @kalibro_configuration_restart
+ Scenario: editing a kalibro range successfully
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I have a sample range within the sample metric configuration with beginning "1.1"
+ And I am at the Edit Kalibro Range page
+ And the select field "Reading" is set as "My Reading"
+ And the field "Beginning" should be filled with "1.1"
+ And the field "End" should be filled with "5.1"
+ And the field "Comments" should be filled with "Comment"
+ When I fill the Beginning field with "2.2"
+ And I press the Save button
+ Then I should see "2.2"
+
+ @kalibro_configuration_restart
+ Scenario: editing a kalibro range with blank fields
+ Given I am a regular user
+ And I am signed in
+ And I own a sample configuration
+ And I own a sample reading group
+ And I have a sample metric configuration within the given mezuro configuration
+ And I have a sample reading within the sample reading group labeled "My Reading"
+ And I have a sample range within the sample metric configuration with beginning "1"
+ And I am at the Edit Kalibro Range page
+ When I fill the Beginning field with " "
+ And I press the Save button
+ Then I should see "Beginning can't be blank"
diff --git a/features/mezuro_range/create.feature b/features/mezuro_range/create.feature
deleted file mode 100644
index 7948fb3..0000000
--- a/features/mezuro_range/create.feature
+++ /dev/null
@@ -1,185 +0,0 @@
-Feature: Create range
- In order to be able to create new ranges
- As a metric specialist
- I should be able to fill up a form with its informations and submit it
-
- @kalibro_configuration_restart
- Scenario: Visiting range creation page when the user own an non-empty reading group
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I am at the sample metric configuration page
- When I click the Add Range link
- Then I should be at the New Range page
- And I should see "Beginning"
- And I should see "End"
- And I should see "Comments"
- And I should see "Reading"
-
- @kalibro_configuration_restart
- Scenario: Visiting range creation page when the user don't own the reading group and this reading group is empty
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I have a reading group named "Scholar"
- And I have a sample metric configuration within the given mezuro configuration
- And I am at the sample metric configuration page
- When I click the Add Range link
- Then I should be at the New Range page
- And I should see "Beginning"
- And I should see "End"
- And I should see "Comments"
- And I should see "You must have Readings within your associated Reading Group to create a new Range."
- And I should see "The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it."
-
- @kalibro_configuration_restart
- Scenario: Visiting range creation page when the user own an empty reading group (testing link to New Reading)
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I am at the sample metric configuration page
- When I click the Add Range link
- Then I should be at the New Range page
- And I should see "Beginning"
- And I should see "End"
- And I should see "Comments"
- And I should see "You must have Readings within your associated Reading Group to create a new Range."
- When I click the Create New Reading link
- Then I should be at the New Reading page
- And I should see "Label"
- And I should see "Grade"
- And I should see "Color"
-
- @kalibro_configuration_restart
- Scenario: With valid fields and owning a non-empty reading group
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I am at the New Range page
- And I fill the Beginning field with "42"
- And I fill the End field with "666"
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- When I press the Save button
- Then I should be at metric configuration sample page
-
- @kalibro_configuration_restart
- Scenario: With invalid fields and owning a non-empty reading group (Beginning > End)
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I am at the New Range page
- And I fill the Beginning field with "666"
- And I fill the End field with "42"
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- When I press the Save button
- Then I should be at the New Range page
- And I should see "1 error prohibited this MezuroRange from being saved"
- And I should see "[666.0, 42.0[ is not a valid range"
-
- @kalibro_configuration_restart
- Scenario: With an invalid beggining (not a number)
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I am at the New Range page
- And I fill the Beginning field with "z"
- And I fill the End field with "42"
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- When I press the Save button
- Then I should be at the New Range page
- And I should see "1 error prohibited this MezuroRange from being saved"
- And I should see "Beginning is not a number"
-
- @kalibro_configuration_restart
- Scenario: With an invalid end (not a number)
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I am at the New Range page
- And I fill the Beginning field with "42"
- And I fill the End field with "z"
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- When I press the Save button
- Then I should see "1 error prohibited this MezuroRange from being saved"
- And I should be at the New Range page
-
- @kalibro_configuration_restart
- Scenario: With an already taken beginning
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I have a sample range within the sample metric configuration with beginning "2"
- And I am at the New Range page
- And I fill the Beginning field with "2"
- And I fill the End field with "666"
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- When I press the Save button
- Then I should be at the New Range page
- And I should see "Beginning There is already a MezuroRange with beginning 2.0! Please, choose another one."
-
- @kalibro_configuration_restart @javascript
- Scenario: Should create range with [-INF, INF] threshold
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I am at the New Range page
- And I click the -∞ link
- And I click the ∞ link
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- When I press the Save button
- Then I should be at metric configuration sample page
- And I should see "-INF"
- And I should see "INF"
-
- @kalibro_configuration_restart @javascript
- Scenario: Two valid ranges (one with INF)
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I am at the New Range page
- And I fill the Beginning field with "2"
- And I fill the End field with "666"
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- And I press the Save button
- And I am at the New Range page
- And I fill the Beginning field with "666"
- And I click the ∞ link
- And I fill the Comments field with "My Comment"
- And I set the select field "Reading" as "My Reading"
- When I press the Save button
- Then I should be at metric configuration sample page
- And I should see "666"
- And I should see "INF"
\ No newline at end of file
diff --git a/features/mezuro_range/deletion.feature b/features/mezuro_range/deletion.feature
deleted file mode 100644
index 802083b..0000000
--- a/features/mezuro_range/deletion.feature
+++ /dev/null
@@ -1,30 +0,0 @@
-Feature: Range Deletion
- In order to be able to remove a range
- As a regular user
- The system should have an interface to it
-
- @kalibro_configuration_restart
- Scenario: Should delete a range that I own
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I have a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I have a sample range within the sample metric configuration
- And I am at the sample metric configuration page
- When I click the Destroy link
- Then I should be at metric configuration sample page
- And I should see "There are no Ranges yet!"
-
- @kalibro_configuration_restart
- Scenario: Should not see the destroy range link in the range that I not own
- Given I am a regular user
- And I am signed in
- And I have a sample configuration
- And I have a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I have a sample range within the sample metric configuration
- When I am at the sample metric configuration page
- Then I should not see "Destroy"
diff --git a/features/mezuro_range/edit.feature b/features/mezuro_range/edit.feature
deleted file mode 100644
index 71f6622..0000000
--- a/features/mezuro_range/edit.feature
+++ /dev/null
@@ -1,36 +0,0 @@
-Feature: Mezuro Range Edit
- In Order to be able to update my mezuro range info
- As a regular user
- I should be able to edit my mezuro ranges
-
- @kalibro_configuration_restart
- Scenario: editing a mezuro range successfully
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I have a sample range within the sample metric configuration with beginning "1.1"
- And I am at the Edit Mezuro Range page
- And the select field "Reading" is set as "My Reading"
- And the field "Beginning" should be filled with "1.1"
- And the field "End" should be filled with "5.1"
- And the field "Comments" should be filled with "Comment"
- When I fill the Beginning field with "2.2"
- And I press the Save button
- Then I should see "2.2"
-
- @kalibro_configuration_restart
- Scenario: editing a mezuro range with blank fields
- Given I am a regular user
- And I am signed in
- And I own a sample configuration
- And I own a sample reading group
- And I have a sample metric configuration within the given mezuro configuration
- And I have a sample reading within the sample reading group labeled "My Reading"
- And I have a sample range within the sample metric configuration with beginning "1"
- And I am at the Edit Mezuro Range page
- When I fill the Beginning field with " "
- And I press the Save button
- Then I should see "Beginning can't be blank"
diff --git a/features/step_definitions/compound_metric_configuration_steps.rb b/features/step_definitions/compound_metric_configuration_steps.rb
index 19ca154..a88db82 100644
--- a/features/step_definitions/compound_metric_configuration_steps.rb
+++ b/features/step_definitions/compound_metric_configuration_steps.rb
@@ -7,11 +7,11 @@ Given(/^I see the sample metric configuration code$/) do
end
Given(/^I have a sample compound metric configuration within the given mezuro configuration$/) do
- @compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {id: nil, configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id})
+ @compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id})
end
Given(/^I have another compound metric configuration with code "(.*?)" within the given mezuro configuration$/) do |code|
- @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {id: nil, configuration_id: @kalibro_configuration.id, code: code, reading_group_id: @reading_group.id})
+ @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, code: code, reading_group_id: @reading_group.id})
end
When(/^I visit the sample compound metric configuration edit page$/) do
diff --git a/features/step_definitions/kalibro_range_steps.rb b/features/step_definitions/kalibro_range_steps.rb
new file mode 100644
index 0000000..85b2fbd
--- /dev/null
+++ b/features/step_definitions/kalibro_range_steps.rb
@@ -0,0 +1,39 @@
+Given(/^I have a sample range within the sample metric configuration with beginning "(.*?)"$/) do |beginning|
+ @kalibro_range = FactoryGirl.create(:kalibro_range, {beginning: beginning, metric_configuration_id: @metric_configuration.id,
+ reading_id: @reading.id})
+end
+
+Given(/^I am at the Edit Kalibro Range page$/) do
+ visit edit_kalibro_configuration_metric_configuration_kalibro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id, @kalibro_range.id)
+end
+
+Given(/^the select field "(.*?)" is set as "(.*?)"$/) do |field, text|
+ select text, from: field
+end
+
+Given(/^I have a sample range within the sample metric configuration$/) do
+ @kalibro_range = FactoryGirl.create(:kalibro_range, {metric_configuration_id: @metric_configuration.id,
+ reading_id: @reading.id})
+end
+
+Given(/^I have a sample range within the sample compound metric configuration$/) do
+ @kalibro_range = FactoryGirl.create(:kalibro_range, {metric_configuration_id: @compound_metric_configuration.id,
+ reading_id: @reading.id})
+end
+
+When(/^I am at the New Range page$/) do
+ visit kalibro_configuration_metric_configuration_new_kalibro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id)
+end
+
+Then(/^I should be at the New Range page$/) do
+ expect(page).to have_content("New Range")
+ expect(page).to have_content("Beginning")
+ expect(page).to have_content("End")
+ expect(page).to have_content("Comments")
+end
+
+Then(/^I should see the sample range$/) do
+ expect(page).to have_content(@kalibro_range.label)
+ expect(page).to have_content(@kalibro_range.beginning)
+ expect(page).to have_content(@kalibro_range.end)
+end
diff --git a/features/step_definitions/mezuro_range_steps.rb b/features/step_definitions/mezuro_range_steps.rb
deleted file mode 100644
index f349e30..0000000
--- a/features/step_definitions/mezuro_range_steps.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-Given(/^I have a sample range within the sample metric configuration with beginning "(.*?)"$/) do |beginning|
- @mezuro_range = FactoryGirl.create(:mezuro_range, {beginning: beginning, metric_configuration_id: @metric_configuration.id,
- reading_id: @reading.id, id: nil})
-end
-
-Given(/^I am at the Edit Mezuro Range page$/) do
- visit edit_kalibro_configuration_metric_configuration_mezuro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id, @mezuro_range.id)
-end
-
-Given(/^the select field "(.*?)" is set as "(.*?)"$/) do |field, text|
- select text, from: field
-end
-
-Given(/^I have a sample range within the sample metric configuration$/) do
- @mezuro_range = FactoryGirl.create(:mezuro_range, {metric_configuration_id: @metric_configuration.id,
- reading_id: @reading.id, id: nil})
-end
-
-Given(/^I have a sample range within the sample compound metric configuration$/) do
- @mezuro_range = FactoryGirl.create(:mezuro_range, {metric_configuration_id: @compound_metric_configuration.id,
- reading_id: @reading.id, id: nil})
-end
-
-When(/^I am at the New Range page$/) do
- visit kalibro_configuration_metric_configuration_new_mezuro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id)
-end
-
-Then(/^I should be at the New Range page$/) do
- expect(page).to have_content("New Range")
- expect(page).to have_content("Beginning")
- expect(page).to have_content("End")
- expect(page).to have_content("Comments")
-end
-
-Then(/^I should see the sample range$/) do
- expect(page).to have_content(@mezuro_range.label)
- expect(page).to have_content(@mezuro_range.beginning)
- expect(page).to have_content(@mezuro_range.end)
-end
diff --git a/features/step_definitions/repository_steps.rb b/features/step_definitions/repository_steps.rb
index 47e7aff..af947e1 100644
--- a/features/step_definitions/repository_steps.rb
+++ b/features/step_definitions/repository_steps.rb
@@ -22,7 +22,7 @@ Given(/^I have a sample configuration with native metrics$/) do
reading_group_id: reading_group.id,
kalibro_configuration_id: @kalibro_configuration.id,
code: 'loc'})
- range = FactoryGirl.build(:mezuro_range, {id: nil, reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id})
+ range = FactoryGirl.build(:kalibro_range, {reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id})
range.save
end
diff --git a/spec/controllers/base_metric_configurations_controller_spec.rb b/spec/controllers/base_metric_configurations_controller_spec.rb
index 3ddf1cc..ca0c8e9 100644
--- a/spec/controllers/base_metric_configurations_controller_spec.rb
+++ b/spec/controllers/base_metric_configurations_controller_spec.rb
@@ -30,8 +30,8 @@ class InheritsFromBaseMetricConfigurationsController < BaseMetricConfigurationsC
@metric_configuration = new_metric_configuration
end
- def mezuro_ranges
- @mezuro_ranges
+ def kalibro_ranges
+ @kalibro_ranges
end
def reading_group
@@ -112,18 +112,18 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do
describe 'show' do
let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
let(:reading_group) { FactoryGirl.build(:reading_group_with_id) }
- let(:mezuro_range) { FactoryGirl.build(:mezuro_range) }
+ let(:kalibro_range) { FactoryGirl.build(:kalibro_range) }
context 'with a valid metric_configuration' do
before :each do
ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).returns(reading_group)
subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration)
- metric_configuration.expects(:kalibro_ranges).returns([mezuro_range])
+ metric_configuration.expects(:kalibro_ranges).returns([kalibro_range])
get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id
end
- it { expect(subject.mezuro_ranges).not_to be_nil}
+ it { expect(subject.kalibro_ranges).not_to be_nil}
it { expect(subject.reading_group).not_to be_nil }
end
diff --git a/spec/controllers/compound_metric_configurations_controller_spec.rb b/spec/controllers/compound_metric_configurations_controller_spec.rb
index ad1b84d..2af46c6 100644
--- a/spec/controllers/compound_metric_configurations_controller_spec.rb
+++ b/spec/controllers/compound_metric_configurations_controller_spec.rb
@@ -72,12 +72,12 @@ describe CompoundMetricConfigurationsController, :type => :controller do
describe 'show' do
let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) }
let(:reading_group) { FactoryGirl.build(:reading_group_with_id) }
- let(:mezuro_range) { FactoryGirl.build(:mezuro_range) }
+ let(:kalibro_range) { FactoryGirl.build(:kalibro_range) }
before :each do
ReadingGroup.expects(:find).with(compound_metric_configuration.reading_group_id).returns(reading_group)
subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration)
- compound_metric_configuration.expects(:kalibro_ranges).returns([mezuro_range])
+ compound_metric_configuration.expects(:kalibro_ranges).returns([kalibro_range])
get :show, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id.to_s, id: compound_metric_configuration.id
end
diff --git a/spec/controllers/kalibro_ranges_controller_spec.rb b/spec/controllers/kalibro_ranges_controller_spec.rb
new file mode 100644
index 0000000..0ad9f63
--- /dev/null
+++ b/spec/controllers/kalibro_ranges_controller_spec.rb
@@ -0,0 +1,206 @@
+require 'rails_helper'
+
+describe KalibroRangesController, :type => :controller do
+ let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id) }
+ let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
+
+ describe 'new' do
+ let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) }
+
+ before :each do
+ sign_in FactoryGirl.create(:user)
+ end
+
+ context 'when the current user owns the metric configuration' do
+ before :each do
+ subject.expects(:metric_configuration_owner?).returns true
+ MetricConfiguration.expects(:find).with(kalibro_range.metric_configuration_id).returns(metric_configuration)
+ Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([])
+ get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: kalibro_range.metric_configuration_id
+ end
+
+ it { is_expected.to respond_with(:success) }
+ it { is_expected.to render_template(:new) }
+ end
+
+ context "when the current user doesn't owns the metric configuration" do
+ before :each do
+ get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: kalibro_range.metric_configuration_id
+ end
+
+ it { is_expected.to redirect_to(kalibro_configurations_path(kalibro_configuration.id)) }
+ it { is_expected.to respond_with(:redirect) }
+ end
+ end
+
+ describe 'create' do
+ let(:kalibro_range_params) { kalibro_range.to_hash }
+ let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) }
+
+ before do
+ sign_in FactoryGirl.create(:user)
+ end
+
+ context 'when the current user owns the mezuro range' do
+ before :each do
+ subject.expects(:metric_configuration_owner?).returns true
+ end
+
+ context 'with valid fields' do
+ before :each do
+ KalibroRange.any_instance.expects(:save).returns(true)
+
+ post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params
+ end
+
+ it { is_expected.to respond_with(:redirect) }
+ end
+
+ context 'with invalid fields' do
+ before :each do
+ KalibroRange.any_instance.expects(:save).returns(false)
+ MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration)
+ Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([])
+
+ post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params
+ end
+
+ it { is_expected.to render_template(:new) }
+ end
+ end
+ end
+
+ describe 'destroy' do
+ context 'with an User logged in' do
+ before do
+ sign_in FactoryGirl.create(:user)
+ end
+
+ context 'when the user owns the metric configuration' do
+ before :each do
+ subject.expects(:metric_configuration_owner?).returns true
+ kalibro_range.expects(:destroy)
+ subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range)
+
+ delete :destroy, id: kalibro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s
+ end
+
+ it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) }
+ it { is_expected.to respond_with(:redirect) }
+ end
+
+ context "when the user doesn't own the metric configuration" do
+ before :each do
+ delete :destroy, id: kalibro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s
+ end
+
+ it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) }
+ it { is_expected.to respond_with(:redirect) }
+ end
+ end
+
+ context 'with no User logged in' do
+ before :each do
+ delete :destroy, id: kalibro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s
+ end
+
+ it { is_expected.to redirect_to new_user_session_path }
+ end
+ end
+
+ describe 'edit' do
+ let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
+ let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id, metric_configuration_id: metric_configuration.id) }
+ let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) }
+
+ context 'with an User logged in' do
+ before do
+ sign_in FactoryGirl.create(:user)
+ end
+
+ context 'when the user owns the mezuro range' do
+ before :each do
+ subject.expects(:metric_configuration_owner?).returns true
+ subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range)
+ MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration)
+ Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading])
+ get :edit, id: kalibro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id
+ end
+
+ it { is_expected.to render_template(:edit) }
+ end
+
+ context 'when the user does not own the mezuro range' do
+ let!(:reading_group) { FactoryGirl.build(:reading_group, id: metric_configuration.reading_group_id) }
+
+ before do
+ get :edit, id: kalibro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id
+ end
+
+ it { is_expected.to redirect_to(kalibro_configurations_url(metric_configuration.kalibro_configuration_id)) }
+ it { is_expected.to respond_with(:redirect) }
+ it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") }
+ end
+ end
+
+ context 'with no user logged in' do
+ before :each do
+ get :edit, id: kalibro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id
+ end
+
+ it { is_expected.to redirect_to new_user_session_path }
+ end
+ end
+
+ describe 'update' do
+ let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
+ let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id, metric_configuration_id: metric_configuration.id) }
+ let(:kalibro_range_params) { kalibro_range.to_hash }
+ let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) }
+
+ context 'when the user is logged in' do
+ before do
+ sign_in FactoryGirl.create(:user)
+ end
+
+ context 'when user owns the mezuro range' do
+ before :each do
+ subject.expects(:metric_configuration_owner?).returns true
+ end
+
+ context 'with valid fields' do
+ before :each do
+ subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range)
+ KalibroRange.any_instance.expects(:update).with(kalibro_range_params).returns(true)
+
+ post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: kalibro_range.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params
+ end
+
+ it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) }
+ it { is_expected.to respond_with(:redirect) }
+ end
+
+ context 'with an invalid field' do
+ before :each do
+ subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range)
+ KalibroRange.any_instance.expects(:update).with(kalibro_range_params).returns(false)
+ MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration)
+ Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading])
+
+ post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: kalibro_range.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params
+ end
+
+ it { is_expected.to render_template(:edit) }
+ end
+ end
+
+ context 'when the user does not own the mezuro range' do
+ before :each do
+ post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: kalibro_range.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params
+ end
+
+ it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.kalibro_configuration_id) }
+ end
+ end
+ end
+end
diff --git a/spec/controllers/metric_configurations_controller_spec.rb b/spec/controllers/metric_configurations_controller_spec.rb
index 14aa75c..3e3683a 100644
--- a/spec/controllers/metric_configurations_controller_spec.rb
+++ b/spec/controllers/metric_configurations_controller_spec.rb
@@ -93,12 +93,12 @@ describe MetricConfigurationsController, :type => :controller do
describe 'show' do
let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
let(:reading_group) { FactoryGirl.build(:reading_group_with_id) }
- let(:mezuro_range) { FactoryGirl.build(:mezuro_range) }
+ let(:kalibro_range) { FactoryGirl.build(:kalibro_range) }
before :each do
ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).returns(reading_group)
subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration)
- metric_configuration.expects(:kalibro_ranges).returns([mezuro_range])
+ metric_configuration.expects(:kalibro_ranges).returns([kalibro_range])
get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id
end
diff --git a/spec/controllers/mezuro_ranges_controller_spec.rb b/spec/controllers/mezuro_ranges_controller_spec.rb
deleted file mode 100644
index 6f6af95..0000000
--- a/spec/controllers/mezuro_ranges_controller_spec.rb
+++ /dev/null
@@ -1,206 +0,0 @@
-require 'rails_helper'
-
-describe MezuroRangesController, :type => :controller do
- let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1) }
- let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
-
- describe 'new' do
- let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) }
-
- before :each do
- sign_in FactoryGirl.create(:user)
- end
-
- context 'when the current user owns the metric configuration' do
- before :each do
- subject.expects(:metric_configuration_owner?).returns true
- MetricConfiguration.expects(:find).with(mezuro_range.metric_configuration_id).returns(metric_configuration)
- Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([])
- get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: mezuro_range.metric_configuration_id
- end
-
- it { is_expected.to respond_with(:success) }
- it { is_expected.to render_template(:new) }
- end
-
- context "when the current user doesn't owns the metric configuration" do
- before :each do
- get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: mezuro_range.metric_configuration_id
- end
-
- it { is_expected.to redirect_to(kalibro_configurations_path(kalibro_configuration.id)) }
- it { is_expected.to respond_with(:redirect) }
- end
- end
-
- describe 'create' do
- let(:mezuro_range_params) { Hash[FactoryGirl.attributes_for(:mezuro_range).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers
- let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) }
-
- before do
- sign_in FactoryGirl.create(:user)
- end
-
- context 'when the current user owns the mezuro range' do
- before :each do
- subject.expects(:metric_configuration_owner?).returns true
- end
-
- context 'with valid fields' do
- before :each do
- MezuroRange.any_instance.expects(:save).returns(true)
-
- post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params
- end
-
- it { is_expected.to respond_with(:redirect) }
- end
-
- context 'with invalid fields' do
- before :each do
- MezuroRange.any_instance.expects(:save).returns(false)
- MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration)
- Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([])
-
- post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params
- end
-
- it { is_expected.to render_template(:new) }
- end
- end
- end
-
- describe 'destroy' do
- context 'with an User logged in' do
- before do
- sign_in FactoryGirl.create(:user)
- end
-
- context 'when the user owns the metric configuration' do
- before :each do
- subject.expects(:metric_configuration_owner?).returns true
- mezuro_range.expects(:destroy)
- subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range)
-
- delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s
- end
-
- it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) }
- it { is_expected.to respond_with(:redirect) }
- end
-
- context "when the user doesn't own the metric configuration" do
- before :each do
- delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s
- end
-
- it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) }
- it { is_expected.to respond_with(:redirect) }
- end
- end
-
- context 'with no User logged in' do
- before :each do
- delete :destroy, id: mezuro_range.id.to_s, metric_configuration_id: metric_configuration.id.to_s, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s
- end
-
- it { is_expected.to redirect_to new_user_session_path }
- end
- end
-
- describe 'edit' do
- let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
- let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) }
- let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) }
-
- context 'with an User logged in' do
- before do
- sign_in FactoryGirl.create(:user)
- end
-
- context 'when the user owns the mezuro range' do
- before :each do
- subject.expects(:metric_configuration_owner?).returns true
- subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range)
- MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration)
- Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading])
- get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id
- end
-
- it { is_expected.to render_template(:edit) }
- end
-
- context 'when the user does not own the mezuro range' do
- let!(:reading_group) { FactoryGirl.build(:reading_group, id: metric_configuration.reading_group_id) }
-
- before do
- get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id
- end
-
- it { is_expected.to redirect_to(kalibro_configurations_url(metric_configuration.kalibro_configuration_id)) }
- it { is_expected.to respond_with(:redirect) }
- it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") }
- end
- end
-
- context 'with no user logged in' do
- before :each do
- get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id
- end
-
- it { is_expected.to redirect_to new_user_session_path }
- end
- end
-
- describe 'update' do
- let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
- let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) }
- let(:mezuro_range_params) { Hash[FactoryGirl.attributes_for(:mezuro_range).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers
- let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) }
-
- context 'when the user is logged in' do
- before do
- sign_in FactoryGirl.create(:user)
- end
-
- context 'when user owns the mezuro range' do
- before :each do
- subject.expects(:metric_configuration_owner?).returns true
- end
-
- context 'with valid fields' do
- before :each do
- subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range)
- MezuroRange.any_instance.expects(:update).with(mezuro_range_params).returns(true)
-
- post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params
- end
-
- it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) }
- it { is_expected.to respond_with(:redirect) }
- end
-
- context 'with an invalid field' do
- before :each do
- subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range)
- MezuroRange.any_instance.expects(:update).with(mezuro_range_params).returns(false)
- MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration)
- Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading])
-
- post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params
- end
-
- it { is_expected.to render_template(:edit) }
- end
- end
-
- context 'when the user does not own the mezuro range' do
- before :each do
- post :update, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, id: mezuro_range.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params
- end
-
- it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.kalibro_configuration_id) }
- end
- end
- end
-end
diff --git a/spec/factories/kalibro_ranges.rb b/spec/factories/kalibro_ranges.rb
new file mode 100644
index 0000000..ef1b5d7
--- /dev/null
+++ b/spec/factories/kalibro_ranges.rb
@@ -0,0 +1,36 @@
+# This file is part of KalibroEntities
+# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+FactoryGirl.define do
+ factory :kalibro_range do
+ beginning 1.1
+ self.end 5.1
+ reading_id 3
+ comments "Comment"
+ metric_configuration_id 32
+
+ trait :another_comment do
+ comments "Another Comment"
+ end
+
+ trait :with_id do
+ id 1
+ end
+
+ factory :kalibro_range_with_id, traits: [:with_id]
+ factory :another_kalibro_range, traits: [:another_comment]
+ end
+end
\ No newline at end of file
diff --git a/spec/factories/mezuro_ranges.rb b/spec/factories/mezuro_ranges.rb
deleted file mode 100644
index d175b1c..0000000
--- a/spec/factories/mezuro_ranges.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is part of KalibroEntities
-# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-FactoryGirl.define do
- factory :mezuro_range do
- beginning 1.1
- self.end 5.1
- reading_id 3
- comments "Comment"
- metric_configuration_id 32
-
- trait :another_comment do
- comments "Another Comment"
- end
-
- factory :another_mezuro_range, traits: [:another_comment]
- end
-end
\ No newline at end of file
diff --git a/spec/helpers/kalibro_ranges_helper_spec.rb b/spec/helpers/kalibro_ranges_helper_spec.rb
new file mode 100644
index 0000000..96037a4
--- /dev/null
+++ b/spec/helpers/kalibro_ranges_helper_spec.rb
@@ -0,0 +1,11 @@
+require 'rails_helper'
+
+describe KalibroRangesHelper, :type => :helper do
+ describe 'readings_options' do
+ let(:reading) { FactoryGirl.build(:reading_with_id) }
+ it 'should return a pair with the reading label and id' do
+ expect(helper.readings_options([reading])).to eq [[reading.label, reading.id]]
+ end
+ end
+end
+
diff --git a/spec/helpers/mezuro_ranges_helper_spec.rb b/spec/helpers/mezuro_ranges_helper_spec.rb
deleted file mode 100644
index 323c7ba..0000000
--- a/spec/helpers/mezuro_ranges_helper_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'rails_helper'
-
-describe MezuroRangesHelper, :type => :helper do
- describe 'readings_options' do
- let(:reading) { FactoryGirl.build(:reading_with_id) }
- it 'should return a pair with the reading label and id' do
- expect(helper.readings_options([reading])).to eq [[reading.label, reading.id]]
- end
- end
-end
-
diff --git a/spec/routing/kalibro_ranges_routing_spec.rb b/spec/routing/kalibro_ranges_routing_spec.rb
new file mode 100644
index 0000000..e2b23bc
--- /dev/null
+++ b/spec/routing/kalibro_ranges_routing_spec.rb
@@ -0,0 +1,20 @@
+require "rails_helper"
+
+describe KalibroRangesController, :type => :routing do
+ describe "routing" do
+ it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges').
+ to(controller: :kalibro_ranges, action: :index, kalibro_configuration_id: "1", metric_configuration_id: "1") }
+ it { is_expected.to route(:post, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges').
+ to(controller: :kalibro_ranges, action: :create, kalibro_configuration_id: "1", metric_configuration_id: "1") }
+ it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1/edit').
+ to(controller: :kalibro_ranges, action: :edit, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
+ it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1').
+ to(controller: :kalibro_ranges, action: :show, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
+ it { is_expected.to route(:delete, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1').
+ to(controller: :kalibro_ranges, action: :destroy, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
+ it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/new').
+ to(controller: :kalibro_ranges, action: :new, kalibro_configuration_id: "1", metric_configuration_id: "1") }
+ it { is_expected.to route(:put, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1').
+ to(controller: :kalibro_ranges, action: :update, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
+ end
+end
diff --git a/spec/routing/mezuro_ranges_routing_spec.rb b/spec/routing/mezuro_ranges_routing_spec.rb
deleted file mode 100644
index 8a8a93f..0000000
--- a/spec/routing/mezuro_ranges_routing_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require "rails_helper"
-
-describe MezuroRangesController, :type => :routing do
- describe "routing" do
- it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges').
- to(controller: :mezuro_ranges, action: :index, kalibro_configuration_id: "1", metric_configuration_id: "1") }
- it { is_expected.to route(:post, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges').
- to(controller: :mezuro_ranges, action: :create, kalibro_configuration_id: "1", metric_configuration_id: "1") }
- it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1/edit').
- to(controller: :mezuro_ranges, action: :edit, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
- it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1').
- to(controller: :mezuro_ranges, action: :show, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
- it { is_expected.to route(:delete, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1').
- to(controller: :mezuro_ranges, action: :destroy, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
- it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/new').
- to(controller: :mezuro_ranges, action: :new, kalibro_configuration_id: "1", metric_configuration_id: "1") }
- it { is_expected.to route(:put, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1').
- to(controller: :mezuro_ranges, action: :update, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") }
- end
-end
--
libgit2 0.21.2