Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Store iFrames in a model

  • Loading branch information...
commit 33daddee8a2a7f913b9a941181b48ef150a204fb 1 parent e82a79f
@iain authored
Showing with 117 additions and 143 deletions.
  1. +5 −0 app/assets/stylesheets/_layout.sass
  2. +0 −7 app/controllers/coverage_controller.rb
  3. +0 −7 app/controllers/cucumber_controller.rb
  4. +5 −0 app/controllers/iframes_controller.rb
  5. +0 −7 app/controllers/rspec_controller.rb
  6. +20 −0 app/models/iframe.rb
  7. +2 −0  app/models/project.rb
  8. +0 −13 app/views/coverage/show.html.haml
  9. +0 −13 app/views/cucumber/show.html.haml
  10. +4 −0 app/views/iframes/_form.html.haml
  11. +5 −0 app/views/iframes/edit.html.haml
  12. +5 −0 app/views/iframes/new.html.haml
  13. +3 −0  app/views/iframes/show.html.haml
  14. +2 −8 app/views/projects/_header.html.haml
  15. +8 −4 app/views/projects/edit.html.haml
  16. +0 −13 app/views/rspec/show.html.haml
  17. +0 −11 config/locales/coverage.yml
  18. +0 −11 config/locales/cucumber.yml
  19. +9 −0 config/locales/iframes.yml
  20. +0 −11 config/locales/rspec.yml
  21. +1 −3 config/routes.rb
  22. +0 −8 db/migrate/20120115181329_add_rspec_and_cucumber_paths_to_projects.rb
  23. +0 −6 db/migrate/20120115230959_add_coverage_url_to_projects.rb
  24. +14 −0 db/migrate/20120115232627_create_iframes.rb
  25. +15 −6 db/schema.rb
  26. +0 −5 spec/controllers/coverage_controller_spec.rb
  27. +0 −5 spec/controllers/cucumber_controller_spec.rb
  28. +5 −0 spec/controllers/iframes_controller_spec.rb
  29. +0 −5 spec/controllers/rspec_controller_spec.rb
  30. +9 −0 spec/factories/iframes.rb
  31. +5 −0 spec/models/iframe_spec.rb
