kuztuscms 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. data/.gitignore +9 -0
  2. data/.rvmrc +55 -0
  3. data/Gemfile +18 -0
  4. data/Gemfile.lock +156 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +12 -0
  7. data/Rakefile +29 -0
  8. data/app/assets/images/kuztuscms/.gitkeep +0 -0
  9. data/app/assets/images/kuztuscms/glyphicons-halflings-white.png +0 -0
  10. data/app/assets/images/kuztuscms/glyphicons-halflings.png +0 -0
  11. data/app/assets/javascripts/kuztuscms/.DS_Store +0 -0
  12. data/app/assets/javascripts/kuztuscms/application.js +15 -0
  13. data/app/assets/javascripts/kuztuscms/bootstrap.js +1720 -0
  14. data/app/assets/javascripts/kuztuscms/codemirror-compressed.js +1 -0
  15. data/app/assets/stylesheets/kuztuscms/.DS_Store +0 -0
  16. data/app/assets/stylesheets/kuztuscms/application.css.scss +16 -0
  17. data/app/assets/stylesheets/kuztuscms/bootstrap-responsive.css +581 -0
  18. data/app/assets/stylesheets/kuztuscms/bootstrap.css +3496 -0
  19. data/app/assets/stylesheets/kuztuscms/codemirror.css +115 -0
  20. data/app/controllers/kuztuscms/articles_controller.rb +53 -0
  21. data/app/controllers/kuztuscms/home_controller.rb +6 -0
  22. data/app/controllers/kuztuscms/layouts_controller.rb +75 -0
  23. data/app/controllers/kuztuscms/pages_controller.rb +73 -0
  24. data/app/controllers/kuztuscms/settings_controller.rb +48 -0
  25. data/app/controllers/kuztuscms/templates_controller.rb +72 -0
  26. data/app/controllers/kuztuscms/users_controller.rb +74 -0
  27. data/app/controllers/kuztuscms_controller.rb +23 -0
  28. data/app/helpers/kuztuscms/application_helper.rb +4 -0
  29. data/app/models/kuztuscms/article.rb +4 -0
  30. data/app/models/kuztuscms/layout.rb +14 -0
  31. data/app/models/kuztuscms/page.rb +8 -0
  32. data/app/models/kuztuscms/setting.rb +11 -0
  33. data/app/models/kuztuscms/template.rb +14 -0
  34. data/app/models/kuztuscms/user.rb +20 -0
  35. data/app/views/devise/_links.erb +27 -0
  36. data/app/views/devise/confirmations/new.html.erb +12 -0
  37. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  38. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  39. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  40. data/app/views/devise/passwords/edit.html.erb +16 -0
  41. data/app/views/devise/passwords/new.html.erb +18 -0
  42. data/app/views/devise/registrations/edit.html.erb +25 -0
  43. data/app/views/devise/registrations/new.html.erb +21 -0
  44. data/app/views/devise/sessions/new.html.erb +31 -0
  45. data/app/views/devise/unlocks/new.html.erb +19 -0
  46. data/app/views/kuztuscms/articles/_form.html.erb +35 -0
  47. data/app/views/kuztuscms/articles/edit.html.erb +1 -0
  48. data/app/views/kuztuscms/articles/index.html.erb +22 -0
  49. data/app/views/kuztuscms/articles/new.html.erb +1 -0
  50. data/app/views/kuztuscms/articles/show.html.erb +4 -0
  51. data/app/views/kuztuscms/home/index.html.erb +1 -0
  52. data/app/views/kuztuscms/layouts/_form.html.erb +58 -0
  53. data/app/views/kuztuscms/layouts/edit.html.erb +2 -0
  54. data/app/views/kuztuscms/layouts/index.html.erb +32 -0
  55. data/app/views/kuztuscms/layouts/new.html.erb +2 -0
  56. data/app/views/kuztuscms/pages/_form.html.erb +72 -0
  57. data/app/views/kuztuscms/pages/edit.html.erb +1 -0
  58. data/app/views/kuztuscms/pages/index.html.erb +28 -0
  59. data/app/views/kuztuscms/pages/new.html.erb +1 -0
  60. data/app/views/kuztuscms/pages/show.html.erb +1 -0
  61. data/app/views/kuztuscms/settings/_form.html.erb +35 -0
  62. data/app/views/kuztuscms/settings/edit.html.erb +1 -0
  63. data/app/views/kuztuscms/settings/index.html.erb +24 -0
  64. data/app/views/kuztuscms/settings/new.html.erb +1 -0
  65. data/app/views/kuztuscms/shared/_codemirror.html.erb +20 -0
  66. data/app/views/kuztuscms/templates/_form.html.erb +58 -0
  67. data/app/views/kuztuscms/templates/edit.html.erb +3 -0
  68. data/app/views/kuztuscms/templates/index.html.erb +28 -0
  69. data/app/views/kuztuscms/templates/new.html.erb +2 -0
  70. data/app/views/kuztuscms/users/_form.html.erb +56 -0
  71. data/app/views/kuztuscms/users/edit.html.erb +1 -0
  72. data/app/views/kuztuscms/users/index.html.erb +28 -0
  73. data/app/views/kuztuscms/users/new.html.erb +1 -0
  74. data/app/views/kuztuscms/users/show.html.erb +15 -0
  75. data/app/views/layouts/kuztuscms/application.html.erb +57 -0
  76. data/config/initializers/devise.rb +225 -0
  77. data/config/initializers/resolver.rb +65 -0
  78. data/config/locales/devise.en.yml +57 -0
  79. data/config/locales/en.yml +5 -0
  80. data/config/routes.rb +18 -0
  81. data/db/migrate/20120218074040_devise_create_kuztuscms_users.rb +52 -0
  82. data/db/migrate/20120218075211_create_kuztuscms_pages.rb +15 -0
  83. data/db/migrate/20120311080242_create_kuztuscms_templates.rb +38 -0
  84. data/db/migrate/20120311141419_create_kuztuscms_articles.rb +10 -0
  85. data/db/migrate/20120311173954_create_kuztuscms_layouts.rb +43 -0
  86. data/db/migrate/20120316081613_create_kuztuscms_settings.rb +10 -0
  87. data/kuztuscms.gemspec +33 -0
  88. data/lib/kuztuscms/engine.rb +13 -0
  89. data/lib/kuztuscms/settings.rb +26 -0
  90. data/lib/kuztuscms/version.rb +3 -0
  91. data/lib/kuztuscms.rb +7 -0
  92. data/lib/tasks/kuztuscms_tasks.rake +4 -0
  93. data/script/rails +8 -0
  94. data/spec/controllers/kuztuscms/articles_controller_spec.rb +164 -0
  95. data/spec/controllers/kuztuscms/languages_controller_spec.rb +164 -0
  96. data/spec/controllers/kuztuscms/layouts_controller_spec.rb +164 -0
  97. data/spec/controllers/kuztuscms/pages_controller_spec.rb +164 -0
  98. data/spec/controllers/kuztuscms/settings_controller_spec.rb +164 -0
  99. data/spec/controllers/kuztuscms/templates_controller_spec.rb +164 -0
  100. data/spec/controllers/kuztuscms/translations_controller_spec.rb +164 -0
  101. data/spec/dummy/README.rdoc +261 -0
  102. data/spec/dummy/Rakefile +7 -0
  103. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  104. data/spec/dummy/app/assets/javascripts/home.js +2 -0
  105. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  106. data/spec/dummy/app/assets/stylesheets/home.css +4 -0
  107. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  108. data/spec/dummy/app/controllers/home_controller.rb +4 -0
  109. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  110. data/spec/dummy/app/helpers/home_helper.rb +2 -0
  111. data/spec/dummy/app/mailers/.gitkeep +0 -0
  112. data/spec/dummy/app/models/.gitkeep +0 -0
  113. data/spec/dummy/app/views/home/index.html.erb +3 -0
  114. data/spec/dummy/app/views/layouts/application.html.erb +16 -0
  115. data/spec/dummy/config/application.rb +62 -0
  116. data/spec/dummy/config/boot.rb +10 -0
  117. data/spec/dummy/config/database.yml +25 -0
  118. data/spec/dummy/config/environment.rb +5 -0
  119. data/spec/dummy/config/environments/development.rb +38 -0
  120. data/spec/dummy/config/environments/production.rb +67 -0
  121. data/spec/dummy/config/environments/test.rb +37 -0
  122. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  123. data/spec/dummy/config/initializers/inflections.rb +15 -0
  124. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  125. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  126. data/spec/dummy/config/initializers/session_store.rb +8 -0
  127. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  128. data/spec/dummy/config/locales/en.yml +9 -0
  129. data/spec/dummy/config/locales/ru.yml +5 -0
  130. data/spec/dummy/config/routes.rb +8 -0
  131. data/spec/dummy/config.ru +4 -0
  132. data/spec/dummy/db/migrate/20120313083011_devise_create_kuztuscms_users.kuztuscms.rb +59 -0
  133. data/spec/dummy/db/migrate/20120313083012_create_kuztuscms_pages.kuztuscms.rb +16 -0
  134. data/spec/dummy/db/migrate/20120313083013_create_kuztuscms_templates.kuztuscms.rb +15 -0
  135. data/spec/dummy/db/migrate/20120313083014_create_kuztuscms_articles.kuztuscms.rb +11 -0
  136. data/spec/dummy/db/migrate/20120313083015_create_kuztuscms_layouts.kuztuscms.rb +41 -0
  137. data/spec/dummy/db/migrate/20120316084434_create_kuztuscms_settings.kuztuscms.rb +11 -0
  138. data/spec/dummy/db/schema.rb +90 -0
  139. data/spec/dummy/lib/assets/.gitkeep +0 -0
  140. data/spec/dummy/log/.gitkeep +0 -0
  141. data/spec/dummy/public/404.html +26 -0
  142. data/spec/dummy/public/422.html +26 -0
  143. data/spec/dummy/public/500.html +25 -0
  144. data/spec/dummy/public/favicon.ico +0 -0
  145. data/spec/dummy/script/rails +6 -0
  146. data/spec/helpers/kuztuscms/articles_helper_spec.rb +15 -0
  147. data/spec/helpers/kuztuscms/languages_helper_spec.rb +15 -0
  148. data/spec/helpers/kuztuscms/layouts_helper_spec.rb +15 -0
  149. data/spec/helpers/kuztuscms/pages_helper_spec.rb +15 -0
  150. data/spec/helpers/kuztuscms/settings_helper_spec.rb +15 -0
  151. data/spec/helpers/kuztuscms/templates_helper_spec.rb +15 -0
  152. data/spec/helpers/kuztuscms/translations_helper_spec.rb +15 -0
  153. data/spec/models/kuztuscms/article_spec.rb +5 -0
  154. data/spec/models/kuztuscms/language_spec.rb +5 -0
  155. data/spec/models/kuztuscms/layout_spec.rb +5 -0
  156. data/spec/models/kuztuscms/page_spec.rb +5 -0
  157. data/spec/models/kuztuscms/setting_spec.rb +5 -0
  158. data/spec/models/kuztuscms/template_spec.rb +5 -0
  159. data/spec/models/kuztuscms/translation_spec.rb +5 -0
  160. data/spec/models/kuztuscms/user_spec.rb +5 -0
  161. data/spec/routing/kuztuscms/articles_routing_spec.rb +35 -0
  162. data/spec/routing/kuztuscms/languages_routing_spec.rb +35 -0
  163. data/spec/routing/kuztuscms/layouts_routing_spec.rb +35 -0
  164. data/spec/routing/kuztuscms/pages_routing_spec.rb +35 -0
  165. data/spec/routing/kuztuscms/settings_routing_spec.rb +35 -0
  166. data/spec/routing/kuztuscms/templates_routing_spec.rb +35 -0
  167. data/spec/routing/kuztuscms/translations_routing_spec.rb +35 -0
  168. data/spec/views/kuztuscms/articles/edit.html.erb_spec.rb +20 -0
  169. data/spec/views/kuztuscms/articles/index.html.erb_spec.rb +24 -0
  170. data/spec/views/kuztuscms/articles/new.html.erb_spec.rb +20 -0
  171. data/spec/views/kuztuscms/articles/show.html.erb_spec.rb +18 -0
  172. data/spec/views/kuztuscms/languages/edit.html.erb_spec.rb +22 -0
  173. data/spec/views/kuztuscms/languages/index.html.erb_spec.rb +28 -0
  174. data/spec/views/kuztuscms/languages/new.html.erb_spec.rb +22 -0
  175. data/spec/views/kuztuscms/languages/show.html.erb_spec.rb +21 -0
  176. data/spec/views/kuztuscms/layouts/edit.html.erb_spec.rb +20 -0
  177. data/spec/views/kuztuscms/layouts/index.html.erb_spec.rb +24 -0
  178. data/spec/views/kuztuscms/layouts/new.html.erb_spec.rb +20 -0
  179. data/spec/views/kuztuscms/layouts/show.html.erb_spec.rb +18 -0
  180. data/spec/views/kuztuscms/pages/edit.html.erb_spec.rb +15 -0
  181. data/spec/views/kuztuscms/pages/index.html.erb_spec.rb +14 -0
  182. data/spec/views/kuztuscms/pages/new.html.erb_spec.rb +15 -0
  183. data/spec/views/kuztuscms/pages/show.html.erb_spec.rb +11 -0
  184. data/spec/views/kuztuscms/settings/edit.html.erb_spec.rb +20 -0
  185. data/spec/views/kuztuscms/settings/index.html.erb_spec.rb +24 -0
  186. data/spec/views/kuztuscms/settings/new.html.erb_spec.rb +20 -0
  187. data/spec/views/kuztuscms/settings/show.html.erb_spec.rb +18 -0
  188. data/spec/views/kuztuscms/templates/edit.html.erb_spec.rb +28 -0
  189. data/spec/views/kuztuscms/templates/index.html.erb_spec.rb +40 -0
  190. data/spec/views/kuztuscms/templates/new.html.erb_spec.rb +28 -0
  191. data/spec/views/kuztuscms/templates/show.html.erb_spec.rb +30 -0
  192. data/spec/views/kuztuscms/translations/edit.html.erb_spec.rb +28 -0
  193. data/spec/views/kuztuscms/translations/index.html.erb_spec.rb +40 -0
  194. data/spec/views/kuztuscms/translations/new.html.erb_spec.rb +28 -0
  195. data/spec/views/kuztuscms/translations/show.html.erb_spec.rb +30 -0
  196. data/test/integration/kuztuscms/setting_test.rb +7 -0
  197. metadata +351 -0
