Skip to content

Commit

Permalink
Introduce staging namespace in WebUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Nov 13, 2018
1 parent 78d60e2 commit e415d23
Show file tree
Hide file tree
Showing 19 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Webui
module StagingWorkflows
class StagingProjectsController < WebuiController
module Staging
class ProjectsController < WebuiController
layout 'webui2/webui'

before_action :require_login
Expand Down Expand Up @@ -45,7 +45,7 @@ def destroy
private

def set_staging_workflow
@staging_workflow = Staging::Workflow.find(params[:staging_workflow_id])
@staging_workflow = ::Staging::Workflow.find(params[:staging_workflow_id])
return if @staging_workflow

redirect_back(fallback_location: root_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Webui::StagingWorkflowsController < Webui::WebuiController
class Webui::Staging::WorkflowsController < Webui::WebuiController
layout 'webui2/webui'

before_action :require_login, except: [:show]
Expand Down Expand Up @@ -47,7 +47,7 @@ def edit
end

def destroy
@staging_workflow = StagingWorkflow.find_by(id: params[:id])
@staging_workflow = ::Staging::Workflow.find_by(id: params[:id])
authorize @staging_workflow
@project = @staging_workflow.project

Expand All @@ -71,7 +71,7 @@ def set_bootstrap_views
end

def set_staging_workflow
@staging_workflow = Staging::Workflow.find_by(id: params[:id])
@staging_workflow = ::Staging::Workflow.find_by(id: params[:id])
return if @staging_workflow

redirect_back(fallback_location: root_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class StagingWorkflowPolicy < ApplicationPolicy
class Staging::WorkflowPolicy < ApplicationPolicy
def initialize(user, record)
raise Pundit::NotAuthorizedError, 'staging workflow does not exist' unless record
@user = user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Create Staging Projects
- else
%li.breadcrumb-item
= link_to 'Staging Projects', staging_workflow_path(@staging_workflow)
= link_to 'Staging Projects', staging_workflows_path(@staging_workflow)
- if controller_name == 'staging_workflows' && action_name == 'edit'
%li.breadcrumb-item.active{ 'aria-current' => 'page' }
Edit
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%i.fas.fa-edit.text-info
Edit Staging Workflow
- if policy(@staging_workflow).destroy?
= render(partial: 'webui2/webui/staging_workflows/delete', locals: { project: @project })
= render(partial: 'webui2/webui/staging/workflows/delete', locals: { project: @project })
%hr

%table.table.table-striped.table-bordered.table-sm.dt-responsive.w-100#staging-projects-datatable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Webui::StagingWorkflows::StagingProjectsController do
RSpec.describe Webui::Staging::ProjectsController do
let(:user) { create(:confirmed_user, login: 'tom') }
let(:project) { user.home_project }
let(:staging_workflow) { project.create_staging }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe Webui::StagingWorkflowsController do
RSpec.describe Webui::Staging::WorkflowsController do
let(:user) { create(:confirmed_user, login: 'tom') }
let(:project) { user.home_project }

Expand Down Expand Up @@ -128,7 +128,7 @@

subject { project.staging }

it { expect(StagingWorkflow.count).to eq(0) }
it { expect(Staging::Workflow.count).to eq(0) }
it { expect(subject.staging_projects.count).to eq(0) }
it { expect(flash[:success]).not_to be_nil }
it { expect(response.body).to eq("window.location='#{project_show_path(project)}'") }
Expand All @@ -144,7 +144,7 @@

subject { project.staging }

it { expect(StagingWorkflow.count).to eq(0) }
it { expect(Staging::Workflow.count).to eq(0) }
it { expect(subject.staging_projects.count).to eq(0) }
it { expect(project.subprojects.count).to eq(1) }
it { expect(flash[:success]).not_to be_nil }
Expand All @@ -154,7 +154,7 @@
context 'a staging workflow unsuccessful' do
before do
project.create_staging
allow_any_instance_of(StagingWorkflow).to receive(:destroy).and_return(false)
allow_any_instance_of(Staging::Workflow).to receive(:destroy).and_return(false)
params = { id: project.staging, staging_project_ids: project.staging.staging_projects.ids, format: :js }
delete :destroy, params: params
end
Expand Down

0 comments on commit e415d23

Please sign in to comment.