diff options
28 files changed, 59 insertions, 61 deletions
| diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index ec695bcbf..bc5bedd7f 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -77,7 +77,7 @@ class CompaniesController < InheritedResources::Base    def decorate_companies(companies)      ModelDecorator.decorate(        companies, -      with: Chouette::CompanyDecorator, +      with: CompanyDecorator,        context: {          referential: line_referential        } diff --git a/app/controllers/journey_patterns_collections_controller.rb b/app/controllers/journey_patterns_collections_controller.rb index f217dccb3..546158fa8 100644 --- a/app/controllers/journey_patterns_collections_controller.rb +++ b/app/controllers/journey_patterns_collections_controller.rb @@ -48,7 +48,7 @@ class JourneyPatternsCollectionsController < ChouetteController    end    def user_permissions -    policy = policy(:"chouette/journey_pattern") +    policy = policy(:journey_pattern)      @perms =        %w{create destroy update}.inject({}) do | permissions, action |          permissions.merge( "journey_patterns.#{action}" => policy.authorizes_action?(action) ) diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 49a8ca2c5..cf2908500 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -15,7 +15,7 @@ class LinesController < InheritedResources::Base      index! do |format|        @lines = ModelDecorator.decorate(          @lines, -        with: Chouette::LineDecorator, +        with: LineDecorator,          context: {            line_referential: @line_referential,            current_organisation: current_organisation diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb index d90af0ed8..98c840777 100644 --- a/app/controllers/networks_controller.rb +++ b/app/controllers/networks_controller.rb @@ -85,7 +85,7 @@ class NetworksController < InheritedResources::Base    def decorate_networks(networks)      ModelDecorator.decorate(        networks, -      with: Chouette::NetworkDecorator, +      with: NetworkDecorator,        context: {          line_referential: line_referential        } diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index 75e574da3..b9f8c0050 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -29,7 +29,7 @@ class ReferentialLinesController < ChouetteController      @routes = ModelDecorator.decorate(        @routes, -      with: Chouette::RouteDecorator, +      with: RouteDecorator,        context: {          referential: referential,          line: @line diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index c8813dbcb..1a6c82484 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -48,7 +48,7 @@ class RoutesController < ChouetteController        @route_sp = ModelDecorator.decorate(          @route_sp, -        with: Chouette::StopPointDecorator +        with: StopPointDecorator        )      end    end diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index 8261373a6..6c3da5980 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -14,7 +14,7 @@ class RoutingConstraintZonesController < ChouetteController      index! do |format|        @routing_constraint_zones = ModelDecorator.decorate(          @routing_constraint_zones, -        with: Chouette::RoutingConstraintZoneDecorator, +        with: RoutingConstraintZoneDecorator,          context: {            referential: referential,            line: parent diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 2732c5f99..1d6f88068 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -56,7 +56,7 @@ class StopAreasController < InheritedResources::Base          @stop_areas = ModelDecorator.decorate(            @stop_areas, -          with: Chouette::StopAreaDecorator +          with: StopAreaDecorator          )        }      end diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 34b1ca89d..0c1769ad7 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -168,7 +168,7 @@ class TimeTablesController < ChouetteController    def decorate_time_tables(time_tables)      ModelDecorator.decorate(        time_tables, -      with: Chouette::TimeTableDecorator, +      with: TimeTableDecorator,        context: {          referential: @referential        } diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index e74957ffc..050f2f219 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -158,7 +158,7 @@ class VehicleJourneysController < ChouetteController    end    def user_permissions -    policy = policy(:"chouette/vehicle_journey") +    policy = policy(:vehicle_journey)      @perms =        %w{create destroy update}.inject({}) do | permissions, action |          permissions.merge( "vehicle_journeys.#{action}" => policy.authorizes_action?(action) ) diff --git a/app/decorators/referential_network_decorator.rb b/app/decorators/referential_network_decorator.rb index 7b1c6ada9..1260a38cb 100644 --- a/app/decorators/referential_network_decorator.rb +++ b/app/decorators/referential_network_decorator.rb @@ -1,40 +1,38 @@ -module Chouette -  class NetworkDecorator < Draper::Decorator -    decorates Chouette::Network +class ReferentialNetworkDecorator < Draper::Decorator +  decorates Chouette::Network -    delegate_all +  delegate_all -  # Requires: -  #   context: { -  #     referential: , -  #   } -  def action_links -    links = [] +# Requires: +#   context: { +#     referential: , +#   } +def action_links +  links = [] -    if h.policy(Chouette::Network).create? -      links << Link.new( -        content: h.t('networks.actions.new'), -        href: h.new_referential_network_path(context[:referential]) -      ) -    end +  if h.policy(Chouette::Network).create? +    links << Link.new( +      content: h.t('networks.actions.new'), +      href: h.new_referential_network_path(context[:referential]) +    ) +  end -    if h.policy(object).update? -      links << Link.new( -        content: h.t('networks.actions.edit'), -        href: h.edit_referential_network_path(context[:referential], object) -      ) -    end +  if h.policy(object).update? +    links << Link.new( +      content: h.t('networks.actions.edit'), +      href: h.edit_referential_network_path(context[:referential], object) +    ) +  end -    if h.policy(object).destroy? -      links << Link.new( -        content: h.destroy_link_content('networks.actions.destroy'), -        href: h.referential_network_path(context[:referential], object), -        method: :delete, -        data: { confirm: t('networks.actions.destroy_confirm') } -      ) -    end +  if h.policy(object).destroy? +    links << Link.new( +      content: h.destroy_link_content('networks.actions.destroy'), +      href: h.referential_network_path(context[:referential], object), +      method: :delete, +      data: { confirm: t('networks.actions.destroy_confirm') } +    ) +  end -      links -    end +    links    end  end
\ No newline at end of file diff --git a/app/models/chouette/stop_point.rb b/app/models/chouette/stop_point.rb index 86be39d70..f4c9b3800 100644 --- a/app/models/chouette/stop_point.rb +++ b/app/models/chouette/stop_point.rb @@ -2,7 +2,7 @@ module Chouette    class StopPoint < Chouette::TridentActiveRecord      def self.policy_class -      Chouette::RoutePolicy +      RoutePolicy      end      include ForBoardingEnumerations diff --git a/spec/features/line_footnotes_permissions_spec.rb b/spec/features/line_footnotes_permissions_spec.rb index deac8e8fc..62adbfcd5 100644 --- a/spec/features/line_footnotes_permissions_spec.rb +++ b/spec/features/line_footnotes_permissions_spec.rb @@ -10,7 +10,7 @@ describe 'Line Footnotes', type: :feature do    describe 'permissions' do      before do -      allow_any_instance_of(Chouette::LinePolicy).to receive(:update_footnote?).and_return permission +      allow_any_instance_of(LinePolicy).to receive(:update_footnote?).and_return permission        visit path      end diff --git a/spec/features/lines_permissions_spec.rb b/spec/features/lines_permissions_spec.rb index 903868fae..5d53d6568 100644 --- a/spec/features/lines_permissions_spec.rb +++ b/spec/features/lines_permissions_spec.rb @@ -13,8 +13,8 @@ describe "Lines", :type => :feature do        create :group_of_line        line_referential.lines << line        line_referential.organisations << Organisation.first -      allow_any_instance_of(Chouette::LinePolicy).to receive(:create?).and_return permission -      allow_any_instance_of(Chouette::LinePolicy).to receive(:destroy?).and_return permission +      allow_any_instance_of(LinePolicy).to receive(:create?).and_return permission +      allow_any_instance_of(LinePolicy).to receive(:destroy?).and_return permission        visit path      end diff --git a/spec/features/referential_lines_permissions_spec.rb b/spec/features/referential_lines_permissions_spec.rb index bedec3d07..0d156f0d6 100644 --- a/spec/features/referential_lines_permissions_spec.rb +++ b/spec/features/referential_lines_permissions_spec.rb @@ -7,7 +7,7 @@ describe 'ReferentialLines', type: :feature do    context 'permissions' do       before do -      allow_any_instance_of(Chouette::RoutePolicy).to receive(:create?).and_return permission +      allow_any_instance_of(RoutePolicy).to receive(:create?).and_return permission        visit path      end diff --git a/spec/features/routes_permissions_spec.rb b/spec/features/routes_permissions_spec.rb index 467d8479d..36c13b24a 100644 --- a/spec/features/routes_permissions_spec.rb +++ b/spec/features/routes_permissions_spec.rb @@ -11,8 +11,8 @@ describe "Routes", :type => :feature do    describe 'permissions' do      before do        @user.update(organisation: referential.organisation) -      allow_any_instance_of(Chouette::RoutePolicy).to receive(:edit?).and_return permission -      allow_any_instance_of(Chouette::RoutePolicy).to receive(:destroy?).and_return permission +      allow_any_instance_of(RoutePolicy).to receive(:edit?).and_return permission +      allow_any_instance_of(RoutePolicy).to receive(:destroy?).and_return permission        visit path      end diff --git a/spec/features/time_tables_permissions_spec.rb b/spec/features/time_tables_permissions_spec.rb index 01c7c2ed2..bd94a3aa1 100644 --- a/spec/features/time_tables_permissions_spec.rb +++ b/spec/features/time_tables_permissions_spec.rb @@ -8,7 +8,7 @@ describe "TimeTables", :type => :feature do    describe 'permissions' do      before do -      allow_any_instance_of(Chouette::TimeTablePolicy).to receive(:duplicate?).and_return permission +      allow_any_instance_of(TimeTablePolicy).to receive(:duplicate?).and_return permission        visit path      end diff --git a/spec/policies/access_link_policy_spec.rb b/spec/policies/access_link_policy_spec.rb index 392ad7f92..6194ae55c 100644 --- a/spec/policies/access_link_policy_spec.rb +++ b/spec/policies/access_link_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::AccessLinkPolicy, type: :policy do +RSpec.describe AccessLinkPolicy, type: :policy do    let( :record ){ build_stubbed :access_link } diff --git a/spec/policies/access_point_policy_spec.rb b/spec/policies/access_point_policy_spec.rb index 8154b3d24..b6bc46eb4 100644 --- a/spec/policies/access_point_policy_spec.rb +++ b/spec/policies/access_point_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::AccessPointPolicy, type: :policy do +RSpec.describe AccessPointPolicy, type: :policy do    let( :record ){ build_stubbed :access_point } diff --git a/spec/policies/company_policy_spec.rb b/spec/policies/company_policy_spec.rb index f374e31d2..2d249a2be 100644 --- a/spec/policies/company_policy_spec.rb +++ b/spec/policies/company_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::CompanyPolicy, type: :policy do +RSpec.describe CompanyPolicy, type: :policy do    let( :record ){ build_stubbed :company }    before { stub_policy_scope(record) } diff --git a/spec/policies/connection_link_policy_spec.rb b/spec/policies/connection_link_policy_spec.rb index 17cfdeb04..23e40abe3 100644 --- a/spec/policies/connection_link_policy_spec.rb +++ b/spec/policies/connection_link_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::ConnectionLinkPolicy, type: :policy do +RSpec.describe ConnectionLinkPolicy, type: :policy do    let( :record ){ build_stubbed :connection_link } diff --git a/spec/policies/group_of_line_policy_spec.rb b/spec/policies/group_of_line_policy_spec.rb index 7a58a7f0e..29fbb1bfb 100644 --- a/spec/policies/group_of_line_policy_spec.rb +++ b/spec/policies/group_of_line_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::GroupOfLinePolicy, type: :policy do +RSpec.describe GroupOfLinePolicy, type: :policy do    let( :record ){ build_stubbed :group_of_line }    before { stub_policy_scope(record) } diff --git a/spec/policies/journey_pattern_policy_spec.rb b/spec/policies/journey_pattern_policy_spec.rb index a7de379a2..39f849277 100644 --- a/spec/policies/journey_pattern_policy_spec.rb +++ b/spec/policies/journey_pattern_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::JourneyPatternPolicy, type: :policy do +RSpec.describe JourneyPatternPolicy, type: :policy do    let( :record ){ build_stubbed :journey_pattern } diff --git a/spec/policies/line_policy_spec.rb b/spec/policies/line_policy_spec.rb index d2248e750..334073506 100644 --- a/spec/policies/line_policy_spec.rb +++ b/spec/policies/line_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::LinePolicy, type: :policy do +RSpec.describe LinePolicy, type: :policy do    let( :record ){ build_stubbed :line }    before { stub_policy_scope(record) } diff --git a/spec/policies/routing_constraint_zone_policy_spec.rb b/spec/policies/routing_constraint_zone_policy_spec.rb index 903e3671a..2ef15fa95 100644 --- a/spec/policies/routing_constraint_zone_policy_spec.rb +++ b/spec/policies/routing_constraint_zone_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::RoutingConstraintZonePolicy, type: :policy do +RSpec.describe RoutingConstraintZonePolicy, type: :policy do    let( :record ){ build_stubbed :routing_constraint_zone } diff --git a/spec/policies/stop_area_policy_spec.rb b/spec/policies/stop_area_policy_spec.rb index 1295ecd68..8fe59c8e3 100644 --- a/spec/policies/stop_area_policy_spec.rb +++ b/spec/policies/stop_area_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::StopAreaPolicy, type: :policy do +RSpec.describe StopAreaPolicy, type: :policy do    let( :record ){ build_stubbed :stop_area }    before { stub_policy_scope(record) } diff --git a/spec/policies/time_table_policy_spec.rb b/spec/policies/time_table_policy_spec.rb index 6f1e13844..dad3c13bc 100644 --- a/spec/policies/time_table_policy_spec.rb +++ b/spec/policies/time_table_policy_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Chouette::TimeTablePolicy, type: :policy do +RSpec.describe TimeTablePolicy, type: :policy do    let( :record ){ build_stubbed :time_table } diff --git a/spec/views/routes/show.html.erb_spec.rb b/spec/views/routes/show.html.erb_spec.rb index ee917127f..dae8c9ed3 100644 --- a/spec/views/routes/show.html.erb_spec.rb +++ b/spec/views/routes/show.html.erb_spec.rb @@ -6,7 +6,7 @@ RSpec.describe "/routes/show", type: :view do    let!(:route_sp) do      assign :route_sp, ModelDecorator.decorate(        route.stop_points, -      with: Chouette::StopPointDecorator +      with: StopPointDecorator      )    end | 