@@ -0,0 +1,43 @@
1
+ class CreateKuztuscmsLayouts < ActiveRecord::Migration
2
+ def change
3
+ create_table :kuztuscms_layouts do |t|
4
+ t.text :body
5
+ t.string :path
6
+ t.string :format
7
+ t.string :locale
8
+ t.string :handler
9
+ t.boolean :partial, :default => false
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ body = <<EOF
15
+ <!DOCTYPE html>
16
+ <html>
17
+ <head>
18
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
+ <meta name="keywords" content="<%= @page.keywords %>" />
20
+ <meta name="description" content="<%= @page.description %>" />
21
+ <title><%= @page.title %></title>
22
+ <%= stylesheet_link_tag "application", :media => "all" %>
23
+ <%= javascript_include_tag "application" %>
24
+ <%= csrf_meta_tags %>
25
+ </head>
26
+ <body>
27
+ <%= render 'google-analytics' %>
28
+ <p class=notice><%= notice %></p>
29
+ <p class=alert><%= alert %></p>
30
+ <%= yield %>
31
+ </body>
32
+ </html>
33
+ EOF
34
+ Kuztuscms::Layout.create(
35
+ :body => body,
36
+ :path => 'default',
37
+ :format => 'html',
38
+ :locale => 'en',
39
+ :handler => 'erb',
40
+ :partial => false
41
+ )
42
+ end
43
+ end
@@ -0,0 +1,10 @@
1
+ class CreateKuztuscmsSettings < ActiveRecord::Migration
2
+ def change
3
+ create_table :kuztuscms_settings do |t|
4
+ t.string :key
5
+ t.string :value
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
data/kuztuscms.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "kuztuscms/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "kuztuscms"
9
+ s.version = Kuztuscms::VERSION
10
+ s.authors = ["Arturs Kreipans"]
11
+ s.email = ["dummy@email.com"]
12
+ s.homepage = "http://github.com/fragallia/kuztuscms"
13
+ s.summary = "KuztusCMS for rails >= 3.1"
14
+ s.description = "KuztusCMS for rails >= 3.1"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+
18
+ s.add_dependency "rails"
19
+ s.add_dependency 'sass-rails'
20
+ s.add_dependency 'coffee-rails'
21
+ s.add_dependency 'uglifier'
22
+ s.add_dependency "devise"
23
+
24
+ # Things that devise needs.
25
+ s.add_dependency 'tzinfo'
26
+ s.add_dependency 'omniauth'
27
+ s.add_dependency 'actionmailer'
28
+ # s.add_dependency "jquery-rails"
29
+
30
+ s.add_development_dependency "sqlite3"
31
+ s.add_development_dependency 'rspec-rails'
32
+
33
+ end
@@ -0,0 +1,13 @@
1
+ module Kuztuscms
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Kuztuscms
4
+
5
+ config.generators do |g|
6
+ g.orm :active_record
7
+ g.template_engine :erb
8
+ g.test_framework :rspec
9
+ g.stylesheet_engine :scss
10
+ g.javascript_engine :coffee
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ module Kuztuscms
2
+ class Settings
3
+ class << self
4
+ def set(key, value)
5
+ Kuztuscms::Setting.create!(:key => key, :value => value)
6
+ self.clear_cache
7
+ end
8
+
9
+ def clear_cache
10
+ @cache = nil
11
+ end
12
+
13
+ def get(key)
14
+ unless @cache
15
+ @cache = Kuztuscms::Setting.all.inject({}) do |res, setting|
16
+ res[setting.key] = setting.value
17
+
18
+ res
19
+ end
20
+ end
21
+
22
+ @cache[key]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Kuztuscms
2
+ VERSION = "0.0.1"
3
+ end
data/lib/kuztuscms.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'rails'
2
+ require 'devise'
3
+ require "kuztuscms/engine"
4
+
5
+ module Kuztuscms
6
+ autoload :Settings, 'kuztuscms/settings'
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :kuztuscms do
3
+ # # Task goes here
4
+ # end
data/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/kuztuscms/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,164 @@
1
+ require 'spec_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
20
+
21
+ describe ArticlesController do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # Article. As you add validations to Article, be sure to
25
+ # update the return value of this method accordingly.
26
+ def valid_attributes
27
+ {}
28
+ end
29
+
30
+ # This should return the minimal set of values that should be in the session
31
+ # in order to pass any filters (e.g. authentication) defined in
32
+ # ArticlesController. Be sure to keep this updated too.
33
+ def valid_session
34
+ {}
35
+ end
36
+
37
+ describe "GET index" do
38
+ it "assigns all articles as @articles" do
39
+ article = Article.create! valid_attributes
40
+ get :index, {}, valid_session
41
+ assigns(:articles).should eq([article])
42
+ end
43
+ end
44
+
45
+ describe "GET show" do
46
+ it "assigns the requested article as @article" do
47
+ article = Article.create! valid_attributes
48
+ get :show, {:id => article.to_param}, valid_session
49
+ assigns(:article).should eq(article)
50
+ end
51
+ end
52
+
53
+ describe "GET new" do
54
+ it "assigns a new article as @article" do
55
+ get :new, {}, valid_session
56
+ assigns(:article).should be_a_new(Article)
57
+ end
58
+ end
59
+
60
+ describe "GET edit" do
61
+ it "assigns the requested article as @article" do
62
+ article = Article.create! valid_attributes
63
+ get :edit, {:id => article.to_param}, valid_session
64
+ assigns(:article).should eq(article)
65
+ end
66
+ end
67
+
68
+ describe "POST create" do
69
+ describe "with valid params" do
70
+ it "creates a new Article" do
71
+ expect {
72
+ post :create, {:article => valid_attributes}, valid_session
73
+ }.to change(Article, :count).by(1)
74
+ end
75
+
76
+ it "assigns a newly created article as @article" do
77
+ post :create, {:article => valid_attributes}, valid_session
78
+ assigns(:article).should be_a(Article)
79
+ assigns(:article).should be_persisted
80
+ end
81
+
82
+ it "redirects to the created article" do
83
+ post :create, {:article => valid_attributes}, valid_session
84
+ response.should redirect_to(Article.last)
85
+ end
86
+ end
87
+
88
+ describe "with invalid params" do
89
+ it "assigns a newly created but unsaved article as @article" do
90
+ # Trigger the behavior that occurs when invalid params are submitted
91
+ Article.any_instance.stub(:save).and_return(false)
92
+ post :create, {:article => {}}, valid_session
93
+ assigns(:article).should be_a_new(Article)
94
+ end
95
+
96
+ it "re-renders the 'new' template" do
97
+ # Trigger the behavior that occurs when invalid params are submitted
98
+ Article.any_instance.stub(:save).and_return(false)
99
+ post :create, {:article => {}}, valid_session
100
+ response.should render_template("new")
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "PUT update" do
106
+ describe "with valid params" do
107
+ it "updates the requested article" do
108
+ article = Article.create! valid_attributes
109
+ # Assuming there are no other articles in the database, this
110
+ # specifies that the Article created on the previous line
111
+ # receives the :update_attributes message with whatever params are
112
+ # submitted in the request.
113
+ Article.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
114
+ put :update, {:id => article.to_param, :article => {'these' => 'params'}}, valid_session
115
+ end
116
+
117
+ it "assigns the requested article as @article" do
118
+ article = Article.create! valid_attributes
119
+ put :update, {:id => article.to_param, :article => valid_attributes}, valid_session
120
+ assigns(:article).should eq(article)
121
+ end
122
+
123
+ it "redirects to the article" do
124
+ article = Article.create! valid_attributes
125
+ put :update, {:id => article.to_param, :article => valid_attributes}, valid_session
126
+ response.should redirect_to(article)
127
+ end
128
+ end
129
+
130
+ describe "with invalid params" do
131
+ it "assigns the article as @article" do
132
+ article = Article.create! valid_attributes
133
+ # Trigger the behavior that occurs when invalid params are submitted
134
+ Article.any_instance.stub(:save).and_return(false)
135
+ put :update, {:id => article.to_param, :article => {}}, valid_session
136
+ assigns(:article).should eq(article)
137
+ end
138
+
139
+ it "re-renders the 'edit' template" do
140
+ article = Article.create! valid_attributes
141
+ # Trigger the behavior that occurs when invalid params are submitted
142
+ Article.any_instance.stub(:save).and_return(false)
143
+ put :update, {:id => article.to_param, :article => {}}, valid_session
144
+ response.should render_template("edit")
145
+ end
146
+ end
147
+ end
148
+
149
+ describe "DELETE destroy" do
150
+ it "destroys the requested article" do
151
+ article = Article.create! valid_attributes
152
+ expect {
153
+ delete :destroy, {:id => article.to_param}, valid_session
154
+ }.to change(Article, :count).by(-1)
155
+ end
156
+
157
+ it "redirects to the articles list" do
158
+ article = Article.create! valid_attributes
159
+ delete :destroy, {:id => article.to_param}, valid_session
160
+ response.should redirect_to(articles_url)
161
+ end
162
+ end
163
+
164
+ end
@@ -0,0 +1,164 @@
1
+ require 'spec_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
20
+
21
+ describe LanguagesController do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # Language. As you add validations to Language, be sure to
25
+ # update the return value of this method accordingly.
26
+ def valid_attributes
27
+ {}
28
+ end
29
+
30
+ # This should return the minimal set of values that should be in the session
31
+ # in order to pass any filters (e.g. authentication) defined in
32
+ # LanguagesController. Be sure to keep this updated too.
33
+ def valid_session
34
+ {}
35
+ end
36
+
37
+ describe "GET index" do
38
+ it "assigns all languages as @languages" do
39
+ language = Language.create! valid_attributes
40
+ get :index, {}, valid_session
41
+ assigns(:languages).should eq([language])
42
+ end
43
+ end
44
+
45
+ describe "GET show" do
46
+ it "assigns the requested language as @language" do
47
+ language = Language.create! valid_attributes
48
+ get :show, {:id => language.to_param}, valid_session
49
+ assigns(:language).should eq(language)
50
+ end
51
+ end
52
+
53
+ describe "GET new" do
54
+ it "assigns a new language as @language" do
55
+ get :new, {}, valid_session
56
+ assigns(:language).should be_a_new(Language)
57
+ end
58
+ end
59
+
60
+ describe "GET edit" do
61
+ it "assigns the requested language as @language" do
62
+ language = Language.create! valid_attributes
63
+ get :edit, {:id => language.to_param}, valid_session
64
+ assigns(:language).should eq(language)
65
+ end
66
+ end
67
+
68
+ describe "POST create" do
69
+ describe "with valid params" do
70
+ it "creates a new Language" do
71
+ expect {
72
+ post :create, {:language => valid_attributes}, valid_session
73
+ }.to change(Language, :count).by(1)
74
+ end
75
+
76
+ it "assigns a newly created language as @language" do
77
+ post :create, {:language => valid_attributes}, valid_session
78
+ assigns(:language).should be_a(Language)
79
+ assigns(:language).should be_persisted
80
+ end
81
+
82
+ it "redirects to the created language" do
83
+ post :create, {:language => valid_attributes}, valid_session
84
+ response.should redirect_to(Language.last)
85
+ end
86
+ end
87
+
88
+ describe "with invalid params" do
89
+ it "assigns a newly created but unsaved language as @language" do
90
+ # Trigger the behavior that occurs when invalid params are submitted
91
+ Language.any_instance.stub(:save).and_return(false)
92
+ post :create, {:language => {}}, valid_session
93
+ assigns(:language).should be_a_new(Language)
94
+ end
95
+
96
+ it "re-renders the 'new' template" do
97
+ # Trigger the behavior that occurs when invalid params are submitted
98
+ Language.any_instance.stub(:save).and_return(false)
99
+ post :create, {:language => {}}, valid_session
100
+ response.should render_template("new")
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "PUT update" do
106
+ describe "with valid params" do
107
+ it "updates the requested language" do
108
+ language = Language.create! valid_attributes
109
+ # Assuming there are no other languages in the database, this
110
+ # specifies that the Language created on the previous line
111
+ # receives the :update_attributes message with whatever params are
112
+ # submitted in the request.
113
+ Language.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
114
+ put :update, {:id => language.to_param, :language => {'these' => 'params'}}, valid_session
115
+ end
116
+
117
+ it "assigns the requested language as @language" do
118
+ language = Language.create! valid_attributes
119
+ put :update, {:id => language.to_param, :language => valid_attributes}, valid_session
120
+ assigns(:language).should eq(language)
121
+ end
122
+
123
+ it "redirects to the language" do
124
+ language = Language.create! valid_attributes
125
+ put :update, {:id => language.to_param, :language => valid_attributes}, valid_session
126
+ response.should redirect_to(language)
127
+ end
128
+ end
129
+
130
+ describe "with invalid params" do
131
+ it "assigns the language as @language" do
132
+ language = Language.create! valid_attributes
133
+ # Trigger the behavior that occurs when invalid params are submitted
134
+ Language.any_instance.stub(:save).and_return(false)
135
+ put :update, {:id => language.to_param, :language => {}}, valid_session
136
+ assigns(:language).should eq(language)
137
+ end
138
+
139
+ it "re-renders the 'edit' template" do
140
+ language = Language.create! valid_attributes
141
+ # Trigger the behavior that occurs when invalid params are submitted
142
+ Language.any_instance.stub(:save).and_return(false)
143
+ put :update, {:id => language.to_param, :language => {}}, valid_session
144
+ response.should render_template("edit")
145
+ end
146
+ end
147
+ end
148
+
149
+ describe "DELETE destroy" do
150
+ it "destroys the requested language" do
151
+ language = Language.create! valid_attributes
152
+ expect {
153
+ delete :destroy, {:id => language.to_param}, valid_session
154
+ }.to change(Language, :count).by(-1)
155
+ end
156
+
157
+ it "redirects to the languages list" do
158
+ language = Language.create! valid_attributes
159
+ delete :destroy, {:id => language.to_param}, valid_session
160
+ response.should redirect_to(languages_url)
161
+ end
162
+ end
163
+
164
+ end
@@ -0,0 +1,164 @@
1
+ require 'spec_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
20
+
21
+ describe LayoutsController do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # Layout. As you add validations to Layout, be sure to
25
+ # update the return value of this method accordingly.
26
+ def valid_attributes
27
+ {}
28
+ end
29
+
30
+ # This should return the minimal set of values that should be in the session
31
+ # in order to pass any filters (e.g. authentication) defined in
32
+ # LayoutsController. Be sure to keep this updated too.
33
+ def valid_session
34
+ {}
35
+ end
36
+
37
+ describe "GET index" do
38
+ it "assigns all layouts as @layouts" do
39
+ layout = Layout.create! valid_attributes
40
+ get :index, {}, valid_session
41
+ assigns(:layouts).should eq([layout])
42
+ end
43
+ end
44
+
45
+ describe "GET show" do
46
+ it "assigns the requested layout as @layout" do
47
+ layout = Layout.create! valid_attributes
48
+ get :show, {:id => layout.to_param}, valid_session
49
+ assigns(:layout).should eq(layout)
50
+ end
51
+ end
52
+
53
+ describe "GET new" do
54
+ it "assigns a new layout as @layout" do
55
+ get :new, {}, valid_session
56
+ assigns(:layout).should be_a_new(Layout)
57
+ end
58
+ end
59
+
60
+ describe "GET edit" do
61
+ it "assigns the requested layout as @layout" do
62
+ layout = Layout.create! valid_attributes
63
+ get :edit, {:id => layout.to_param}, valid_session
64
+ assigns(:layout).should eq(layout)
65
+ end
66
+ end
67
+
68
+ describe "POST create" do
69
+ describe "with valid params" do
70
+ it "creates a new Layout" do
71
+ expect {
72
+ post :create, {:layout => valid_attributes}, valid_session
73
+ }.to change(Layout, :count).by(1)
74
+ end
75
+
76
+ it "assigns a newly created layout as @layout" do
77
+ post :create, {:layout => valid_attributes}, valid_session
78
+ assigns(:layout).should be_a(Layout)
79
+ assigns(:layout).should be_persisted
80
+ end
81
+
82
+ it "redirects to the created layout" do
83
+ post :create, {:layout => valid_attributes}, valid_session
84
+ response.should redirect_to(Layout.last)
85
+ end
86
+ end
87
+
88
+ describe "with invalid params" do
89
+ it "assigns a newly created but unsaved layout as @layout" do
90
+ # Trigger the behavior that occurs when invalid params are submitted
91
+ Layout.any_instance.stub(:save).and_return(false)
92
+ post :create, {:layout => {}}, valid_session
93
+ assigns(:layout).should be_a_new(Layout)
94
+ end
95
+
96
+ it "re-renders the 'new' template" do
97
+ # Trigger the behavior that occurs when invalid params are submitted
98
+ Layout.any_instance.stub(:save).and_return(false)
99
+ post :create, {:layout => {}}, valid_session
100
+ response.should render_template("new")
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "PUT update" do
106
+ describe "with valid params" do
107
+ it "updates the requested layout" do
108
+ layout = Layout.create! valid_attributes
109
+ # Assuming there are no other layouts in the database, this
110
+ # specifies that the Layout created on the previous line
111
+ # receives the :update_attributes message with whatever params are
112
+ # submitted in the request.
113
+ Layout.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
114
+ put :update, {:id => layout.to_param, :layout => {'these' => 'params'}}, valid_session
115
+ end
116
+
117
+ it "assigns the requested layout as @layout" do
118
+ layout = Layout.create! valid_attributes
119
+ put :update, {:id => layout.to_param, :layout => valid_attributes}, valid_session
120
+ assigns(:layout).should eq(layout)
121
+ end
122
+
123
+ it "redirects to the layout" do
124
+ layout = Layout.create! valid_attributes
125
+ put :update, {:id => layout.to_param, :layout => valid_attributes}, valid_session
126
+ response.should redirect_to(layout)
127
+ end
128
+ end
129
+
130
+ describe "with invalid params" do
131
+ it "assigns the layout as @layout" do
132
+ layout = Layout.create! valid_attributes
133
+ # Trigger the behavior that occurs when invalid params are submitted
134
+ Layout.any_instance.stub(:save).and_return(false)
135
+ put :update, {:id => layout.to_param, :layout => {}}, valid_session
136
+ assigns(:layout).should eq(layout)
137
+ end
138
+
139
+ it "re-renders the 'edit' template" do
140
+ layout = Layout.create! valid_attributes
141
+ # Trigger the behavior that occurs when invalid params are submitted
142
+ Layout.any_instance.stub(:save).and_return(false)
143
+ put :update, {:id => layout.to_param, :layout => {}}, valid_session
144
+ response.should render_template("edit")
145
+ end
146
+ end
147
+ end
148
+
149
+ describe "DELETE destroy" do
150
+ it "destroys the requested layout" do
151
+ layout = Layout.create! valid_attributes
152
+ expect {
153
+ delete :destroy, {:id => layout.to_param}, valid_session
154
+ }.to change(Layout, :count).by(-1)
155
+ end
156
+
157
+ it "redirects to the layouts list" do
158
+ layout = Layout.create! valid_attributes
159
+ delete :destroy, {:id => layout.to_param}, valid_session
160
+ response.should redirect_to(layouts_url)
161
+ end
162
+ end
163
+
164
+ end