Commit f253a4f1ebf889de9b11e7bdd070a022a549048a
Committed by
Rafael Manzo
1 parent
e9c638e9
Exists in
colab
and in
4 other branches
Renamed MezuroRanges to KalibroRanges
Showing
40 changed files
with
788 additions
and
783 deletions
Show diff stats
app/controllers/base_metric_configurations_controller.rb
| ... | ... | @@ -15,7 +15,7 @@ class BaseMetricConfigurationsController < ApplicationController |
| 15 | 15 | def show |
| 16 | 16 | if metric_configuration |
| 17 | 17 | @reading_group = ReadingGroup.find(metric_configuration.reading_group_id) |
| 18 | - @mezuro_ranges = metric_configuration.kalibro_ranges | |
| 18 | + @kalibro_ranges = metric_configuration.kalibro_ranges | |
| 19 | 19 | else |
| 20 | 20 | raise NotImplementedError |
| 21 | 21 | end | ... | ... |
| ... | ... | @@ -0,0 +1,90 @@ |
| 1 | +include OwnershipAuthentication | |
| 2 | +include ResourceFinder | |
| 3 | + | |
| 4 | +class KalibroRangesController < ApplicationController | |
| 5 | + before_action :authenticate_user!, except: [:show] | |
| 6 | + before_action :metric_configuration_owner?, only: [:new, :create, :destroy, :edit, :update] | |
| 7 | + before_action :get_url_params, only: [:update, :create, :destroy] | |
| 8 | + before_action :set_kalibro_range, only: [:edit, :update, :destroy] | |
| 9 | + | |
| 10 | + def new | |
| 11 | + @kalibro_range = KalibroRange.new | |
| 12 | + before_form | |
| 13 | + end | |
| 14 | + | |
| 15 | + def create | |
| 16 | + @kalibro_range = KalibroRange.new(kalibro_range_params) | |
| 17 | + @kalibro_range.metric_configuration_id = params[:metric_configuration_id].to_i | |
| 18 | + respond_to do |format| | |
| 19 | + create_and_redir(format) | |
| 20 | + end | |
| 21 | + end | |
| 22 | + | |
| 23 | + def destroy | |
| 24 | + @kalibro_range.destroy | |
| 25 | + respond_to do |format| | |
| 26 | + format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
| 27 | + @kalibro_configuration_id, @metric_configuration_id) } | |
| 28 | + format.json { head :no_content } | |
| 29 | + end | |
| 30 | + end | |
| 31 | + | |
| 32 | + def edit | |
| 33 | + before_form | |
| 34 | + end | |
| 35 | + | |
| 36 | + def update | |
| 37 | + respond_to do |format| | |
| 38 | + @kalibro_range.metric_configuration_id = @metric_configuration_id | |
| 39 | + if @kalibro_range.update(kalibro_range_params) | |
| 40 | + format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
| 41 | + @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully edited.' } | |
| 42 | + format.json { head :no_content } | |
| 43 | + else | |
| 44 | + failed_action(format, 'edit') | |
| 45 | + end | |
| 46 | + end | |
| 47 | + end | |
| 48 | + | |
| 49 | + private | |
| 50 | + | |
| 51 | + def kalibro_range_params | |
| 52 | + 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 | |
| 53 | + params[:kalibro_range] | |
| 54 | + end | |
| 55 | + | |
| 56 | + def create_and_redir(format) | |
| 57 | + if @kalibro_range.save | |
| 58 | + format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
| 59 | + @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully created.' } | |
| 60 | + else | |
| 61 | + failed_action(format, 'new') | |
| 62 | + end | |
| 63 | + end | |
| 64 | + | |
| 65 | + def failed_action(format, destiny_action) | |
| 66 | + before_form | |
| 67 | + format.html { render action: destiny_action } | |
| 68 | + format.json { render json: @kalibro_range.errors, status: :unprocessable_entity } | |
| 69 | + end | |
| 70 | + | |
| 71 | + def before_form | |
| 72 | + get_url_params | |
| 73 | + @reading_group_id = MetricConfiguration.find(@metric_configuration_id).reading_group_id | |
| 74 | + @readings = Reading.readings_of(@reading_group_id) | |
| 75 | + end | |
| 76 | + | |
| 77 | + def get_url_params | |
| 78 | + @kalibro_configuration_id = params[:kalibro_configuration_id].to_i | |
| 79 | + @metric_configuration_id = params[:metric_configuration_id].to_i | |
| 80 | + end | |
| 81 | + | |
| 82 | + # used on kalibro_range_params | |
| 83 | + def numeric?(text) | |
| 84 | + Float(text) != nil rescue false | |
| 85 | + end | |
| 86 | + | |
| 87 | + def set_kalibro_range | |
| 88 | + @kalibro_range = find_resource(KalibroRange, params[:id].to_i) | |
| 89 | + end | |
| 90 | +end | ... | ... |
app/controllers/mezuro_ranges_controller.rb
| ... | ... | @@ -1,90 +0,0 @@ |
| 1 | -include OwnershipAuthentication | |
| 2 | -include ResourceFinder | |
| 3 | - | |
| 4 | -class MezuroRangesController < ApplicationController | |
| 5 | - before_action :authenticate_user!, except: [:show] | |
| 6 | - before_action :metric_configuration_owner?, only: [:new, :create, :destroy, :edit, :update] | |
| 7 | - before_action :get_url_params, only: [:update, :create, :destroy] | |
| 8 | - before_action :set_mezuro_range, only: [:edit, :update, :destroy] | |
| 9 | - | |
| 10 | - def new | |
| 11 | - @mezuro_range = MezuroRange.new | |
| 12 | - before_form | |
| 13 | - end | |
| 14 | - | |
| 15 | - def create | |
| 16 | - @mezuro_range = MezuroRange.new(mezuro_range_params) | |
| 17 | - @mezuro_range.metric_configuration_id = params[:metric_configuration_id].to_i | |
| 18 | - respond_to do |format| | |
| 19 | - create_and_redir(format) | |
| 20 | - end | |
| 21 | - end | |
| 22 | - | |
| 23 | - def destroy | |
| 24 | - @mezuro_range.destroy | |
| 25 | - respond_to do |format| | |
| 26 | - format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
| 27 | - @kalibro_configuration_id, @metric_configuration_id) } | |
| 28 | - format.json { head :no_content } | |
| 29 | - end | |
| 30 | - end | |
| 31 | - | |
| 32 | - def edit | |
| 33 | - before_form | |
| 34 | - end | |
| 35 | - | |
| 36 | - def update | |
| 37 | - respond_to do |format| | |
| 38 | - @mezuro_range.metric_configuration_id = @metric_configuration_id | |
| 39 | - if @mezuro_range.update(mezuro_range_params) | |
| 40 | - format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
| 41 | - @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully edited.' } | |
| 42 | - format.json { head :no_content } | |
| 43 | - else | |
| 44 | - failed_action(format, 'edit') | |
| 45 | - end | |
| 46 | - end | |
| 47 | - end | |
| 48 | - | |
| 49 | - private | |
| 50 | - | |
| 51 | - def mezuro_range_params | |
| 52 | - 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 | |
| 53 | - params[:mezuro_range] | |
| 54 | - end | |
| 55 | - | |
| 56 | - def create_and_redir(format) | |
| 57 | - if @mezuro_range.save | |
| 58 | - format.html { redirect_to kalibro_configuration_metric_configuration_path( | |
| 59 | - @kalibro_configuration_id, @metric_configuration_id), notice: 'Range was successfully created.' } | |
| 60 | - else | |
| 61 | - failed_action(format, 'new') | |
| 62 | - end | |
| 63 | - end | |
| 64 | - | |
| 65 | - def failed_action(format, destiny_action) | |
| 66 | - before_form | |
| 67 | - format.html { render action: destiny_action } | |
| 68 | - format.json { render json: @mezuro_range.errors, status: :unprocessable_entity } | |
| 69 | - end | |
| 70 | - | |
| 71 | - def before_form | |
| 72 | - get_url_params | |
| 73 | - @reading_group_id = MetricConfiguration.find(@metric_configuration_id).reading_group_id | |
| 74 | - @readings = Reading.readings_of(@reading_group_id) | |
| 75 | - end | |
| 76 | - | |
| 77 | - def get_url_params | |
| 78 | - @kalibro_configuration_id = params[:kalibro_configuration_id].to_i | |
| 79 | - @metric_configuration_id = params[:metric_configuration_id].to_i | |
| 80 | - end | |
| 81 | - | |
| 82 | - # used on mezuro_range_params | |
| 83 | - def numeric?(text) | |
| 84 | - Float(text) != nil rescue false | |
| 85 | - end | |
| 86 | - | |
| 87 | - def set_mezuro_range | |
| 88 | - @mezuro_range = find_resource(MezuroRange, params[:id].to_i) | |
| 89 | - end | |
| 90 | -end |
app/helpers/mezuro_ranges_helper.rb
app/models/mezuro_range.rb
app/views/compound_metric_configurations/show.html.erb
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | |
| 46 | 46 | <h2> Ranges </h2> |
| 47 | 47 | <% if kalibro_configuration_owner? @compound_metric_configuration.configuration_id %> |
| 48 | - <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_mezuro_range_path(@compound_metric_configuration.configuration_id, | |
| 48 | + <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_kalibro_range_path(@compound_metric_configuration.configuration_id, | |
| 49 | 49 | @compound_metric_configuration.id), class: 'btn btn-info' %> |
| 50 | 50 | <% end %> |
| 51 | 51 | |
| ... | ... | @@ -58,10 +58,10 @@ |
| 58 | 58 | </tr> |
| 59 | 59 | </thead> |
| 60 | 60 | <tbody> |
| 61 | - <% if @mezuro_ranges.empty? %> | |
| 61 | + <% if @kalibro_ranges.empty? %> | |
| 62 | 62 | <%= render partial: 'metric_configurations/no_ranges' %> |
| 63 | 63 | <% else %> |
| 64 | - <%= render partial: 'metric_configurations/ranges', collection: @mezuro_ranges, as: :mezuro_range %> | |
| 64 | + <%= render partial: 'metric_configurations/ranges', collection: @kalibro_ranges, as: :kalibro_range %> | |
| 65 | 65 | <% end %> |
| 66 | 66 | </tbody> |
| 67 | 67 | </table> | ... | ... |
| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | + <%= render :partial => 'shared/form_errors', :locals => {:object => @kalibro_range} %> | |
| 2 | + | |
| 3 | + <div class="row margin-left-none"> | |
| 4 | + <div class="form-table col-md-9"> | |
| 5 | + | |
| 6 | + <div class="form-row"> | |
| 7 | + <% if @readings.size == 0 %> | |
| 8 | + <%= render partial: 'no_readings' %> | |
| 9 | + <% else %> | |
| 10 | + <div class="field-container"> | |
| 11 | + <%= f.label :reading_id, 'Reading', class: 'control-label' %> | |
| 12 | + <%= f.select( :reading_id, readings_options(@readings), {class: 'form-control'} ) %> | |
| 13 | + </div> | |
| 14 | + <div class="help-container"> | |
| 15 | + <p> | |
| 16 | + The <%= link_to 'Reading', tutorials_path('keywords', anchor: 'reading')%> associated with this <%= link_to 'Range', tutorials_path('keywords', anchor: 'range')%>. | |
| 17 | + </p> | |
| 18 | + </div> | |
| 19 | + <% end %> | |
| 20 | + </div> | |
| 21 | + | |
| 22 | + <div class="form-row"> | |
| 23 | + <div class="field-container" > | |
| 24 | + <%= f.label :beginning, class: 'control-label' %> | |
| 25 | + <div class="input-group"> | |
| 26 | + <%= f.text_field :beginning, :required => true, class: 'diminished-text-field form-control' %> | |
| 27 | + <span class="input-group-btn"> | |
| 28 | + <%= link_to '-∞'.html_safe, 'javascript:void(0)', :onClick => "jQuery( '#kalibro_range_beginning' ).val('-INF');", class: 'btn btn-default' %> | |
| 29 | + </span> | |
| 30 | + </div> | |
| 31 | + </div> | |
| 32 | + | |
| 33 | + <div class="help-container"> | |
| 34 | + <p> | |
| 35 | + This Range's lower limit. | |
| 36 | + </p> | |
| 37 | + </div> | |
| 38 | + </div> | |
| 39 | + | |
| 40 | + <div class="form-row"> | |
| 41 | + <div class="field-container"> | |
| 42 | + <%= f.label :end, class: 'control-label' %> | |
| 43 | + <div class="input-group"> | |
| 44 | + <%= f.text_field :end, :required => true, class: 'diminished-text-field form-control' %> | |
| 45 | + <span class="input-group-btn"> | |
| 46 | + <%= link_to '∞'.html_safe, 'javascript:void(0)', :onClick => "jQuery( '#kalibro_range_end' ).val('INF');", class: 'btn btn-default align-button' %> | |
| 47 | + </span> | |
| 48 | + </div> | |
| 49 | + </div> | |
| 50 | + <div class="help-container"> | |
| 51 | + <p> | |
| 52 | + This Range's upper limit. | |
| 53 | + </p> | |
| 54 | + </div> | |
| 55 | + </div> | |
| 56 | + | |
| 57 | + <div class="form-row"> | |
| 58 | + <div class="field-container"> | |
| 59 | + <%= f.label :comments, class: 'control-label' %> | |
| 60 | + <%= f.text_area :comments, class: 'text-area form-control' %> | |
| 61 | + </div> | |
| 62 | + <div class="help-container"> | |
| 63 | + <p> | |
| 64 | + An explanation of why you chose this interval, with that reading for this <%= link_to 'Metric', tutorials_path('keywords', anchor: 'metric')%>. | |
| 65 | + </p> | |
| 66 | + </div> | |
| 67 | + </div> | |
| 68 | + </div> | |
| 69 | + </div> | |
| 70 | + | |
| 71 | + <div class="row margin-left-none" style="margin-top: 20px"> | |
| 72 | + <%= f.submit 'Save', class: 'btn btn-primary' %> | |
| 73 | + <%= link_to 'Back', kalibro_configuration_metric_configuration_path(@kalibro_configuration_id, @metric_configuration_id), class: 'btn btn-default' %> | |
| 74 | + </div> | ... | ... |
| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | +<div class="alert alert-error alert-dismissable"> | |
| 2 | + <h4 class="alert-heading">You must have Readings within your associated Reading Group to create a new Range.</h4> | |
| 3 | + <p> | |
| 4 | + <% if reading_groups_owner? @reading_group_id %> | |
| 5 | + <br /><%= link_to 'Create New Reading', new_reading_group_reading_path(@reading_group_id), class: 'btn btn-danger' %> | |
| 6 | + <% else %> | |
| 7 | + <p> The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it.</p> | |
| 8 | + <% end %> | |
| 9 | + </p> | |
| 10 | +</div> | ... | ... |
| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | +<h1>Edit Range</h1> | |
| 2 | + | |
| 3 | +<%= form_for(@kalibro_range, :url => kalibro_configuration_metric_configuration_kalibro_range_update_url( | |
| 4 | + @kalibro_configuration_id, @metric_configuration_id, @kalibro_range.id), method: :put) do |f| %> | |
| 5 | + <%= render partial: 'form', locals: {f: f} %> | |
| 6 | +<% end %> | |
| 0 | 7 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | +<h1>New Range</h1> | |
| 2 | + | |
| 3 | +<%= form_for(@kalibro_range, :url => kalibro_configuration_metric_configuration_kalibro_ranges_path( | |
| 4 | + @kalibro_configuration_id, @metric_configuration_id)) do |f| %> | |
| 5 | + <%= render partial: 'form', locals: {f: f} %> | |
| 6 | +<% end %> | |
| 0 | 7 | \ No newline at end of file | ... | ... |
app/views/metric_configurations/_ranges.html.erb
| 1 | 1 | <tr> |
| 2 | 2 | <td> |
| 3 | 3 | <div> |
| 4 | - <a class="popover_element" rel="popover" data-placement="left" data-original-title="Comments" data-content="<%= mezuro_range.comments %>"><span id="comment-icon" class="fa fa-comment"></span></a> | |
| 5 | - <span style="color: #<%= mezuro_range.color %>"><%= mezuro_range.label %></span> | |
| 4 | + <a class="popover_element" rel="popover" data-placement="left" data-original-title="Comments" data-content="<%= kalibro_range.comments %>"><span id="comment-icon" class="fa fa-comment"></span></a> | |
| 5 | + <span style="color: #<%= kalibro_range.color %>"><%= kalibro_range.label %></span> | |
| 6 | 6 | </div> |
| 7 | 7 | </td> |
| 8 | - <td><%= mezuro_range.beginning %></td> | |
| 9 | - <td><%= mezuro_range.end %></td> | |
| 8 | + <td><%= kalibro_range.beginning %></td> | |
| 9 | + <td><%= kalibro_range.end %></td> | |
| 10 | 10 | <td> |
| 11 | 11 | <% if kalibro_configuration_owner? @metric_configuration.configuration_id %> |
| 12 | - <%= link_to 'Edit', edit_kalibro_configuration_metric_configuration_mezuro_range_path( | |
| 13 | - @metric_configuration.configuration_id, @metric_configuration.id, mezuro_range.id), class: 'btn btn-info' %> | |
| 14 | - <%= link_to 'Destroy', kalibro_configuration_metric_configuration_mezuro_range_path(@metric_configuration.configuration_id, | |
| 15 | - @metric_configuration.id, mezuro_range.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Range?' }, | |
| 12 | + <%= link_to 'Edit', edit_kalibro_configuration_metric_configuration_kalibro_range_path( | |
| 13 | + @metric_configuration.configuration_id, @metric_configuration.id, kalibro_range.id), class: 'btn btn-info' %> | |
| 14 | + <%= link_to 'Destroy', kalibro_configuration_metric_configuration_kalibro_range_path(@metric_configuration.configuration_id, | |
| 15 | + @metric_configuration.id, kalibro_range.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Range?' }, | |
| 16 | 16 | class: 'btn btn-danger' %> |
| 17 | 17 | <% end %> |
| 18 | 18 | </td> | ... | ... |
app/views/metric_configurations/show.html.erb
| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | <% if @metric_configuration.metric.description.nil? %> |
| 43 | 43 | <%= "There is no description available." %> |
| 44 | 44 | <% else %> |
| 45 | - <%= @metric_configuration.metric.description %> | |
| 45 | + <%= @metric_configuration.metric.description %> | |
| 46 | 46 | <% end %> |
| 47 | 47 | |
| 48 | 48 | </p> |
| ... | ... | @@ -50,7 +50,7 @@ |
| 50 | 50 | |
| 51 | 51 | <h2> Ranges </h2> |
| 52 | 52 | <% if kalibro_configuration_owner? @metric_configuration.configuration_id %> |
| 53 | - <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_mezuro_range_path(@metric_configuration.configuration_id, | |
| 53 | + <%= link_to 'Add Range', kalibro_configuration_metric_configuration_new_kalibro_range_path(@metric_configuration.configuration_id, | |
| 54 | 54 | @metric_configuration.id), class: 'btn btn-info' %> |
| 55 | 55 | <% end %> |
| 56 | 56 | |
| ... | ... | @@ -63,10 +63,10 @@ |
| 63 | 63 | </tr> |
| 64 | 64 | </thead> |
| 65 | 65 | <tbody> |
| 66 | - <% if @mezuro_ranges.empty? %> | |
| 66 | + <% if @kalibro_ranges.empty? %> | |
| 67 | 67 | <%= render partial: 'no_ranges' %> |
| 68 | 68 | <% else %> |
| 69 | - <%= render partial: 'ranges', collection: @mezuro_ranges, as: :mezuro_range %> | |
| 69 | + <%= render partial: 'ranges', collection: @kalibro_ranges, as: :kalibro_range %> | |
| 70 | 70 | <% end %> |
| 71 | 71 | </tbody> |
| 72 | 72 | </table> |
| ... | ... | @@ -75,7 +75,7 @@ |
| 75 | 75 | <%= link_to 'Back', kalibro_configuration_path(@metric_configuration.configuration_id), class: 'btn btn-default' %> |
| 76 | 76 | <% if kalibro_configuration_owner? @metric_configuration.configuration_id %> |
| 77 | 77 | <%= link_to 'Destroy Metric Configuration', kalibro_configuration_metric_configuration_path(@metric_configuration.configuration_id, |
| 78 | - @metric_configuration.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Metric Configuration?' }, | |
| 78 | + @metric_configuration.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this Metric Configuration?' }, | |
| 79 | 79 | class: 'btn btn-danger' %> |
| 80 | 80 | <% end %> |
| 81 | 81 | </p> | ... | ... |
app/views/mezuro_ranges/_form.html.erb
| ... | ... | @@ -1,74 +0,0 @@ |
| 1 | - <%= render :partial => 'shared/form_errors', :locals => {:object => @mezuro_range} %> | |
| 2 | - | |
| 3 | - <div class="row margin-left-none"> | |
| 4 | - <div class="form-table col-md-9"> | |
| 5 | - | |
| 6 | - <div class="form-row"> | |
| 7 | - <% if @readings.size == 0 %> | |
| 8 | - <%= render partial: 'no_readings' %> | |
| 9 | - <% else %> | |
| 10 | - <div class="field-container"> | |
| 11 | - <%= f.label :reading_id, 'Reading', class: 'control-label' %> | |
| 12 | - <%= f.select( :reading_id, readings_options(@readings), {class: 'form-control'} ) %> | |
| 13 | - </div> | |
| 14 | - <div class="help-container"> | |
| 15 | - <p> | |
| 16 | - The <%= link_to 'Reading', tutorials_path('keywords', anchor: 'reading')%> associated with this <%= link_to 'Range', tutorials_path('keywords', anchor: 'range')%>. | |
| 17 | - </p> | |
| 18 | - </div> | |
| 19 | - <% end %> | |
| 20 | - </div> | |
| 21 | - | |
| 22 | - <div class="form-row"> | |
| 23 | - <div class="field-container" > | |
| 24 | - <%= f.label :beginning, class: 'control-label' %> | |
| 25 | - <div class="input-group"> | |
| 26 | - <%= f.text_field :beginning, :required => true, class: 'diminished-text-field form-control' %> | |
| 27 | - <span class="input-group-btn"> | |
| 28 | - <%= link_to '-∞'.html_safe, 'javascript:void(0)', :onClick => "jQuery( '#mezuro_range_beginning' ).val('-INF');", class: 'btn btn-default' %> | |
| 29 | - </span> | |
| 30 | - </div> | |
| 31 | - </div> | |
| 32 | - | |
| 33 | - <div class="help-container"> | |
| 34 | - <p> | |
| 35 | - This Range's lower limit. | |
| 36 | - </p> | |
| 37 | - </div> | |
| 38 | - </div> | |
| 39 | - | |
| 40 | - <div class="form-row"> | |
| 41 | - <div class="field-container"> | |
| 42 | - <%= f.label :end, class: 'control-label' %> | |
| 43 | - <div class="input-group"> | |
| 44 | - <%= f.text_field :end, :required => true, class: 'diminished-text-field form-control' %> | |
| 45 | - <span class="input-group-btn"> | |
| 46 | - <%= link_to '∞'.html_safe, 'javascript:void(0)', :onClick => "jQuery( '#mezuro_range_end' ).val('INF');", class: 'btn btn-default align-button' %> | |
| 47 | - </span> | |
| 48 | - </div> | |
| 49 | - </div> | |
| 50 | - <div class="help-container"> | |
| 51 | - <p> | |
| 52 | - This Range's upper limit. | |
| 53 | - </p> | |
| 54 | - </div> | |
| 55 | - </div> | |
| 56 | - | |
| 57 | - <div class="form-row"> | |
| 58 | - <div class="field-container"> | |
| 59 | - <%= f.label :comments, class: 'control-label' %> | |
| 60 | - <%= f.text_area :comments, class: 'text-area form-control' %> | |
| 61 | - </div> | |
| 62 | - <div class="help-container"> | |
| 63 | - <p> | |
| 64 | - An explanation of why you chose this interval, with that reading for this <%= link_to 'Metric', tutorials_path('keywords', anchor: 'metric')%>. | |
| 65 | - </p> | |
| 66 | - </div> | |
| 67 | - </div> | |
| 68 | - </div> | |
| 69 | - </div> | |
| 70 | - | |
| 71 | - <div class="row margin-left-none" style="margin-top: 20px"> | |
| 72 | - <%= f.submit 'Save', class: 'btn btn-primary' %> | |
| 73 | - <%= link_to 'Back', kalibro_configuration_metric_configuration_path(@kalibro_configuration_id, @metric_configuration_id), class: 'btn btn-default' %> | |
| 74 | - </div> |
app/views/mezuro_ranges/_no_readings.html.erb
| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | -<div class="alert alert-error alert-dismissable"> | |
| 2 | - <h4 class="alert-heading">You must have Readings within your associated Reading Group to create a new Range.</h4> | |
| 3 | - <p> | |
| 4 | - <% if reading_groups_owner? @reading_group_id %> | |
| 5 | - <br /><%= link_to 'Create New Reading', new_reading_group_reading_path(@reading_group_id), class: 'btn btn-danger' %> | |
| 6 | - <% else %> | |
| 7 | - <p> The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it.</p> | |
| 8 | - <% end %> | |
| 9 | - </p> | |
| 10 | -</div> |
app/views/mezuro_ranges/edit.html.erb
| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | -<h1>Edit Range</h1> | |
| 2 | - | |
| 3 | -<%= form_for(@mezuro_range, :url => kalibro_configuration_metric_configuration_mezuro_range_update_url( | |
| 4 | - @kalibro_configuration_id, @metric_configuration_id, @mezuro_range.id), method: :put) do |f| %> | |
| 5 | - <%= render partial: 'form', locals: {f: f} %> | |
| 6 | -<% end %> | |
| 7 | 0 | \ No newline at end of file |
app/views/mezuro_ranges/new.html.erb
| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | -<h1>New Range</h1> | |
| 2 | - | |
| 3 | -<%= form_for(@mezuro_range, :url => kalibro_configuration_metric_configuration_mezuro_ranges_path( | |
| 4 | - @kalibro_configuration_id, @metric_configuration_id)) do |f| %> | |
| 5 | - <%= render partial: 'form', locals: {f: f} %> | |
| 6 | -<% end %> | |
| 7 | 0 | \ No newline at end of file |
config/routes.rb
| ... | ... | @@ -13,9 +13,9 @@ Rails.application.routes.draw do |
| 13 | 13 | resources :kalibro_configurations do |
| 14 | 14 | get '/metric_configurations/choose_metric' => 'metric_configurations#choose_metric', as: :choose_metric |
| 15 | 15 | resources :metric_configurations, except: [:update, :new] do |
| 16 | - get '/mezuro_ranges/new' => 'mezuro_ranges#new', as: :new_mezuro_range | |
| 17 | - resources :mezuro_ranges, except: [:update, :new] | |
| 18 | - put '/mezuro_ranges/:id' => 'mezuro_ranges#update', as: :mezuro_range_update | |
| 16 | + get '/kalibro_ranges/new' => 'kalibro_ranges#new', as: :new_kalibro_range | |
| 17 | + resources :kalibro_ranges, except: [:update, :new] | |
| 18 | + put '/kalibro_ranges/:id' => 'kalibro_ranges#update', as: :kalibro_range_update | |
| 19 | 19 | end |
| 20 | 20 | post '/metric_configurations/new' => 'metric_configurations#new', as: :new_metric_configuration |
| 21 | 21 | put '/metric_configurations/:id' => 'metric_configurations#update', as: :metric_configuration_update | ... | ... |
| ... | ... | @@ -0,0 +1,185 @@ |
| 1 | +Feature: Create range | |
| 2 | + In order to be able to create new ranges | |
| 3 | + As a metric specialist | |
| 4 | + I should be able to fill up a form with its informations and submit it | |
| 5 | + | |
| 6 | + @kalibro_configuration_restart | |
| 7 | + Scenario: Visiting range creation page when the user own an non-empty reading group | |
| 8 | + Given I am a regular user | |
| 9 | + And I am signed in | |
| 10 | + And I own a sample configuration | |
| 11 | + And I own a sample reading group | |
| 12 | + And I have a sample metric configuration within the given mezuro configuration | |
| 13 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 14 | + And I am at the sample metric configuration page | |
| 15 | + When I click the Add Range link | |
| 16 | + Then I should be at the New Range page | |
| 17 | + And I should see "Beginning" | |
| 18 | + And I should see "End" | |
| 19 | + And I should see "Comments" | |
| 20 | + And I should see "Reading" | |
| 21 | + | |
| 22 | + @kalibro_configuration_restart | |
| 23 | + Scenario: Visiting range creation page when the user don't own the reading group and this reading group is empty | |
| 24 | + Given I am a regular user | |
| 25 | + And I am signed in | |
| 26 | + And I own a sample configuration | |
| 27 | + And I have a reading group named "Scholar" | |
| 28 | + And I have a sample metric configuration within the given mezuro configuration | |
| 29 | + And I am at the sample metric configuration page | |
| 30 | + When I click the Add Range link | |
| 31 | + Then I should be at the New Range page | |
| 32 | + And I should see "Beginning" | |
| 33 | + And I should see "End" | |
| 34 | + And I should see "Comments" | |
| 35 | + And I should see "You must have Readings within your associated Reading Group to create a new Range." | |
| 36 | + And I should see "The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it." | |
| 37 | + | |
| 38 | + @kalibro_configuration_restart | |
| 39 | + Scenario: Visiting range creation page when the user own an empty reading group (testing link to New Reading) | |
| 40 | + Given I am a regular user | |
| 41 | + And I am signed in | |
| 42 | + And I own a sample configuration | |
| 43 | + And I own a sample reading group | |
| 44 | + And I have a sample metric configuration within the given mezuro configuration | |
| 45 | + And I am at the sample metric configuration page | |
| 46 | + When I click the Add Range link | |
| 47 | + Then I should be at the New Range page | |
| 48 | + And I should see "Beginning" | |
| 49 | + And I should see "End" | |
| 50 | + And I should see "Comments" | |
| 51 | + And I should see "You must have Readings within your associated Reading Group to create a new Range." | |
| 52 | + When I click the Create New Reading link | |
| 53 | + Then I should be at the New Reading page | |
| 54 | + And I should see "Label" | |
| 55 | + And I should see "Grade" | |
| 56 | + And I should see "Color" | |
| 57 | + | |
| 58 | + @kalibro_configuration_restart | |
| 59 | + Scenario: With valid fields and owning a non-empty reading group | |
| 60 | + Given I am a regular user | |
| 61 | + And I am signed in | |
| 62 | + And I own a sample configuration | |
| 63 | + And I own a sample reading group | |
| 64 | + And I have a sample metric configuration within the given mezuro configuration | |
| 65 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 66 | + And I am at the New Range page | |
| 67 | + And I fill the Beginning field with "42" | |
| 68 | + And I fill the End field with "666" | |
| 69 | + And I fill the Comments field with "My Comment" | |
| 70 | + And I set the select field "Reading" as "My Reading" | |
| 71 | + When I press the Save button | |
| 72 | + Then I should be at metric configuration sample page | |
| 73 | + | |
| 74 | + @kalibro_configuration_restart | |
| 75 | + Scenario: With invalid fields and owning a non-empty reading group (Beginning > End) | |
| 76 | + Given I am a regular user | |
| 77 | + And I am signed in | |
| 78 | + And I own a sample configuration | |
| 79 | + And I own a sample reading group | |
| 80 | + And I have a sample metric configuration within the given mezuro configuration | |
| 81 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 82 | + And I am at the New Range page | |
| 83 | + And I fill the Beginning field with "666" | |
| 84 | + And I fill the End field with "42" | |
| 85 | + And I fill the Comments field with "My Comment" | |
| 86 | + And I set the select field "Reading" as "My Reading" | |
| 87 | + When I press the Save button | |
| 88 | + Then I should be at the New Range page | |
| 89 | + And I should see "1 error prohibited this KalibroRange from being saved" | |
| 90 | + And I should see "[666.0, 42.0[ is not a valid range" | |
| 91 | + | |
| 92 | + @kalibro_configuration_restart | |
| 93 | + Scenario: With an invalid beggining (not a number) | |
| 94 | + Given I am a regular user | |
| 95 | + And I am signed in | |
| 96 | + And I own a sample configuration | |
| 97 | + And I own a sample reading group | |
| 98 | + And I have a sample metric configuration within the given mezuro configuration | |
| 99 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 100 | + And I am at the New Range page | |
| 101 | + And I fill the Beginning field with "z" | |
| 102 | + And I fill the End field with "42" | |
| 103 | + And I fill the Comments field with "My Comment" | |
| 104 | + And I set the select field "Reading" as "My Reading" | |
| 105 | + When I press the Save button | |
| 106 | + Then I should be at the New Range page | |
| 107 | + And I should see "1 error prohibited this KalibroRange from being saved" | |
| 108 | + And I should see "Beginning is not a number" | |
| 109 | + | |
| 110 | + @kalibro_configuration_restart | |
| 111 | + Scenario: With an invalid end (not a number) | |
| 112 | + Given I am a regular user | |
| 113 | + And I am signed in | |
| 114 | + And I own a sample configuration | |
| 115 | + And I own a sample reading group | |
| 116 | + And I have a sample metric configuration within the given mezuro configuration | |
| 117 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 118 | + And I am at the New Range page | |
| 119 | + And I fill the Beginning field with "42" | |
| 120 | + And I fill the End field with "z" | |
| 121 | + And I fill the Comments field with "My Comment" | |
| 122 | + And I set the select field "Reading" as "My Reading" | |
| 123 | + When I press the Save button | |
| 124 | + Then I should see "1 error prohibited this KalibroRange from being saved" | |
| 125 | + And I should be at the New Range page | |
| 126 | + | |
| 127 | + @kalibro_configuration_restart | |
| 128 | + Scenario: With an already taken beginning | |
| 129 | + Given I am a regular user | |
| 130 | + And I am signed in | |
| 131 | + And I own a sample configuration | |
| 132 | + And I own a sample reading group | |
| 133 | + And I have a sample metric configuration within the given mezuro configuration | |
| 134 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 135 | + And I have a sample range within the sample metric configuration with beginning "2" | |
| 136 | + And I am at the New Range page | |
| 137 | + And I fill the Beginning field with "2" | |
| 138 | + And I fill the End field with "666" | |
| 139 | + And I fill the Comments field with "My Comment" | |
| 140 | + And I set the select field "Reading" as "My Reading" | |
| 141 | + When I press the Save button | |
| 142 | + Then I should be at the New Range page | |
| 143 | + And I should see "Beginning There is already a KalibroRange with beginning 2.0! Please, choose another one." | |
| 144 | + | |
| 145 | + @kalibro_configuration_restart @javascript | |
| 146 | + Scenario: Should create range with [-INF, INF] threshold | |
| 147 | + Given I am a regular user | |
| 148 | + And I am signed in | |
| 149 | + And I own a sample configuration | |
| 150 | + And I own a sample reading group | |
| 151 | + And I have a sample metric configuration within the given mezuro configuration | |
| 152 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 153 | + And I am at the New Range page | |
| 154 | + And I click the -∞ link | |
| 155 | + And I click the ∞ link | |
| 156 | + And I fill the Comments field with "My Comment" | |
| 157 | + And I set the select field "Reading" as "My Reading" | |
| 158 | + When I press the Save button | |
| 159 | + Then I should be at metric configuration sample page | |
| 160 | + And I should see "-INF" | |
| 161 | + And I should see "INF" | |
| 162 | + | |
| 163 | + @kalibro_configuration_restart @javascript | |
| 164 | + Scenario: Two valid ranges (one with INF) | |
| 165 | + Given I am a regular user | |
| 166 | + And I am signed in | |
| 167 | + And I own a sample configuration | |
| 168 | + And I own a sample reading group | |
| 169 | + And I have a sample metric configuration within the given mezuro configuration | |
| 170 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 171 | + And I am at the New Range page | |
| 172 | + And I fill the Beginning field with "2" | |
| 173 | + And I fill the End field with "666" | |
| 174 | + And I fill the Comments field with "My Comment" | |
| 175 | + And I set the select field "Reading" as "My Reading" | |
| 176 | + And I press the Save button | |
| 177 | + And I am at the New Range page | |
| 178 | + And I fill the Beginning field with "666" | |
| 179 | + And I click the ∞ link | |
| 180 | + And I fill the Comments field with "My Comment" | |
| 181 | + And I set the select field "Reading" as "My Reading" | |
| 182 | + When I press the Save button | |
| 183 | + Then I should be at metric configuration sample page | |
| 184 | + And I should see "666" | |
| 185 | + And I should see "INF" | |
| 0 | 186 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | +Feature: Range Deletion | |
| 2 | + In order to be able to remove a range | |
| 3 | + As a regular user | |
| 4 | + The system should have an interface to it | |
| 5 | + | |
| 6 | + @kalibro_configuration_restart | |
| 7 | + Scenario: Should delete a range that I own | |
| 8 | + Given I am a regular user | |
| 9 | + And I am signed in | |
| 10 | + And I own a sample configuration | |
| 11 | + And I have a sample reading group | |
| 12 | + And I have a sample metric configuration within the given mezuro configuration | |
| 13 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 14 | + And I have a sample range within the sample metric configuration | |
| 15 | + And I am at the sample metric configuration page | |
| 16 | + When I click the Destroy link | |
| 17 | + Then I should be at metric configuration sample page | |
| 18 | + And I should see "There are no Ranges yet!" | |
| 19 | + | |
| 20 | + @kalibro_configuration_restart | |
| 21 | + Scenario: Should not see the destroy range link in the range that I not own | |
| 22 | + Given I am a regular user | |
| 23 | + And I am signed in | |
| 24 | + And I have a sample configuration | |
| 25 | + And I have a sample reading group | |
| 26 | + And I have a sample metric configuration within the given mezuro configuration | |
| 27 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 28 | + And I have a sample range within the sample metric configuration | |
| 29 | + When I am at the sample metric configuration page | |
| 30 | + Then I should not see "Destroy" | ... | ... |
| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | +Feature: Kalibro Range Edit | |
| 2 | + In Order to be able to update my kalibro range info | |
| 3 | + As a regular user | |
| 4 | + I should be able to edit my kalibro ranges | |
| 5 | + | |
| 6 | + @kalibro_configuration_restart | |
| 7 | + Scenario: editing a kalibro range successfully | |
| 8 | + Given I am a regular user | |
| 9 | + And I am signed in | |
| 10 | + And I own a sample configuration | |
| 11 | + And I own a sample reading group | |
| 12 | + And I have a sample metric configuration within the given mezuro configuration | |
| 13 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 14 | + And I have a sample range within the sample metric configuration with beginning "1.1" | |
| 15 | + And I am at the Edit Kalibro Range page | |
| 16 | + And the select field "Reading" is set as "My Reading" | |
| 17 | + And the field "Beginning" should be filled with "1.1" | |
| 18 | + And the field "End" should be filled with "5.1" | |
| 19 | + And the field "Comments" should be filled with "Comment" | |
| 20 | + When I fill the Beginning field with "2.2" | |
| 21 | + And I press the Save button | |
| 22 | + Then I should see "2.2" | |
| 23 | + | |
| 24 | + @kalibro_configuration_restart | |
| 25 | + Scenario: editing a kalibro range with blank fields | |
| 26 | + Given I am a regular user | |
| 27 | + And I am signed in | |
| 28 | + And I own a sample configuration | |
| 29 | + And I own a sample reading group | |
| 30 | + And I have a sample metric configuration within the given mezuro configuration | |
| 31 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
| 32 | + And I have a sample range within the sample metric configuration with beginning "1" | |
| 33 | + And I am at the Edit Kalibro Range page | |
| 34 | + When I fill the Beginning field with " " | |
| 35 | + And I press the Save button | |
| 36 | + Then I should see "Beginning can't be blank" | ... | ... |
features/mezuro_range/create.feature
| ... | ... | @@ -1,185 +0,0 @@ |
| 1 | -Feature: Create range | |
| 2 | - In order to be able to create new ranges | |
| 3 | - As a metric specialist | |
| 4 | - I should be able to fill up a form with its informations and submit it | |
| 5 | - | |
| 6 | - @kalibro_configuration_restart | |
| 7 | - Scenario: Visiting range creation page when the user own an non-empty reading group | |
| 8 | - Given I am a regular user | |
| 9 | - And I am signed in | |
| 10 | - And I own a sample configuration | |
| 11 | - And I own a sample reading group | |
| 12 | - And I have a sample metric configuration within the given mezuro configuration | |
| 13 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 14 | - And I am at the sample metric configuration page | |
| 15 | - When I click the Add Range link | |
| 16 | - Then I should be at the New Range page | |
| 17 | - And I should see "Beginning" | |
| 18 | - And I should see "End" | |
| 19 | - And I should see "Comments" | |
| 20 | - And I should see "Reading" | |
| 21 | - | |
| 22 | - @kalibro_configuration_restart | |
| 23 | - Scenario: Visiting range creation page when the user don't own the reading group and this reading group is empty | |
| 24 | - Given I am a regular user | |
| 25 | - And I am signed in | |
| 26 | - And I own a sample configuration | |
| 27 | - And I have a reading group named "Scholar" | |
| 28 | - And I have a sample metric configuration within the given mezuro configuration | |
| 29 | - And I am at the sample metric configuration page | |
| 30 | - When I click the Add Range link | |
| 31 | - Then I should be at the New Range page | |
| 32 | - And I should see "Beginning" | |
| 33 | - And I should see "End" | |
| 34 | - And I should see "Comments" | |
| 35 | - And I should see "You must have Readings within your associated Reading Group to create a new Range." | |
| 36 | - And I should see "The Reading Group of your Metric Configuration belongs to another user and you are not allowed to modify it." | |
| 37 | - | |
| 38 | - @kalibro_configuration_restart | |
| 39 | - Scenario: Visiting range creation page when the user own an empty reading group (testing link to New Reading) | |
| 40 | - Given I am a regular user | |
| 41 | - And I am signed in | |
| 42 | - And I own a sample configuration | |
| 43 | - And I own a sample reading group | |
| 44 | - And I have a sample metric configuration within the given mezuro configuration | |
| 45 | - And I am at the sample metric configuration page | |
| 46 | - When I click the Add Range link | |
| 47 | - Then I should be at the New Range page | |
| 48 | - And I should see "Beginning" | |
| 49 | - And I should see "End" | |
| 50 | - And I should see "Comments" | |
| 51 | - And I should see "You must have Readings within your associated Reading Group to create a new Range." | |
| 52 | - When I click the Create New Reading link | |
| 53 | - Then I should be at the New Reading page | |
| 54 | - And I should see "Label" | |
| 55 | - And I should see "Grade" | |
| 56 | - And I should see "Color" | |
| 57 | - | |
| 58 | - @kalibro_configuration_restart | |
| 59 | - Scenario: With valid fields and owning a non-empty reading group | |
| 60 | - Given I am a regular user | |
| 61 | - And I am signed in | |
| 62 | - And I own a sample configuration | |
| 63 | - And I own a sample reading group | |
| 64 | - And I have a sample metric configuration within the given mezuro configuration | |
| 65 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 66 | - And I am at the New Range page | |
| 67 | - And I fill the Beginning field with "42" | |
| 68 | - And I fill the End field with "666" | |
| 69 | - And I fill the Comments field with "My Comment" | |
| 70 | - And I set the select field "Reading" as "My Reading" | |
| 71 | - When I press the Save button | |
| 72 | - Then I should be at metric configuration sample page | |
| 73 | - | |
| 74 | - @kalibro_configuration_restart | |
| 75 | - Scenario: With invalid fields and owning a non-empty reading group (Beginning > End) | |
| 76 | - Given I am a regular user | |
| 77 | - And I am signed in | |
| 78 | - And I own a sample configuration | |
| 79 | - And I own a sample reading group | |
| 80 | - And I have a sample metric configuration within the given mezuro configuration | |
| 81 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 82 | - And I am at the New Range page | |
| 83 | - And I fill the Beginning field with "666" | |
| 84 | - And I fill the End field with "42" | |
| 85 | - And I fill the Comments field with "My Comment" | |
| 86 | - And I set the select field "Reading" as "My Reading" | |
| 87 | - When I press the Save button | |
| 88 | - Then I should be at the New Range page | |
| 89 | - And I should see "1 error prohibited this MezuroRange from being saved" | |
| 90 | - And I should see "[666.0, 42.0[ is not a valid range" | |
| 91 | - | |
| 92 | - @kalibro_configuration_restart | |
| 93 | - Scenario: With an invalid beggining (not a number) | |
| 94 | - Given I am a regular user | |
| 95 | - And I am signed in | |
| 96 | - And I own a sample configuration | |
| 97 | - And I own a sample reading group | |
| 98 | - And I have a sample metric configuration within the given mezuro configuration | |
| 99 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 100 | - And I am at the New Range page | |
| 101 | - And I fill the Beginning field with "z" | |
| 102 | - And I fill the End field with "42" | |
| 103 | - And I fill the Comments field with "My Comment" | |
| 104 | - And I set the select field "Reading" as "My Reading" | |
| 105 | - When I press the Save button | |
| 106 | - Then I should be at the New Range page | |
| 107 | - And I should see "1 error prohibited this MezuroRange from being saved" | |
| 108 | - And I should see "Beginning is not a number" | |
| 109 | - | |
| 110 | - @kalibro_configuration_restart | |
| 111 | - Scenario: With an invalid end (not a number) | |
| 112 | - Given I am a regular user | |
| 113 | - And I am signed in | |
| 114 | - And I own a sample configuration | |
| 115 | - And I own a sample reading group | |
| 116 | - And I have a sample metric configuration within the given mezuro configuration | |
| 117 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 118 | - And I am at the New Range page | |
| 119 | - And I fill the Beginning field with "42" | |
| 120 | - And I fill the End field with "z" | |
| 121 | - And I fill the Comments field with "My Comment" | |
| 122 | - And I set the select field "Reading" as "My Reading" | |
| 123 | - When I press the Save button | |
| 124 | - Then I should see "1 error prohibited this MezuroRange from being saved" | |
| 125 | - And I should be at the New Range page | |
| 126 | - | |
| 127 | - @kalibro_configuration_restart | |
| 128 | - Scenario: With an already taken beginning | |
| 129 | - Given I am a regular user | |
| 130 | - And I am signed in | |
| 131 | - And I own a sample configuration | |
| 132 | - And I own a sample reading group | |
| 133 | - And I have a sample metric configuration within the given mezuro configuration | |
| 134 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 135 | - And I have a sample range within the sample metric configuration with beginning "2" | |
| 136 | - And I am at the New Range page | |
| 137 | - And I fill the Beginning field with "2" | |
| 138 | - And I fill the End field with "666" | |
| 139 | - And I fill the Comments field with "My Comment" | |
| 140 | - And I set the select field "Reading" as "My Reading" | |
| 141 | - When I press the Save button | |
| 142 | - Then I should be at the New Range page | |
| 143 | - And I should see "Beginning There is already a MezuroRange with beginning 2.0! Please, choose another one." | |
| 144 | - | |
| 145 | - @kalibro_configuration_restart @javascript | |
| 146 | - Scenario: Should create range with [-INF, INF] threshold | |
| 147 | - Given I am a regular user | |
| 148 | - And I am signed in | |
| 149 | - And I own a sample configuration | |
| 150 | - And I own a sample reading group | |
| 151 | - And I have a sample metric configuration within the given mezuro configuration | |
| 152 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 153 | - And I am at the New Range page | |
| 154 | - And I click the -∞ link | |
| 155 | - And I click the ∞ link | |
| 156 | - And I fill the Comments field with "My Comment" | |
| 157 | - And I set the select field "Reading" as "My Reading" | |
| 158 | - When I press the Save button | |
| 159 | - Then I should be at metric configuration sample page | |
| 160 | - And I should see "-INF" | |
| 161 | - And I should see "INF" | |
| 162 | - | |
| 163 | - @kalibro_configuration_restart @javascript | |
| 164 | - Scenario: Two valid ranges (one with INF) | |
| 165 | - Given I am a regular user | |
| 166 | - And I am signed in | |
| 167 | - And I own a sample configuration | |
| 168 | - And I own a sample reading group | |
| 169 | - And I have a sample metric configuration within the given mezuro configuration | |
| 170 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 171 | - And I am at the New Range page | |
| 172 | - And I fill the Beginning field with "2" | |
| 173 | - And I fill the End field with "666" | |
| 174 | - And I fill the Comments field with "My Comment" | |
| 175 | - And I set the select field "Reading" as "My Reading" | |
| 176 | - And I press the Save button | |
| 177 | - And I am at the New Range page | |
| 178 | - And I fill the Beginning field with "666" | |
| 179 | - And I click the ∞ link | |
| 180 | - And I fill the Comments field with "My Comment" | |
| 181 | - And I set the select field "Reading" as "My Reading" | |
| 182 | - When I press the Save button | |
| 183 | - Then I should be at metric configuration sample page | |
| 184 | - And I should see "666" | |
| 185 | - And I should see "INF" | |
| 186 | 0 | \ No newline at end of file |
features/mezuro_range/deletion.feature
| ... | ... | @@ -1,30 +0,0 @@ |
| 1 | -Feature: Range Deletion | |
| 2 | - In order to be able to remove a range | |
| 3 | - As a regular user | |
| 4 | - The system should have an interface to it | |
| 5 | - | |
| 6 | - @kalibro_configuration_restart | |
| 7 | - Scenario: Should delete a range that I own | |
| 8 | - Given I am a regular user | |
| 9 | - And I am signed in | |
| 10 | - And I own a sample configuration | |
| 11 | - And I have a sample reading group | |
| 12 | - And I have a sample metric configuration within the given mezuro configuration | |
| 13 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 14 | - And I have a sample range within the sample metric configuration | |
| 15 | - And I am at the sample metric configuration page | |
| 16 | - When I click the Destroy link | |
| 17 | - Then I should be at metric configuration sample page | |
| 18 | - And I should see "There are no Ranges yet!" | |
| 19 | - | |
| 20 | - @kalibro_configuration_restart | |
| 21 | - Scenario: Should not see the destroy range link in the range that I not own | |
| 22 | - Given I am a regular user | |
| 23 | - And I am signed in | |
| 24 | - And I have a sample configuration | |
| 25 | - And I have a sample reading group | |
| 26 | - And I have a sample metric configuration within the given mezuro configuration | |
| 27 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 28 | - And I have a sample range within the sample metric configuration | |
| 29 | - When I am at the sample metric configuration page | |
| 30 | - Then I should not see "Destroy" |
features/mezuro_range/edit.feature
| ... | ... | @@ -1,36 +0,0 @@ |
| 1 | -Feature: Mezuro Range Edit | |
| 2 | - In Order to be able to update my mezuro range info | |
| 3 | - As a regular user | |
| 4 | - I should be able to edit my mezuro ranges | |
| 5 | - | |
| 6 | - @kalibro_configuration_restart | |
| 7 | - Scenario: editing a mezuro range successfully | |
| 8 | - Given I am a regular user | |
| 9 | - And I am signed in | |
| 10 | - And I own a sample configuration | |
| 11 | - And I own a sample reading group | |
| 12 | - And I have a sample metric configuration within the given mezuro configuration | |
| 13 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 14 | - And I have a sample range within the sample metric configuration with beginning "1.1" | |
| 15 | - And I am at the Edit Mezuro Range page | |
| 16 | - And the select field "Reading" is set as "My Reading" | |
| 17 | - And the field "Beginning" should be filled with "1.1" | |
| 18 | - And the field "End" should be filled with "5.1" | |
| 19 | - And the field "Comments" should be filled with "Comment" | |
| 20 | - When I fill the Beginning field with "2.2" | |
| 21 | - And I press the Save button | |
| 22 | - Then I should see "2.2" | |
| 23 | - | |
| 24 | - @kalibro_configuration_restart | |
| 25 | - Scenario: editing a mezuro range with blank fields | |
| 26 | - Given I am a regular user | |
| 27 | - And I am signed in | |
| 28 | - And I own a sample configuration | |
| 29 | - And I own a sample reading group | |
| 30 | - And I have a sample metric configuration within the given mezuro configuration | |
| 31 | - And I have a sample reading within the sample reading group labeled "My Reading" | |
| 32 | - And I have a sample range within the sample metric configuration with beginning "1" | |
| 33 | - And I am at the Edit Mezuro Range page | |
| 34 | - When I fill the Beginning field with " " | |
| 35 | - And I press the Save button | |
| 36 | - Then I should see "Beginning can't be blank" |
features/step_definitions/compound_metric_configuration_steps.rb
| ... | ... | @@ -7,11 +7,11 @@ Given(/^I see the sample metric configuration code$/) do |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | Given(/^I have a sample compound metric configuration within the given mezuro configuration$/) do |
| 10 | - @compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {id: nil, configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id}) | |
| 10 | + @compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, reading_group_id: @reading_group.id}) | |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | Given(/^I have another compound metric configuration with code "(.*?)" within the given mezuro configuration$/) do |code| |
| 14 | - @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {id: nil, configuration_id: @kalibro_configuration.id, code: code, reading_group_id: @reading_group.id}) | |
| 14 | + @another_compound_metric_configuration = FactoryGirl.create(:compound_metric_configuration, {kalibro_configuration_id: @kalibro_configuration.id, code: code, reading_group_id: @reading_group.id}) | |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | When(/^I visit the sample compound metric configuration edit page$/) do | ... | ... |
| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | +Given(/^I have a sample range within the sample metric configuration with beginning "(.*?)"$/) do |beginning| | |
| 2 | + @kalibro_range = FactoryGirl.create(:kalibro_range, {beginning: beginning, metric_configuration_id: @metric_configuration.id, | |
| 3 | + reading_id: @reading.id}) | |
| 4 | +end | |
| 5 | + | |
| 6 | +Given(/^I am at the Edit Kalibro Range page$/) do | |
| 7 | + visit edit_kalibro_configuration_metric_configuration_kalibro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id, @kalibro_range.id) | |
| 8 | +end | |
| 9 | + | |
| 10 | +Given(/^the select field "(.*?)" is set as "(.*?)"$/) do |field, text| | |
| 11 | + select text, from: field | |
| 12 | +end | |
| 13 | + | |
| 14 | +Given(/^I have a sample range within the sample metric configuration$/) do | |
| 15 | + @kalibro_range = FactoryGirl.create(:kalibro_range, {metric_configuration_id: @metric_configuration.id, | |
| 16 | + reading_id: @reading.id}) | |
| 17 | +end | |
| 18 | + | |
| 19 | +Given(/^I have a sample range within the sample compound metric configuration$/) do | |
| 20 | + @kalibro_range = FactoryGirl.create(:kalibro_range, {metric_configuration_id: @compound_metric_configuration.id, | |
| 21 | + reading_id: @reading.id}) | |
| 22 | +end | |
| 23 | + | |
| 24 | +When(/^I am at the New Range page$/) do | |
| 25 | + visit kalibro_configuration_metric_configuration_new_kalibro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id) | |
| 26 | +end | |
| 27 | + | |
| 28 | +Then(/^I should be at the New Range page$/) do | |
| 29 | + expect(page).to have_content("New Range") | |
| 30 | + expect(page).to have_content("Beginning") | |
| 31 | + expect(page).to have_content("End") | |
| 32 | + expect(page).to have_content("Comments") | |
| 33 | +end | |
| 34 | + | |
| 35 | +Then(/^I should see the sample range$/) do | |
| 36 | + expect(page).to have_content(@kalibro_range.label) | |
| 37 | + expect(page).to have_content(@kalibro_range.beginning) | |
| 38 | + expect(page).to have_content(@kalibro_range.end) | |
| 39 | +end | ... | ... |
features/step_definitions/mezuro_range_steps.rb
| ... | ... | @@ -1,39 +0,0 @@ |
| 1 | -Given(/^I have a sample range within the sample metric configuration with beginning "(.*?)"$/) do |beginning| | |
| 2 | - @mezuro_range = FactoryGirl.create(:mezuro_range, {beginning: beginning, metric_configuration_id: @metric_configuration.id, | |
| 3 | - reading_id: @reading.id, id: nil}) | |
| 4 | -end | |
| 5 | - | |
| 6 | -Given(/^I am at the Edit Mezuro Range page$/) do | |
| 7 | - visit edit_kalibro_configuration_metric_configuration_mezuro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id, @mezuro_range.id) | |
| 8 | -end | |
| 9 | - | |
| 10 | -Given(/^the select field "(.*?)" is set as "(.*?)"$/) do |field, text| | |
| 11 | - select text, from: field | |
| 12 | -end | |
| 13 | - | |
| 14 | -Given(/^I have a sample range within the sample metric configuration$/) do | |
| 15 | - @mezuro_range = FactoryGirl.create(:mezuro_range, {metric_configuration_id: @metric_configuration.id, | |
| 16 | - reading_id: @reading.id, id: nil}) | |
| 17 | -end | |
| 18 | - | |
| 19 | -Given(/^I have a sample range within the sample compound metric configuration$/) do | |
| 20 | - @mezuro_range = FactoryGirl.create(:mezuro_range, {metric_configuration_id: @compound_metric_configuration.id, | |
| 21 | - reading_id: @reading.id, id: nil}) | |
| 22 | -end | |
| 23 | - | |
| 24 | -When(/^I am at the New Range page$/) do | |
| 25 | - visit kalibro_configuration_metric_configuration_new_mezuro_range_path(@metric_configuration.kalibro_configuration_id, @metric_configuration.id) | |
| 26 | -end | |
| 27 | - | |
| 28 | -Then(/^I should be at the New Range page$/) do | |
| 29 | - expect(page).to have_content("New Range") | |
| 30 | - expect(page).to have_content("Beginning") | |
| 31 | - expect(page).to have_content("End") | |
| 32 | - expect(page).to have_content("Comments") | |
| 33 | -end | |
| 34 | - | |
| 35 | -Then(/^I should see the sample range$/) do | |
| 36 | - expect(page).to have_content(@mezuro_range.label) | |
| 37 | - expect(page).to have_content(@mezuro_range.beginning) | |
| 38 | - expect(page).to have_content(@mezuro_range.end) | |
| 39 | -end |
features/step_definitions/repository_steps.rb
| ... | ... | @@ -22,7 +22,7 @@ Given(/^I have a sample configuration with native metrics$/) do |
| 22 | 22 | reading_group_id: reading_group.id, |
| 23 | 23 | kalibro_configuration_id: @kalibro_configuration.id, |
| 24 | 24 | code: 'loc'}) |
| 25 | - range = FactoryGirl.build(:mezuro_range, {id: nil, reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id}) | |
| 25 | + range = FactoryGirl.build(:kalibro_range, {reading_id: reading.id, beginning: '-INF', :end => 'INF', metric_configuration_id: metric_configuration.id}) | |
| 26 | 26 | range.save |
| 27 | 27 | end |
| 28 | 28 | ... | ... |
spec/controllers/base_metric_configurations_controller_spec.rb
| ... | ... | @@ -30,8 +30,8 @@ class InheritsFromBaseMetricConfigurationsController < BaseMetricConfigurationsC |
| 30 | 30 | @metric_configuration = new_metric_configuration |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | - def mezuro_ranges | |
| 34 | - @mezuro_ranges | |
| 33 | + def kalibro_ranges | |
| 34 | + @kalibro_ranges | |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | def reading_group |
| ... | ... | @@ -112,18 +112,18 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do |
| 112 | 112 | describe 'show' do |
| 113 | 113 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } |
| 114 | 114 | let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } |
| 115 | - let(:mezuro_range) { FactoryGirl.build(:mezuro_range) } | |
| 115 | + let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } | |
| 116 | 116 | |
| 117 | 117 | context 'with a valid metric_configuration' do |
| 118 | 118 | before :each do |
| 119 | 119 | ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).returns(reading_group) |
| 120 | 120 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 121 | - metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) | |
| 121 | + metric_configuration.expects(:kalibro_ranges).returns([kalibro_range]) | |
| 122 | 122 | |
| 123 | 123 | get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id |
| 124 | 124 | end |
| 125 | 125 | |
| 126 | - it { expect(subject.mezuro_ranges).not_to be_nil} | |
| 126 | + it { expect(subject.kalibro_ranges).not_to be_nil} | |
| 127 | 127 | it { expect(subject.reading_group).not_to be_nil } |
| 128 | 128 | end |
| 129 | 129 | ... | ... |
spec/controllers/compound_metric_configurations_controller_spec.rb
| ... | ... | @@ -72,12 +72,12 @@ describe CompoundMetricConfigurationsController, :type => :controller do |
| 72 | 72 | describe 'show' do |
| 73 | 73 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) } |
| 74 | 74 | let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } |
| 75 | - let(:mezuro_range) { FactoryGirl.build(:mezuro_range) } | |
| 75 | + let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } | |
| 76 | 76 | |
| 77 | 77 | before :each do |
| 78 | 78 | ReadingGroup.expects(:find).with(compound_metric_configuration.reading_group_id).returns(reading_group) |
| 79 | 79 | subject.expects(:find_resource).with(MetricConfiguration, compound_metric_configuration.id).returns(compound_metric_configuration) |
| 80 | - compound_metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) | |
| 80 | + compound_metric_configuration.expects(:kalibro_ranges).returns([kalibro_range]) | |
| 81 | 81 | |
| 82 | 82 | get :show, kalibro_configuration_id: compound_metric_configuration.kalibro_configuration_id.to_s, id: compound_metric_configuration.id |
| 83 | 83 | end | ... | ... |
| ... | ... | @@ -0,0 +1,206 @@ |
| 1 | +require 'rails_helper' | |
| 2 | + | |
| 3 | +describe KalibroRangesController, :type => :controller do | |
| 4 | + let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id) } | |
| 5 | + let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | |
| 6 | + | |
| 7 | + describe 'new' do | |
| 8 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | |
| 9 | + | |
| 10 | + before :each do | |
| 11 | + sign_in FactoryGirl.create(:user) | |
| 12 | + end | |
| 13 | + | |
| 14 | + context 'when the current user owns the metric configuration' do | |
| 15 | + before :each do | |
| 16 | + subject.expects(:metric_configuration_owner?).returns true | |
| 17 | + MetricConfiguration.expects(:find).with(kalibro_range.metric_configuration_id).returns(metric_configuration) | |
| 18 | + Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([]) | |
| 19 | + get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: kalibro_range.metric_configuration_id | |
| 20 | + end | |
| 21 | + | |
| 22 | + it { is_expected.to respond_with(:success) } | |
| 23 | + it { is_expected.to render_template(:new) } | |
| 24 | + end | |
| 25 | + | |
| 26 | + context "when the current user doesn't owns the metric configuration" do | |
| 27 | + before :each do | |
| 28 | + get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: kalibro_range.metric_configuration_id | |
| 29 | + end | |
| 30 | + | |
| 31 | + it { is_expected.to redirect_to(kalibro_configurations_path(kalibro_configuration.id)) } | |
| 32 | + it { is_expected.to respond_with(:redirect) } | |
| 33 | + end | |
| 34 | + end | |
| 35 | + | |
| 36 | + describe 'create' do | |
| 37 | + let(:kalibro_range_params) { kalibro_range.to_hash } | |
| 38 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | |
| 39 | + | |
| 40 | + before do | |
| 41 | + sign_in FactoryGirl.create(:user) | |
| 42 | + end | |
| 43 | + | |
| 44 | + context 'when the current user owns the mezuro range' do | |
| 45 | + before :each do | |
| 46 | + subject.expects(:metric_configuration_owner?).returns true | |
| 47 | + end | |
| 48 | + | |
| 49 | + context 'with valid fields' do | |
| 50 | + before :each do | |
| 51 | + KalibroRange.any_instance.expects(:save).returns(true) | |
| 52 | + | |
| 53 | + post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params | |
| 54 | + end | |
| 55 | + | |
| 56 | + it { is_expected.to respond_with(:redirect) } | |
| 57 | + end | |
| 58 | + | |
| 59 | + context 'with invalid fields' do | |
| 60 | + before :each do | |
| 61 | + KalibroRange.any_instance.expects(:save).returns(false) | |
| 62 | + MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
| 63 | + Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([]) | |
| 64 | + | |
| 65 | + post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, kalibro_range: kalibro_range_params | |
| 66 | + end | |
| 67 | + | |
| 68 | + it { is_expected.to render_template(:new) } | |
| 69 | + end | |
| 70 | + end | |
| 71 | + end | |
| 72 | + | |
| 73 | + describe 'destroy' do | |
| 74 | + context 'with an User logged in' do | |
| 75 | + before do | |
| 76 | + sign_in FactoryGirl.create(:user) | |
| 77 | + end | |
| 78 | + | |
| 79 | + context 'when the user owns the metric configuration' do | |
| 80 | + before :each do | |
| 81 | + subject.expects(:metric_configuration_owner?).returns true | |
| 82 | + kalibro_range.expects(:destroy) | |
| 83 | + subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) | |
| 84 | + | |
| 85 | + 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 | |
| 86 | + end | |
| 87 | + | |
| 88 | + it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) } | |
| 89 | + it { is_expected.to respond_with(:redirect) } | |
| 90 | + end | |
| 91 | + | |
| 92 | + context "when the user doesn't own the metric configuration" do | |
| 93 | + before :each do | |
| 94 | + 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 | |
| 95 | + end | |
| 96 | + | |
| 97 | + it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) } | |
| 98 | + it { is_expected.to respond_with(:redirect) } | |
| 99 | + end | |
| 100 | + end | |
| 101 | + | |
| 102 | + context 'with no User logged in' do | |
| 103 | + before :each do | |
| 104 | + 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 | |
| 105 | + end | |
| 106 | + | |
| 107 | + it { is_expected.to redirect_to new_user_session_path } | |
| 108 | + end | |
| 109 | + end | |
| 110 | + | |
| 111 | + describe 'edit' do | |
| 112 | + let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | |
| 113 | + let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id, metric_configuration_id: metric_configuration.id) } | |
| 114 | + let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) } | |
| 115 | + | |
| 116 | + context 'with an User logged in' do | |
| 117 | + before do | |
| 118 | + sign_in FactoryGirl.create(:user) | |
| 119 | + end | |
| 120 | + | |
| 121 | + context 'when the user owns the mezuro range' do | |
| 122 | + before :each do | |
| 123 | + subject.expects(:metric_configuration_owner?).returns true | |
| 124 | + subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) | |
| 125 | + MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
| 126 | + Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) | |
| 127 | + get :edit, id: kalibro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id | |
| 128 | + end | |
| 129 | + | |
| 130 | + it { is_expected.to render_template(:edit) } | |
| 131 | + end | |
| 132 | + | |
| 133 | + context 'when the user does not own the mezuro range' do | |
| 134 | + let!(:reading_group) { FactoryGirl.build(:reading_group, id: metric_configuration.reading_group_id) } | |
| 135 | + | |
| 136 | + before do | |
| 137 | + get :edit, id: kalibro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id | |
| 138 | + end | |
| 139 | + | |
| 140 | + it { is_expected.to redirect_to(kalibro_configurations_url(metric_configuration.kalibro_configuration_id)) } | |
| 141 | + it { is_expected.to respond_with(:redirect) } | |
| 142 | + it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") } | |
| 143 | + end | |
| 144 | + end | |
| 145 | + | |
| 146 | + context 'with no user logged in' do | |
| 147 | + before :each do | |
| 148 | + get :edit, id: kalibro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id | |
| 149 | + end | |
| 150 | + | |
| 151 | + it { is_expected.to redirect_to new_user_session_path } | |
| 152 | + end | |
| 153 | + end | |
| 154 | + | |
| 155 | + describe 'update' do | |
| 156 | + let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | |
| 157 | + let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id, metric_configuration_id: metric_configuration.id) } | |
| 158 | + let(:kalibro_range_params) { kalibro_range.to_hash } | |
| 159 | + let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) } | |
| 160 | + | |
| 161 | + context 'when the user is logged in' do | |
| 162 | + before do | |
| 163 | + sign_in FactoryGirl.create(:user) | |
| 164 | + end | |
| 165 | + | |
| 166 | + context 'when user owns the mezuro range' do | |
| 167 | + before :each do | |
| 168 | + subject.expects(:metric_configuration_owner?).returns true | |
| 169 | + end | |
| 170 | + | |
| 171 | + context 'with valid fields' do | |
| 172 | + before :each do | |
| 173 | + subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) | |
| 174 | + KalibroRange.any_instance.expects(:update).with(kalibro_range_params).returns(true) | |
| 175 | + | |
| 176 | + 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 | |
| 177 | + end | |
| 178 | + | |
| 179 | + it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) } | |
| 180 | + it { is_expected.to respond_with(:redirect) } | |
| 181 | + end | |
| 182 | + | |
| 183 | + context 'with an invalid field' do | |
| 184 | + before :each do | |
| 185 | + subject.expects(:find_resource).with(KalibroRange, kalibro_range.id).returns(kalibro_range) | |
| 186 | + KalibroRange.any_instance.expects(:update).with(kalibro_range_params).returns(false) | |
| 187 | + MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
| 188 | + Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) | |
| 189 | + | |
| 190 | + 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 | |
| 191 | + end | |
| 192 | + | |
| 193 | + it { is_expected.to render_template(:edit) } | |
| 194 | + end | |
| 195 | + end | |
| 196 | + | |
| 197 | + context 'when the user does not own the mezuro range' do | |
| 198 | + before :each do | |
| 199 | + 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 | |
| 200 | + end | |
| 201 | + | |
| 202 | + it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.kalibro_configuration_id) } | |
| 203 | + end | |
| 204 | + end | |
| 205 | + end | |
| 206 | +end | ... | ... |
spec/controllers/metric_configurations_controller_spec.rb
| ... | ... | @@ -93,12 +93,12 @@ describe MetricConfigurationsController, :type => :controller do |
| 93 | 93 | describe 'show' do |
| 94 | 94 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } |
| 95 | 95 | let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } |
| 96 | - let(:mezuro_range) { FactoryGirl.build(:mezuro_range) } | |
| 96 | + let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } | |
| 97 | 97 | |
| 98 | 98 | before :each do |
| 99 | 99 | ReadingGroup.expects(:find).with(metric_configuration.reading_group_id).returns(reading_group) |
| 100 | 100 | subject.expects(:find_resource).with(MetricConfiguration, metric_configuration.id).returns(metric_configuration) |
| 101 | - metric_configuration.expects(:kalibro_ranges).returns([mezuro_range]) | |
| 101 | + metric_configuration.expects(:kalibro_ranges).returns([kalibro_range]) | |
| 102 | 102 | |
| 103 | 103 | get :show, kalibro_configuration_id: metric_configuration.kalibro_configuration_id.to_s, id: metric_configuration.id |
| 104 | 104 | end | ... | ... |
spec/controllers/mezuro_ranges_controller_spec.rb
| ... | ... | @@ -1,206 +0,0 @@ |
| 1 | -require 'rails_helper' | |
| 2 | - | |
| 3 | -describe MezuroRangesController, :type => :controller do | |
| 4 | - let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1) } | |
| 5 | - let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | |
| 6 | - | |
| 7 | - describe 'new' do | |
| 8 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | |
| 9 | - | |
| 10 | - before :each do | |
| 11 | - sign_in FactoryGirl.create(:user) | |
| 12 | - end | |
| 13 | - | |
| 14 | - context 'when the current user owns the metric configuration' do | |
| 15 | - before :each do | |
| 16 | - subject.expects(:metric_configuration_owner?).returns true | |
| 17 | - MetricConfiguration.expects(:find).with(mezuro_range.metric_configuration_id).returns(metric_configuration) | |
| 18 | - Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([]) | |
| 19 | - get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: mezuro_range.metric_configuration_id | |
| 20 | - end | |
| 21 | - | |
| 22 | - it { is_expected.to respond_with(:success) } | |
| 23 | - it { is_expected.to render_template(:new) } | |
| 24 | - end | |
| 25 | - | |
| 26 | - context "when the current user doesn't owns the metric configuration" do | |
| 27 | - before :each do | |
| 28 | - get :new, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: mezuro_range.metric_configuration_id | |
| 29 | - end | |
| 30 | - | |
| 31 | - it { is_expected.to redirect_to(kalibro_configurations_path(kalibro_configuration.id)) } | |
| 32 | - it { is_expected.to respond_with(:redirect) } | |
| 33 | - end | |
| 34 | - end | |
| 35 | - | |
| 36 | - describe 'create' do | |
| 37 | - 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 | |
| 38 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | |
| 39 | - | |
| 40 | - before do | |
| 41 | - sign_in FactoryGirl.create(:user) | |
| 42 | - end | |
| 43 | - | |
| 44 | - context 'when the current user owns the mezuro range' do | |
| 45 | - before :each do | |
| 46 | - subject.expects(:metric_configuration_owner?).returns true | |
| 47 | - end | |
| 48 | - | |
| 49 | - context 'with valid fields' do | |
| 50 | - before :each do | |
| 51 | - MezuroRange.any_instance.expects(:save).returns(true) | |
| 52 | - | |
| 53 | - post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params | |
| 54 | - end | |
| 55 | - | |
| 56 | - it { is_expected.to respond_with(:redirect) } | |
| 57 | - end | |
| 58 | - | |
| 59 | - context 'with invalid fields' do | |
| 60 | - before :each do | |
| 61 | - MezuroRange.any_instance.expects(:save).returns(false) | |
| 62 | - MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
| 63 | - Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([]) | |
| 64 | - | |
| 65 | - post :create, kalibro_configuration_id: kalibro_configuration.id, metric_configuration_id: metric_configuration.id, mezuro_range: mezuro_range_params | |
| 66 | - end | |
| 67 | - | |
| 68 | - it { is_expected.to render_template(:new) } | |
| 69 | - end | |
| 70 | - end | |
| 71 | - end | |
| 72 | - | |
| 73 | - describe 'destroy' do | |
| 74 | - context 'with an User logged in' do | |
| 75 | - before do | |
| 76 | - sign_in FactoryGirl.create(:user) | |
| 77 | - end | |
| 78 | - | |
| 79 | - context 'when the user owns the metric configuration' do | |
| 80 | - before :each do | |
| 81 | - subject.expects(:metric_configuration_owner?).returns true | |
| 82 | - mezuro_range.expects(:destroy) | |
| 83 | - subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) | |
| 84 | - | |
| 85 | - 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 | |
| 86 | - end | |
| 87 | - | |
| 88 | - it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) } | |
| 89 | - it { is_expected.to respond_with(:redirect) } | |
| 90 | - end | |
| 91 | - | |
| 92 | - context "when the user doesn't own the metric configuration" do | |
| 93 | - before :each do | |
| 94 | - 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 | |
| 95 | - end | |
| 96 | - | |
| 97 | - it { is_expected.to redirect_to(kalibro_configurations_path(metric_configuration.kalibro_configuration_id)) } | |
| 98 | - it { is_expected.to respond_with(:redirect) } | |
| 99 | - end | |
| 100 | - end | |
| 101 | - | |
| 102 | - context 'with no User logged in' do | |
| 103 | - before :each do | |
| 104 | - 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 | |
| 105 | - end | |
| 106 | - | |
| 107 | - it { is_expected.to redirect_to new_user_session_path } | |
| 108 | - end | |
| 109 | - end | |
| 110 | - | |
| 111 | - describe 'edit' do | |
| 112 | - let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | |
| 113 | - let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) } | |
| 114 | - let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) } | |
| 115 | - | |
| 116 | - context 'with an User logged in' do | |
| 117 | - before do | |
| 118 | - sign_in FactoryGirl.create(:user) | |
| 119 | - end | |
| 120 | - | |
| 121 | - context 'when the user owns the mezuro range' do | |
| 122 | - before :each do | |
| 123 | - subject.expects(:metric_configuration_owner?).returns true | |
| 124 | - subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) | |
| 125 | - MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
| 126 | - Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) | |
| 127 | - get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id | |
| 128 | - end | |
| 129 | - | |
| 130 | - it { is_expected.to render_template(:edit) } | |
| 131 | - end | |
| 132 | - | |
| 133 | - context 'when the user does not own the mezuro range' do | |
| 134 | - let!(:reading_group) { FactoryGirl.build(:reading_group, id: metric_configuration.reading_group_id) } | |
| 135 | - | |
| 136 | - before do | |
| 137 | - get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id | |
| 138 | - end | |
| 139 | - | |
| 140 | - it { is_expected.to redirect_to(kalibro_configurations_url(metric_configuration.kalibro_configuration_id)) } | |
| 141 | - it { is_expected.to respond_with(:redirect) } | |
| 142 | - it { is_expected.to set_the_flash[:notice].to("You're not allowed to do this operation") } | |
| 143 | - end | |
| 144 | - end | |
| 145 | - | |
| 146 | - context 'with no user logged in' do | |
| 147 | - before :each do | |
| 148 | - get :edit, id: mezuro_range.id, kalibro_configuration_id: metric_configuration.kalibro_configuration_id, metric_configuration_id: metric_configuration.id | |
| 149 | - end | |
| 150 | - | |
| 151 | - it { is_expected.to redirect_to new_user_session_path } | |
| 152 | - end | |
| 153 | - end | |
| 154 | - | |
| 155 | - describe 'update' do | |
| 156 | - let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | |
| 157 | - let(:mezuro_range) { FactoryGirl.build(:mezuro_range, id: 1, metric_configuration_id: metric_configuration.id) } | |
| 158 | - 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 | |
| 159 | - let(:reading) { FactoryGirl.build(:reading_with_id, reading_group_id: metric_configuration.reading_group_id) } | |
| 160 | - | |
| 161 | - context 'when the user is logged in' do | |
| 162 | - before do | |
| 163 | - sign_in FactoryGirl.create(:user) | |
| 164 | - end | |
| 165 | - | |
| 166 | - context 'when user owns the mezuro range' do | |
| 167 | - before :each do | |
| 168 | - subject.expects(:metric_configuration_owner?).returns true | |
| 169 | - end | |
| 170 | - | |
| 171 | - context 'with valid fields' do | |
| 172 | - before :each do | |
| 173 | - subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) | |
| 174 | - MezuroRange.any_instance.expects(:update).with(mezuro_range_params).returns(true) | |
| 175 | - | |
| 176 | - 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 | |
| 177 | - end | |
| 178 | - | |
| 179 | - it { is_expected.to redirect_to(kalibro_configuration_metric_configuration_path(metric_configuration.kalibro_configuration_id, metric_configuration.id)) } | |
| 180 | - it { is_expected.to respond_with(:redirect) } | |
| 181 | - end | |
| 182 | - | |
| 183 | - context 'with an invalid field' do | |
| 184 | - before :each do | |
| 185 | - subject.expects(:find_resource).with(MezuroRange, mezuro_range.id).returns(mezuro_range) | |
| 186 | - MezuroRange.any_instance.expects(:update).with(mezuro_range_params).returns(false) | |
| 187 | - MetricConfiguration.expects(:find).with(metric_configuration.id).returns(metric_configuration) | |
| 188 | - Reading.expects(:readings_of).with(metric_configuration.reading_group_id).returns([reading]) | |
| 189 | - | |
| 190 | - 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 | |
| 191 | - end | |
| 192 | - | |
| 193 | - it { is_expected.to render_template(:edit) } | |
| 194 | - end | |
| 195 | - end | |
| 196 | - | |
| 197 | - context 'when the user does not own the mezuro range' do | |
| 198 | - before :each do | |
| 199 | - 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 | |
| 200 | - end | |
| 201 | - | |
| 202 | - it { is_expected.to redirect_to kalibro_configurations_path(metric_configuration.kalibro_configuration_id) } | |
| 203 | - end | |
| 204 | - end | |
| 205 | - end | |
| 206 | -end |
| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | +# This file is part of KalibroEntities | |
| 2 | +# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file) | |
| 3 | +# | |
| 4 | +# This program is free software: you can redistribute it and/or modify | |
| 5 | +# it under the terms of the GNU General Public License as published by | |
| 6 | +# the Free Software Foundation, either version 3 of the License, or | |
| 7 | +# (at your option) any later version. | |
| 8 | +# | |
| 9 | +# This program is distributed in the hope that it will be useful, | |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | +# GNU General Public License for more details. | |
| 13 | + | |
| 14 | +# You should have received a copy of the GNU General Public License | |
| 15 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + | |
| 17 | +FactoryGirl.define do | |
| 18 | + factory :kalibro_range do | |
| 19 | + beginning 1.1 | |
| 20 | + self.end 5.1 | |
| 21 | + reading_id 3 | |
| 22 | + comments "Comment" | |
| 23 | + metric_configuration_id 32 | |
| 24 | + | |
| 25 | + trait :another_comment do | |
| 26 | + comments "Another Comment" | |
| 27 | + end | |
| 28 | + | |
| 29 | + trait :with_id do | |
| 30 | + id 1 | |
| 31 | + end | |
| 32 | + | |
| 33 | + factory :kalibro_range_with_id, traits: [:with_id] | |
| 34 | + factory :another_kalibro_range, traits: [:another_comment] | |
| 35 | + end | |
| 36 | +end | |
| 0 | 37 | \ No newline at end of file | ... | ... |
spec/factories/mezuro_ranges.rb
| ... | ... | @@ -1,31 +0,0 @@ |
| 1 | -# This file is part of KalibroEntities | |
| 2 | -# Copyright (C) 2013 it's respectives authors (please see the AUTHORS file) | |
| 3 | -# | |
| 4 | -# This program is free software: you can redistribute it and/or modify | |
| 5 | -# it under the terms of the GNU General Public License as published by | |
| 6 | -# the Free Software Foundation, either version 3 of the License, or | |
| 7 | -# (at your option) any later version. | |
| 8 | -# | |
| 9 | -# This program is distributed in the hope that it will be useful, | |
| 10 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | -# GNU General Public License for more details. | |
| 13 | - | |
| 14 | -# You should have received a copy of the GNU General Public License | |
| 15 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | - | |
| 17 | -FactoryGirl.define do | |
| 18 | - factory :mezuro_range do | |
| 19 | - beginning 1.1 | |
| 20 | - self.end 5.1 | |
| 21 | - reading_id 3 | |
| 22 | - comments "Comment" | |
| 23 | - metric_configuration_id 32 | |
| 24 | - | |
| 25 | - trait :another_comment do | |
| 26 | - comments "Another Comment" | |
| 27 | - end | |
| 28 | - | |
| 29 | - factory :another_mezuro_range, traits: [:another_comment] | |
| 30 | - end | |
| 31 | -end | |
| 32 | 0 | \ No newline at end of file |
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | +require 'rails_helper' | |
| 2 | + | |
| 3 | +describe KalibroRangesHelper, :type => :helper do | |
| 4 | + describe 'readings_options' do | |
| 5 | + let(:reading) { FactoryGirl.build(:reading_with_id) } | |
| 6 | + it 'should return a pair with the reading label and id' do | |
| 7 | + expect(helper.readings_options([reading])).to eq [[reading.label, reading.id]] | |
| 8 | + end | |
| 9 | + end | |
| 10 | +end | |
| 11 | + | ... | ... |
spec/helpers/mezuro_ranges_helper_spec.rb
| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | -require 'rails_helper' | |
| 2 | - | |
| 3 | -describe MezuroRangesHelper, :type => :helper do | |
| 4 | - describe 'readings_options' do | |
| 5 | - let(:reading) { FactoryGirl.build(:reading_with_id) } | |
| 6 | - it 'should return a pair with the reading label and id' do | |
| 7 | - expect(helper.readings_options([reading])).to eq [[reading.label, reading.id]] | |
| 8 | - end | |
| 9 | - end | |
| 10 | -end | |
| 11 | - |
| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | +require "rails_helper" | |
| 2 | + | |
| 3 | +describe KalibroRangesController, :type => :routing do | |
| 4 | + describe "routing" do | |
| 5 | + it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges'). | |
| 6 | + to(controller: :kalibro_ranges, action: :index, kalibro_configuration_id: "1", metric_configuration_id: "1") } | |
| 7 | + it { is_expected.to route(:post, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges'). | |
| 8 | + to(controller: :kalibro_ranges, action: :create, kalibro_configuration_id: "1", metric_configuration_id: "1") } | |
| 9 | + it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1/edit'). | |
| 10 | + to(controller: :kalibro_ranges, action: :edit, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 11 | + it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1'). | |
| 12 | + to(controller: :kalibro_ranges, action: :show, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 13 | + it { is_expected.to route(:delete, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1'). | |
| 14 | + to(controller: :kalibro_ranges, action: :destroy, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 15 | + it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/new'). | |
| 16 | + to(controller: :kalibro_ranges, action: :new, kalibro_configuration_id: "1", metric_configuration_id: "1") } | |
| 17 | + it { is_expected.to route(:put, '/kalibro_configurations/1/metric_configurations/1/kalibro_ranges/1'). | |
| 18 | + to(controller: :kalibro_ranges, action: :update, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 19 | + end | |
| 20 | +end | ... | ... |
spec/routing/mezuro_ranges_routing_spec.rb
| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | -require "rails_helper" | |
| 2 | - | |
| 3 | -describe MezuroRangesController, :type => :routing do | |
| 4 | - describe "routing" do | |
| 5 | - it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges'). | |
| 6 | - to(controller: :mezuro_ranges, action: :index, kalibro_configuration_id: "1", metric_configuration_id: "1") } | |
| 7 | - it { is_expected.to route(:post, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges'). | |
| 8 | - to(controller: :mezuro_ranges, action: :create, kalibro_configuration_id: "1", metric_configuration_id: "1") } | |
| 9 | - it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1/edit'). | |
| 10 | - to(controller: :mezuro_ranges, action: :edit, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 11 | - it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1'). | |
| 12 | - to(controller: :mezuro_ranges, action: :show, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 13 | - it { is_expected.to route(:delete, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1'). | |
| 14 | - to(controller: :mezuro_ranges, action: :destroy, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 15 | - it { is_expected.to route(:get, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/new'). | |
| 16 | - to(controller: :mezuro_ranges, action: :new, kalibro_configuration_id: "1", metric_configuration_id: "1") } | |
| 17 | - it { is_expected.to route(:put, '/kalibro_configurations/1/metric_configurations/1/mezuro_ranges/1'). | |
| 18 | - to(controller: :mezuro_ranges, action: :update, kalibro_configuration_id: "1", metric_configuration_id: "1", id: "1") } | |
| 19 | - end | |
| 20 | -end |