View
5 app/assets/stylesheets/_layout.sass
@@ -13,3 +13,8 @@ iframe
.simple_form input.string
@extend .span12
+
+.iframes
+ margin-left: 170px
+ .new
+ list-style-type: circle
View
7 app/controllers/coverage_controller.rb
@@ -1,7 +0,0 @@
-class CoverageController < ApplicationController
-
- def show
- @project = Project.find(params[:project_id])
- end
-
-end
View
7 app/controllers/cucumber_controller.rb
@@ -1,7 +0,0 @@
-class CucumberController < ApplicationController
-
- def show
- @project = Project.find(params[:project_id])
- end
-
-end
View
5 app/controllers/iframes_controller.rb
@@ -0,0 +1,5 @@
+class IframesController < InheritedResources::Base
+
+ belongs_to :project
+
+end
View
7 app/controllers/rspec_controller.rb
@@ -1,7 +0,0 @@
-class RspecController < ApplicationController
-
- def show
- @project = Project.find(params[:project_id])
- end
-
-end
View
20 app/models/iframe.rb
@@ -0,0 +1,20 @@
+class Iframe < ActiveRecord::Base
+
+ extend FriendlyId
+ friendly_id :name, :use => :slugged
+
+ validates_presence_of :name
+ validates_uniqueness_of :name, :scope => :project_id
+
+ validates_presence_of :url
+ validates_uniqueness_of :url
+
+ validates_presence_of :project_id
+
+ belongs_to :project
+
+ def self.list
+ order(:name)
+ end
+
+end
View
2  app/models/project.rb
@@ -6,6 +6,8 @@ class Project < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
+ has_many :iframes
+
def self.list
order(:name)
end
View
13 app/views/coverage/show.html.haml
@@ -1,13 +0,0 @@
-= render "projects/header", :project => @project, :tab => "coverage"
-
-- if @project.coverage_url?
- %iframe#coverage-frame{:src => @project.coverage_url}
-- else
-
- .alert-message.warning.fade.in{data("alert")}
- = link_to "×", "#", :class => "close"
- %p You haven't specified a Coverage URL yet
-
- = simple_form_for @project, :wrapper => :inline do |f|
- = f.input :coverage_url, :required => true
- = render "shared/actions", :f => f
View
13 app/views/cucumber/show.html.haml
@@ -1,13 +0,0 @@
-= render "projects/header", :project => @project, :tab => "cucumber"
-
-- if @project.cucumber_url?
- %iframe#cucumber-frame{:src => @project.cucumber_url}
-- else
-
- .alert-message.warning.fade.in{:data => { :alert => "alert" } }
- = link_to "×", "#", :class => "close"
- %p You haven't specified a Cucumber URL yet
-
- = simple_form_for @project, :wrapper => :inline do |f|
- = f.input :cucumber_url, :required => true
- = render "shared/actions", :f => f
View
4 app/views/iframes/_form.html.haml
@@ -0,0 +1,4 @@
+= simple_form_for [ @project, @iframe ], :wrapper => :inline do |f|
+ = f.input :name
+ = f.input :url
+ = render "shared/actions", :f => f
View
5 app/views/iframes/edit.html.haml
@@ -0,0 +1,5 @@
+= render "projects/header", :project => @project, :tab => "edit"
+
+%h2 Edit iFrame
+
+= render "form"
View
5 app/views/iframes/new.html.haml
@@ -0,0 +1,5 @@
+= render "projects/header", :project => @project, :tab => "edit"
+
+%h2 New iFrame
+
+= render "form"
View
3  app/views/iframes/show.html.haml
@@ -0,0 +1,3 @@
+= render "projects/header", :project => @project, :tab => @iframe.to_param
+
+%iframe{:src => @iframe.url}
View
10 app/views/projects/_header.html.haml
@@ -7,12 +7,6 @@
%ul.tabs
%li{active_when(tab == "overview")}= link_to "Overview", project
- %li{active_when(tab == "rspec")}= link_to "RSpec", project_rspec_path(project)
- %li{active_when(tab == "cucumber")}= link_to "Cucumber", project_cucumber_path(project)
- %li{active_when(tab == "coverage")}= link_to "Coverage", project_coverage_path(project)
- %li{active_when(tab == "commits")}= link_to "Commits", project
- %li{active_when(tab == "errors")}= link_to "Errors", project
- %li{active_when(tab == "builds")}= link_to "Builds", project
- %li{active_when(tab == "stats")}= link_to "Builds", project
- %li{active_when(tab == "tracker")}= link_to "Tracker", project
+ - project.iframes.list.each do |iframe|
+ %li{active_when(tab == iframe.to_param)}= link_to iframe.name, [ project, iframe ]
%li{active_when(tab == "edit")}= link_to "Edit", edit_project_path(project)
View
12 app/views/projects/edit.html.haml
@@ -7,10 +7,14 @@
%fieldset
%legend iFrames Galore!
- = f.input :rspec_url
- = f.input :cucumber_url
- = f.input :coverage_url
+ %ul.iframes
+ - @project.iframes.list.each do |iframe|
+ %li
+ = link_to iframe.name, [ :edit, @project, iframe ]
+ (#{iframe.url.truncate(100)})
+ %li.new= link_to "new iframe", new_project_iframe_path(@project)
= render "shared/actions", :f => f
-.well= link_to "Delete Project", project_path(@project), :method => :delete, :class => "btn danger", :confirm => "Damn, girl! Are you sure?"
+.well
+ = link_to "Delete Project", project_path(@project), :method => :delete, :class => "btn danger", :confirm => "Damn, girl! Are you sure?"
View
13 app/views/rspec/show.html.haml
@@ -1,13 +0,0 @@
-= render "projects/header", :project => @project, :tab => "rspec"
-
-- if @project.rspec_url?
- %iframe#rspec-frame{:src => @project.rspec_url}
-- else
-
- .alert-message.warning.fade.in{data("alert")}
- = link_to "×", "#", :class => "close"
- %p You haven't specified an RSpec URL yet
-
- = simple_form_for @project, :wrapper => :inline do |f|
- = f.input :rspec_url, :required => true
- = render "shared/actions", :f => f
View
11 config/locales/coverage.yml
@@ -1,11 +0,0 @@
-en:
- simple_form:
- labels:
- project:
- coverage_url: Coverage URL
- placeholders:
- project:
- coverage_url: "https://..."
- hints:
- project:
- coverage_url: "Probably: https://www.intranet.finalist.com/hudson/job/JOB_NAME/lastSuccessfulBuild/artifact/coverage/index.html"
View
11 config/locales/cucumber.yml
@@ -1,11 +0,0 @@
-en:
- simple_form:
- labels:
- project:
- cucumber_url: Cucumber URL
- placeholders:
- project:
- cucumber_url: "https://..."
- hints:
- project:
- cucumber_url: "Probably: https://www.intranet.finalist.com/hudson/job/JOB_NAME/ws/cucumber.html"
View
9 config/locales/iframes.yml
@@ -0,0 +1,9 @@
+en:
+ activerecord:
+ models:
+ iframe:
+ one: iFrame
+ other: iFrames
+ attributes:
+ iframe:
+ url: URL
View
11 config/locales/rspec.yml
@@ -1,11 +0,0 @@
-en:
- simple_form:
- labels:
- project:
- rspec_url: RSpec URL
- placeholders:
- project:
- rspec_url: "https://..."
- hints:
- project:
- rspec_url: "Probably: https://www.intranet.finalist.com/hudson/job/JOB_NAME/ws/rspec.html"
View
4 config/routes.rb
@@ -4,9 +4,7 @@
resources :projects do
- get "rspec" => "rspec#show"
- get "cucumber" => "cucumber#show"
- get "coverage" => "coverage#show"
+ resources :iframes
end
View
8 db/migrate/20120115181329_add_rspec_and_cucumber_paths_to_projects.rb
@@ -1,8 +0,0 @@
-class AddRspecAndCucumberPathsToProjects < ActiveRecord::Migration
- def change
- add_column :projects, :rspec_url, :string
-
- add_column :projects, :cucumber_url, :string
-
- end
-end
View
6 db/migrate/20120115230959_add_coverage_url_to_projects.rb
@@ -1,6 +0,0 @@
-class AddCoverageUrlToProjects < ActiveRecord::Migration
- def change
- add_column :projects, :coverage_url, :string
-
- end
-end
View
14 db/migrate/20120115232627_create_iframes.rb
@@ -0,0 +1,14 @@
+class CreateIframes < ActiveRecord::Migration
+ def change
+ create_table :iframes do |t|
+ t.string :name
+ t.string :slug
+ t.string :url
+ t.integer :project_id
+
+ t.timestamps
+ end
+ add_index :iframes, :slug
+ add_index :iframes, :project_id
+ end
+end
View
21 db/schema.rb
@@ -11,17 +11,26 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120115230959) do
+ActiveRecord::Schema.define(:version => 20120115232627) do
+
+ create_table "iframes", :force => true do |t|
+ t.string "name"
+ t.string "slug"
+ t.string "url"
+ t.integer "project_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "iframes", ["project_id"], :name => "index_iframes_on_project_id"
+ add_index "iframes", ["slug"], :name => "index_iframes_on_slug"
create_table "projects", :force => true do |t|
t.string "project"
t.string "name"
t.string "slug"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "rspec_url"
- t.string "cucumber_url"
- t.string "coverage_url"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
add_index "projects", ["slug"], :name => "index_projects_on_slug"
View
5 spec/controllers/coverage_controller_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe CoverageController do
-
-end
View
5 spec/controllers/cucumber_controller_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe CucumberController do
-
-end
View
5 spec/controllers/iframes_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe IframesController do
+
+end
View
5 spec/controllers/rspec_controller_spec.rb
@@ -1,5 +0,0 @@
-require 'spec_helper'
-
-describe RspecController do
-
-end
View
9 spec/factories/iframes.rb
@@ -0,0 +1,9 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :iframe do
+ name "MyString"
+ slug "MyString"
+ url "MyString"
+ end
+end
View
5 spec/models/iframe_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Iframe do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.