forked from joakimk/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,3 +149,7 @@ form h4 { | |
} | ||
} | ||
} | ||
|
||
.navbar-brand--logo { | ||
margin-bottom: 100px !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class CloudInitsController < WebController | ||
def index | ||
locals cloud_inits: CloudInit.all | ||
end | ||
|
||
def new | ||
locals cloud_init: CloudInit.new | ||
end | ||
|
||
def edit | ||
locals cloud_init: CloudInit.find(params[:id]) | ||
end | ||
|
||
def create | ||
cloud_init = CloudInit.new(cloud_init_params) | ||
|
||
if cloud_init.save | ||
redirect_to cloud_inits_path, notice: "Cloud-init was successfully created." | ||
else | ||
render :new, locals: { cloud_init: }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def update | ||
cloud_init = CloudInit.find(params[:id]) | ||
|
||
if cloud_init.update(cloud_init_params) | ||
redirect_to cloud_inits_path, notice: "Cloud-init was successfully updated." | ||
else | ||
render :edit, locals: { cloud_init: }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
cloud_init = CloudInit.find(params[:id]) | ||
cloud_init.destroy! | ||
redirect_to cloud_inits_path, notice: "Cloud-init was successfully destroyed.", status: :see_other | ||
end | ||
|
||
private | ||
|
||
def setup_menu | ||
active_menu_item_name :cloud_inits | ||
end | ||
|
||
def cloud_init_params | ||
params.require(:cloud_init).permit(:name, :data) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class CloudInit < ActiveRecord::Base | ||
validates :name, :data, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.row | ||
.span12 | ||
.page | ||
.row | ||
.span9 | ||
= bootstrap_form_for(cloud_init) do |f| | ||
= f.text_field :name | ||
= f.text_area :data, style: "width: 875px; height: 400px;", label: "Contents" | ||
p = link_to "Cloud-init docs", "https://cloudinit.readthedocs.io/en/latest/", target: "_blank" | ||
.form-actions | ||
= submit_tag "Save", class: "btn btn-primary" | ||
- if cloud_init.persisted? | ||
.span2 | ||
= button_to "Remove", cloud_init_path(cloud_init), method: :delete, data: { confirm: "Are you sure you want to remove #{cloud_init.name}?" }, class: "btn btn-danger" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
h1 Editing cloud-init | ||
|
||
= render "form", cloud_init: cloud_init | ||
|
||
br | ||
|
||
div | ||
= link_to "Back to cloud-inits", cloud_inits_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
h1 Cloud-inits | ||
|
||
.row.index | ||
.span12 | ||
- cloud_inits.each do |cloud_init| | ||
.project | ||
.actions | ||
= link_to "Edit", edit_cloud_init_path(cloud_init) | ||
.status | ||
h1 = cloud_init.name | ||
pre = cloud_init.data | ||
p = link_to "New cloud-init", new_cloud_init_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
h1 New cloud-init | ||
|
||
= render "form", cloud_init: cloud_init | ||
|
||
br | ||
|
||
div | ||
= link_to "Back to cloud-inits", cloud_inits_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateCloudInits < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :cloud_inits do |t| | ||
t.string :name, null: false | ||
t.text :data, null: false | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe "Cloud-inits", type: :feature do | ||
it "can be managed" do | ||
visit root_path | ||
click_link "Cloud-inits" | ||
click_link "New cloud-init" | ||
|
||
fill_in "Name", with: "foo" | ||
fill_in "Content", with: "content" | ||
click_button "Save" | ||
expect(current_path).to eq(cloud_inits_path) | ||
expect(page).to have_content("Cloud-init was successfully created.") | ||
cloud_init = CloudInit.first! | ||
expect(cloud_init.data).to eq("content") | ||
|
||
click_link "Edit" | ||
fill_in "Name", with: "bar" | ||
click_button "Save" | ||
cloud_init.reload | ||
expect(cloud_init.name).to eq("bar") | ||
|
||
click_link "Edit" | ||
click_button "Remove" | ||
expect(current_path).to eq(cloud_inits_path) | ||
expect(page).to have_content("Cloud-init was successfully destroyed.") | ||
expect(CloudInit.all).to be_empty | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters