stiki 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +176 -0
- data/README.rdoc +65 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/project_monster_wiki/application.js +15 -0
- data/app/assets/javascripts/project_monster_wiki/authors.js +2 -0
- data/app/assets/javascripts/project_monster_wiki/pages.js +2 -0
- data/app/assets/javascripts/project_monster_wiki/spaces.js +2 -0
- data/app/assets/stylesheets/stiki/application.css.scss +17 -0
- data/app/assets/stylesheets/stiki/authors.css +4 -0
- data/app/assets/stylesheets/stiki/pages.css +54 -0
- data/app/assets/stylesheets/stiki/spaces.css +4 -0
- data/app/controllers/stiki/application_controller.rb +6 -0
- data/app/controllers/stiki/authors_controller.rb +6 -0
- data/app/controllers/stiki/pages_controller.rb +94 -0
- data/app/controllers/stiki/spaces_controller.rb +42 -0
- data/app/helpers/stiki/application_helper.rb +17 -0
- data/app/helpers/stiki/authors_helper.rb +4 -0
- data/app/helpers/stiki/pages_helper.rb +4 -0
- data/app/helpers/stiki/spaces_helper.rb +4 -0
- data/app/models/stiki/author.rb +9 -0
- data/app/models/stiki/page.rb +33 -0
- data/app/models/stiki/space.rb +16 -0
- data/app/views/stiki/pages/_form.html.erb +35 -0
- data/app/views/stiki/pages/edit.html.erb +13 -0
- data/app/views/stiki/pages/index.html.erb +51 -0
- data/app/views/stiki/pages/new.html.erb +13 -0
- data/app/views/stiki/pages/show.html.erb +86 -0
- data/app/views/stiki/spaces/index.html.erb +52 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20120731063610_create_stiki_spaces.rb +10 -0
- data/db/migrate/20120731063657_create_stiki_pages.rb +13 -0
- data/db/migrate/20120731063721_create_stiki_authors.rb +14 -0
- data/lib/stiki/authenticate/devise.rb +19 -0
- data/lib/stiki/authenticate.rb +7 -0
- data/lib/stiki/authorize/cancan.rb +9 -0
- data/lib/stiki/authorize.rb +7 -0
- data/lib/stiki/engine.rb +6 -0
- data/lib/stiki/model/map_author.rb +10 -0
- data/lib/stiki/model.rb +7 -0
- data/lib/stiki/version.rb +3 -0
- data/lib/stiki.rb +70 -0
- data/lib/tasks/stiki_tasks.rake +4 -0
- data/spec/controllers/stiki/pages_controller_spec.rb +82 -0
- data/spec/controllers/stiki/spaces_controller_spec.rb +43 -0
- data/spec/factories/pages.rb +7 -0
- data/spec/factories/spaces.rb +5 -0
- data/spec/lib/authenticate/devise_spec.rb +26 -0
- data/spec/lib/stiki_spec.rb +47 -0
- data/spec/models/stiki/author_spec.rb +6 -0
- data/spec/models/stiki/page_spec.rb +8 -0
- data/spec/models/stiki/space_spec.rb +7 -0
- data/spec/spec_helper.rb +77 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +18 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +22 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +46 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +69 -0
- data/test/dummy/log/test.log +59362 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/test_helper.rb +15 -0
- metadata +319 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
<fieldset>
|
2
|
+
|
3
|
+
<%- if page.errors %>
|
4
|
+
<div class="control-group error">
|
5
|
+
<%- page.errors.full_messages.each do |error| %>
|
6
|
+
<div class="error help-block">
|
7
|
+
<%= error %>
|
8
|
+
</div>
|
9
|
+
<% end -%>
|
10
|
+
</div>
|
11
|
+
<% end -%>
|
12
|
+
|
13
|
+
<div class="control-group">
|
14
|
+
<%= label_tag 'title', 'Title', :class => "control-label" %>
|
15
|
+
<div class="controls">
|
16
|
+
<input class="field input-xlarge span11" id="title" name="page[title]" value="<%= page.title %>" size="30" type="text">
|
17
|
+
</div>
|
18
|
+
<%= label_tag 'body', 'Body', :class => "control-label" %>
|
19
|
+
<div class="controls">
|
20
|
+
<textarea class="field input-xlarge span11" id="body" name="page[body]" rows="20"><%= page.body %></textarea>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<div class="form-actions">
|
24
|
+
<div class="span2">
|
25
|
+
<%= submit_tag "Save", :class => "btn btn-primary btn-large" %>
|
26
|
+
</div>
|
27
|
+
<div class="span2">
|
28
|
+
<% if page.id %>
|
29
|
+
<%= link_to 'Cancel', stiki_routes.space_page_path(@space, page), :class => 'btn' %>
|
30
|
+
<% else %>
|
31
|
+
<%= link_to 'Cancel', stiki_routes.space_pages_path(@space), :class => 'btn' %>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
</fieldset>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="row-fluid">
|
2
|
+
<div class="span8">
|
3
|
+
<div class="row-fluid well">
|
4
|
+
<h2>Edit <%= @page.title %></h2>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="row-fluid well">
|
8
|
+
<%= form_tag( stiki_routes.space_page_path(@space, @page), :class => 'form-horizontal', :method => :put) do |f| %>
|
9
|
+
<%= render( :partial => 'stiki/pages/form', :locals => { :f => f, :page => @page } ) %>
|
10
|
+
<% end -%>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
</div>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<div class="stiki">
|
2
|
+
<div class="page">
|
3
|
+
<div class="row-fluid">
|
4
|
+
<div class="span10 well">
|
5
|
+
<div class="span9">
|
6
|
+
<h1><%= @space.name %> Pages</h1>
|
7
|
+
</div>
|
8
|
+
<div class="span3">
|
9
|
+
<ul class="breadcrumb">
|
10
|
+
<li>
|
11
|
+
<div class="btn-group">
|
12
|
+
<button class="btn dropdown-toggle" data-toggle="dropdown">Change Space<span class="caret"></span></button>
|
13
|
+
<ul class="dropdown-menu">
|
14
|
+
<li><a href="<%= stiki_routes.spaces_path %>">All Spaces</a></li>
|
15
|
+
<%- @spaces.each do |space| %>
|
16
|
+
<li><a href="<%= stiki_routes.space_pages_path(space) %>"><%= space.name %></a></li>
|
17
|
+
<% end -%>
|
18
|
+
</ul>
|
19
|
+
</div>
|
20
|
+
</li>
|
21
|
+
</ul>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<div class="row-fluid">
|
26
|
+
<div class="span10 well">
|
27
|
+
<ul class="nav nav-list page-list">
|
28
|
+
<%- @pages.each do |page| %>
|
29
|
+
<li>
|
30
|
+
<%= link_to page.title, stiki_routes.space_page_path(@space, page), :class => "span11" %>
|
31
|
+
|
32
|
+
<%- if has_access( :delete, @page ) %>
|
33
|
+
<%= button_to "X", stiki_routes.space_page_path( @space, page ), :method => :delete,
|
34
|
+
:class => 'close', :confirm => 'Are you sure you want to delete this Wiki Page?' %>
|
35
|
+
<% end -%>
|
36
|
+
|
37
|
+
</li>
|
38
|
+
<li class="clear"></li>
|
39
|
+
<% end -%>
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
<%- if has_access( :create, Stiki::Page ) %>
|
44
|
+
<div class="row-fluid">
|
45
|
+
<div class="span10 well">
|
46
|
+
<%= link_to 'Create Page', stiki_routes.new_space_page_path(@space), :class => 'btn-large btn btn-success' %>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
<% end -%>
|
50
|
+
</div>
|
51
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="row-fluid">
|
2
|
+
<div class="span8">
|
3
|
+
<div class="row-fluid well">
|
4
|
+
<h2>New Page in <%= @space.name %></h2>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<div class="row-fluid well">
|
8
|
+
<%= form_tag( stiki_routes.space_pages_path(@space), :class => 'form-horizontal' ) do |f| %>
|
9
|
+
<%= render( :partial => 'stiki/pages/form', :locals => { :f => f, :page => @page } ) %>
|
10
|
+
<% end -%>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
</div>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<div class="stiki">
|
2
|
+
<div class="row-fluid page">
|
3
|
+
<div class="span12 well">
|
4
|
+
<div class="row-fluid">
|
5
|
+
<div class="span7 title">
|
6
|
+
<h1>
|
7
|
+
<%= link_to '<i class="icon-chevron-left"></i>'.html_safe, stiki_routes.space_pages_path(@space) %>
|
8
|
+
<%= @page.title %>
|
9
|
+
</h1>
|
10
|
+
</div>
|
11
|
+
<div class="span5">
|
12
|
+
<ul class="breadcrumb">
|
13
|
+
<li>
|
14
|
+
<span class="divider">/</span>
|
15
|
+
</li>
|
16
|
+
<li>
|
17
|
+
<div class="btn-group">
|
18
|
+
<button class="btn dropdown-toggle" data-toggle="dropdown"><%= @space.name %> <span class="caret"></span></button>
|
19
|
+
<ul class="dropdown-menu">
|
20
|
+
<li><a href="<%= stiki_routes.spaces_path %>">All Spaces</a></li>
|
21
|
+
<li class="divider"></li>
|
22
|
+
<%- @spaces.each do |space| %>
|
23
|
+
<li><a href="<%= stiki_routes.space_pages_path(space) %>"><%= space.name %></a></li>
|
24
|
+
<% end -%>
|
25
|
+
</ul>
|
26
|
+
</div>
|
27
|
+
</li>
|
28
|
+
<li>
|
29
|
+
<span class="divider">/</span>
|
30
|
+
</li>
|
31
|
+
<li>
|
32
|
+
<div class="btn-group">
|
33
|
+
<button class="btn dropdown-toggle" data-toggle="dropdown"><%= @page.title %> <span class="caret"></span></button>
|
34
|
+
<ul class="dropdown-menu">
|
35
|
+
<li><a href="<%= stiki_routes.space_pages_path(@space) %>">All Pages</a></li>
|
36
|
+
<li class="divider"></li>
|
37
|
+
<%- @pages.each do |page| %>
|
38
|
+
<li><a href="<%= stiki_routes.space_page_path(@space,page) %>"><%= page.title %></a></li>
|
39
|
+
<% end -%>
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
<div class="row-fluid">
|
49
|
+
<div class="span9">
|
50
|
+
<div class="row-fluid">
|
51
|
+
<div class="span12 well"><%= @markup %></div>
|
52
|
+
</div>
|
53
|
+
<div class="row-fluid">
|
54
|
+
<div class="span12 well">
|
55
|
+
<%- if has_access( :update, @page ) %>
|
56
|
+
<div class="span2">
|
57
|
+
<%= link_to 'Edit', stiki_routes.edit_space_page_path(@space,@page), :class => 'btn btn-large btn-primary' %>
|
58
|
+
</div>
|
59
|
+
<% end -%>
|
60
|
+
<%- if has_access( :delete, @page ) %>
|
61
|
+
<div class="span2 delete">
|
62
|
+
<%= button_to "Delete", stiki_routes.space_page_path( @space, @page ), :method => :delete,
|
63
|
+
:class => 'btn', :confirm => 'Are you sure you want to delete this Wiki Page?' %>
|
64
|
+
</div>
|
65
|
+
<% end -%>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
<div class="span3">
|
70
|
+
<div class="row-fluid">
|
71
|
+
<div class="span12 well">
|
72
|
+
<ul class="nav nav-list author">
|
73
|
+
<li class="nav-header">Contributors</li>
|
74
|
+
<%- @page.authors.each do |author| %>
|
75
|
+
<li>
|
76
|
+
<%= user_name( author ) %>
|
77
|
+
<%= "<span class='badge badge-success' title='Author'>A</span>".html_safe if author.creator %>
|
78
|
+
<%= "<span class='badge badge-info' title='Last Edit'>L</span>".html_safe if author.last_edit %></li>
|
79
|
+
</li>
|
80
|
+
<% end -%>
|
81
|
+
</ul>
|
82
|
+
<div>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
</div>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<%- @spaces.each do |space| %>
|
2
|
+
<div class="row-fluid">
|
3
|
+
<div class="span8">
|
4
|
+
<div class="row-fluid">
|
5
|
+
<div class="hero-unit">
|
6
|
+
<h2><%= link_to space.name, stiki_routes.space_pages_path(space) %></h2>
|
7
|
+
<h4 style="float:left">Created by <%= user_name( space.creator ) %></h4>
|
8
|
+
<%- if has_access( :update, @page ) %>
|
9
|
+
<%= button_to "X", stiki_routes.space_path( space ), :method => :delete,
|
10
|
+
:class => 'close', :confirm => 'Are you sure you want to delete this Wiki Space?' %>
|
11
|
+
<% end -%>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<% end -%>
|
17
|
+
<%- if has_access( :create, Stiki::Space ) %>
|
18
|
+
<div class="row-fluid create-space">
|
19
|
+
<div class="span8 well">
|
20
|
+
<a href="#" class="create-space-trigger">Create New Space</a>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<div class="row-fluid create-space" style="display:none">
|
24
|
+
<div class="span8">
|
25
|
+
<div class="row-fluid">
|
26
|
+
<%= form_tag( stiki_routes.spaces_path, :class => 'form-horizontal' ) do |f| %>
|
27
|
+
<fieldset class="well">
|
28
|
+
<h2>Create New Space</h2>
|
29
|
+
<div class="control-group">
|
30
|
+
<%= label_tag 'name', 'Name', :class => "control-label" %>
|
31
|
+
<div class="controls">
|
32
|
+
<input class="input-xlarge" id="name" name="space[name]" size="30" type="text">
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<div class="form-actions">
|
36
|
+
<%= submit_tag "Create", :class => "btn btn-primary btn-large" %>
|
37
|
+
<a href="#" class="create-space-trigger btn">Cancel</a>
|
38
|
+
</div>
|
39
|
+
</fieldset>
|
40
|
+
<% end -%>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<script>
|
46
|
+
$(function() {
|
47
|
+
$('.create-space-trigger').click( function() {
|
48
|
+
$('.create-space').slideToggle();
|
49
|
+
});
|
50
|
+
});
|
51
|
+
</script>
|
52
|
+
<% end -%>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'friendly_id'
|
2
|
+
|
3
|
+
Stiki::Engine.routes.draw do
|
4
|
+
|
5
|
+
resources :authors, :controller => 'stiki::authors'
|
6
|
+
|
7
|
+
resources :spaces, :controller => 'stiki::spaces' do
|
8
|
+
resources :pages, :controller => 'stiki::pages'
|
9
|
+
end
|
10
|
+
|
11
|
+
root :to => 'stiki::spaces#index'
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateStikiAuthors < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :stiki_authors do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.integer :authorable_id
|
6
|
+
t.string :authorable_type
|
7
|
+
t.boolean :creator
|
8
|
+
t.boolean :last_edit
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :stiki_authors, [:authorable_id, :authorable_type]
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'stiki'
|
2
|
+
require 'stiki/authenticate'
|
3
|
+
|
4
|
+
module Stiki::Authenticate::Devise
|
5
|
+
def self.included(base)
|
6
|
+
if Stiki.auth_mapping
|
7
|
+
auth_required = Stiki.auth_mapping[base.controller_name.to_sym]
|
8
|
+
if auth_required
|
9
|
+
if auth_required == :all
|
10
|
+
base.before_filter "authenticate_#{Stiki::Helper.user_model_name}!".to_sym
|
11
|
+
else
|
12
|
+
base.before_filter "authenticate_#{Stiki::Helper.user_model_name}!".to_sym, auth_required
|
13
|
+
end
|
14
|
+
end
|
15
|
+
else
|
16
|
+
raise "Stiki.auth_mapping was nil"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/stiki/engine.rb
ADDED
data/lib/stiki/model.rb
ADDED
data/lib/stiki.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require "stiki/engine"
|
2
|
+
require 'stiki/authenticate/devise'
|
3
|
+
require 'stiki/authorize/cancan'
|
4
|
+
require 'stiki/model/map_author'
|
5
|
+
|
6
|
+
module Stiki
|
7
|
+
|
8
|
+
mattr_accessor :user_class
|
9
|
+
mattr_accessor :user_name_via
|
10
|
+
mattr_accessor :authenticate_by
|
11
|
+
mattr_accessor :authenticate_pages
|
12
|
+
mattr_accessor :authenticate_spaces
|
13
|
+
mattr_accessor :auth_mapping
|
14
|
+
|
15
|
+
mattr_accessor :authorize_by
|
16
|
+
|
17
|
+
def self.reload
|
18
|
+
config( &@@config_blk ) if @@config_blk
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.config(&blk)
|
22
|
+
@@config_blk = blk
|
23
|
+
|
24
|
+
yield self
|
25
|
+
|
26
|
+
if user_class
|
27
|
+
unless @@user_name_via.nil?
|
28
|
+
@@user_name_via = @@user_name_via.to_sym
|
29
|
+
else
|
30
|
+
@@user_name_via = :to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
::Stiki::Author.send(:include, Stiki::Model::MapAuthor)
|
34
|
+
end
|
35
|
+
|
36
|
+
if authenticate_by
|
37
|
+
|
38
|
+
if authenticate_by.to_sym == :devise
|
39
|
+
|
40
|
+
if user_class.nil?
|
41
|
+
raise "Stiki.user_class is required for devise auth"
|
42
|
+
end
|
43
|
+
|
44
|
+
@@authenticate_pagess = {:only => [:new, :create, :edit, :update]} if @@authenticate_pages.nil?
|
45
|
+
@@authenticate_spaces = {:only => [:new, :create, :edit, :update]} if @@authenticate_spaces.nil?
|
46
|
+
|
47
|
+
@@auth_mapping = { :pages => @@authenticate_pages, :spaces => @@authenticate_spaces }
|
48
|
+
|
49
|
+
::Stiki::SpacesController.send(:include, Stiki::Authenticate::Devise )
|
50
|
+
|
51
|
+
::Stiki::PagesController.send( :include, Stiki::Authenticate::Devise )
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
if authorize_by
|
57
|
+
if authorize_by.to_sym == :cancan
|
58
|
+
::Stiki::SpacesController.send(:include, Stiki::Authorize::Cancan )
|
59
|
+
|
60
|
+
::Stiki::PagesController.send( :include, Stiki::Authorize::Cancan )
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module Helper
|
66
|
+
def self.user_model_name
|
67
|
+
Stiki.user_class.constantize.name.underscore
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stiki/pages_controller'
|
3
|
+
|
4
|
+
describe Stiki::PagesController do
|
5
|
+
|
6
|
+
before do
|
7
|
+
Stiki.config do |stiki|
|
8
|
+
stiki.user_class = 'Author'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have before_filters" do
|
13
|
+
Stiki::PagesController.filters[:before].should include(:get_space);
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "GET #index" do
|
17
|
+
before do
|
18
|
+
@space = FactoryGirl.create(:space)
|
19
|
+
get :index, :space_id => @space.slug, :use_route => :stiki
|
20
|
+
end
|
21
|
+
|
22
|
+
it { response.should be_success }
|
23
|
+
it { should assign_to(:space) }
|
24
|
+
it { should assign_to(:pages) }
|
25
|
+
it { should render_template('stiki/pages/index') }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "GET #show" do
|
29
|
+
before do
|
30
|
+
@page = FactoryGirl.create(:page)
|
31
|
+
@space = @page.space
|
32
|
+
get :show, :space_id => @space.slug, :id => @page.slug, :use_route => :stiki
|
33
|
+
end
|
34
|
+
|
35
|
+
it { should_not set_the_flash }
|
36
|
+
it { response.should be_success }
|
37
|
+
it { should assign_to(:space) }
|
38
|
+
it { should assign_to(:page) }
|
39
|
+
it { should assign_to(:markup) }
|
40
|
+
it { should render_template('stiki/pages/show') }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "GET #new" do
|
44
|
+
before do
|
45
|
+
@space = FactoryGirl.create(:space)
|
46
|
+
get :new, :space_id => @space.slug, :use_route => :stiki
|
47
|
+
end
|
48
|
+
|
49
|
+
it { should_not set_the_flash }
|
50
|
+
it { response.should be_success }
|
51
|
+
it { should assign_to(:space) }
|
52
|
+
it { should assign_to(:page) }
|
53
|
+
it { should render_template('stiki/pages/new') }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "GET #create" do
|
57
|
+
context "success" do
|
58
|
+
before do
|
59
|
+
@space = FactoryGirl.create(:space)
|
60
|
+
post :create, :space_id => @space.slug, :page => { :title => 'title123', :body => 'body123' }, :use_route => :stiki
|
61
|
+
end
|
62
|
+
|
63
|
+
it { response.should be_redirect }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "error" do
|
67
|
+
before do
|
68
|
+
@space = FactoryGirl.create(:space)
|
69
|
+
post :create, :space_id => @space.slug, :use_route => :stiki
|
70
|
+
end
|
71
|
+
|
72
|
+
it { response.should be_success }
|
73
|
+
it { should assign_to(:space) }
|
74
|
+
it { should assign_to(:page) }
|
75
|
+
it { should render_template('stiki/pages/new') }
|
76
|
+
it "should not be a valid page" do
|
77
|
+
assigns(:page).should_not be_valid
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stiki/spaces_controller'
|
3
|
+
|
4
|
+
describe Stiki::SpacesController do
|
5
|
+
|
6
|
+
describe "GET #index" do
|
7
|
+
before do
|
8
|
+
@space1 = FactoryGirl.create(:space)
|
9
|
+
@space2 = FactoryGirl.create(:space)
|
10
|
+
@space3 = FactoryGirl.create(:space)
|
11
|
+
|
12
|
+
get :index, :use_route => :stiki
|
13
|
+
end
|
14
|
+
|
15
|
+
it { response.should be_success }
|
16
|
+
it { should assign_to(:spaces) }
|
17
|
+
it { assigns(:spaces).size.should eql 3 }
|
18
|
+
it { should render_template('stiki/spaces/index') }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "GET #create" do
|
22
|
+
context "success" do
|
23
|
+
before do
|
24
|
+
expect {
|
25
|
+
post :create, :space => { :name => 'name123' }, :use_route => :stiki
|
26
|
+
}.to change{ Stiki::Space.count }.by(1)
|
27
|
+
end
|
28
|
+
|
29
|
+
it { response.should be_redirect }
|
30
|
+
end
|
31
|
+
|
32
|
+
context "error" do
|
33
|
+
before do
|
34
|
+
expect {
|
35
|
+
post :create, :use_route => :stiki
|
36
|
+
}.to change{ Stiki::Space.count }.by(0)
|
37
|
+
end
|
38
|
+
|
39
|
+
it { response.should be_redirect }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stiki/authenticate/devise'
|
3
|
+
|
4
|
+
describe Stiki::Authenticate::Devise do
|
5
|
+
|
6
|
+
describe "include in Controllers" do
|
7
|
+
before do
|
8
|
+
Stiki.config do |stiki|
|
9
|
+
stiki.authenticate_by = :devise
|
10
|
+
stiki.user_class = 'Author'
|
11
|
+
stiki.authenticate_pages = :all
|
12
|
+
stiki.authenticate_spaces = [:new, :create, :edit, :update]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set before_filter in PagesController" do
|
17
|
+
Stiki::PagesController.filters[:before].should include( :authenticate_author! )
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should set before_filter in SpacesController" do
|
21
|
+
Stiki::SpacesController.filters[:before].should include( :authenticate_author! )
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|