Skip to content

Commit

Permalink
Fixes most specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
kulesa committed Aug 16, 2013
1 parent 841ab74 commit aca8552
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 218 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
26 changes: 15 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
source 'http://rubygems.org'
source 'http://gems.github.com'
## -----------------------------------
## Uncomment content of this Gemfile
## only if you need to run plugin specs.
## -----------------------------------

group :test do
gem 'rake'
gem 'sqlite3'
gem 'rspec', "~> 2.10.0"
gem 'rspec-rails', "~> 2.10.0"
gem 'factory_girl', "~>3.5.0"
gem 'database_cleaner'
gem 'RedCloth'
end
#redmine_root = ENV["REDMINE_ROOT"] || File.dirname(__FILE__) + "/../../"
#eval File.read File.expand_path(redmine_root + 'Gemfile', __FILE__)

#group :test do
#gem 'rspec', "~> 2.14.0"
#gem 'rspec-rails', "~> 2.14.0"
#gem 'factory_girl', "~> 2.3.2"
#gem 'database_cleaner'
#gem 'mysql2'
#gem 'pry'
#end
76 changes: 0 additions & 76 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,83 +1,7 @@
GEM
remote: http://rubygems.org/
remote: http://gems.github.com/
specs:
RedCloth (4.2.9)
actionpack (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
builder (3.0.0)
database_cleaner (0.6.7)
diff-lcs (1.1.3)
erubis (2.7.0)
factory_girl (3.5.0)
activesupport (>= 3.0.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
json (1.7.3)
multi_json (1.3.6)
mysql2 (0.3.11)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
railties (3.2.6)
actionpack (= 3.2.6)
activesupport (= 3.2.6)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.10.0)
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
rspec-rails (2.10.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.10.0)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.4)
thor (0.15.4)
tilt (1.3.3)

PLATFORMS
ruby

DEPENDENCIES
RedCloth (~> 4.2.9)
database_cleaner
factory_girl (~> 3.5.0)
mysql2
rake
rspec (~> 2.10.0)
rspec-rails (~> 2.10.0)
sqlite3
9 changes: 8 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The plugin improves functionality of Redmine Gantt Chart.

== Compatibility

Tested with Redmine versions: 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.2, 1.3, 1.4
Tested with Redmine versions: 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.2, 1.3, 1.4, 2.1, 2.2, 2.3

== Installation and Setup

Expand Down Expand Up @@ -60,6 +60,13 @@ New setting *Work on weekends* introduced in v.0.6.
If you notice any problems, please report them to the GitHub issue tracker {here}[https://github.com/kulesa/redmine_better_gantt_chart/issues]. Feel free to contact me via GitHub or Twitter
or whatever with any other questions or feature requests. To submit changes fork the project and send a pull request.

=== Running specs

To run specs,

- go to the plugin folder, uncomment content of Gemfile, run `bundle`
- run `bundle exec rspec`.

== Contributors

Thanks to Jeremy Subtil ({BigMadWolf}[https://github.com/BigMadWolf]) for contributing a patch for displaying connections between cross-project related issues.
Expand Down
4 changes: 2 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
name 'Redmine Better Gantt Chart plugin'
author 'Alexey Kuleshov'
description 'This plugin improves Redmine Gantt Chart'
version '0.7.0'
version '0.9.0'
url 'https://github.com/kulesa/redmine_better_gantt_chart'
author_url 'http://github.com/kulesa'

requires_redmine :version_or_higher => '1.1.0'

settings(:default => {
Expand Down
69 changes: 39 additions & 30 deletions spec/controllers/gantts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,88 @@

describe GanttsController, '#show' do
include Redmine::I18n
integrate_views
before(:all) do
render_views

before(:all) do
# Precedes - Follows
@preceding_issue, @following_issue = create_related_issues("precedes")

# Blocks - Blocked
@blocks_issue, @blocked_issue = create_related_issues("blocks")

# Duplicates - Duplicated
@duplicates_issue, @duplicated_issue = create_related_issues("duplicates")

# Relates
@one_issue, @other_issue = create_related_issues("relates")
end

before(:each) do
@current_user = mock_model(User, :admin? => true, :logged? => true, :language => :en, :active? => true, :memberships => [], :anonymous? => false, :name => "A Test >User", :projects => Project)
User.stub!(:current).and_return(@current_user)
@current_user.stub!(:allowed_to?).and_return(true)
@current_user.stub!(:pref).and_return(Factory(:user_preference, :user_id => @current_user.id))
@current_user = mock_model(User, :admin? => true,
:logged? => true,
:language => :en,
:active? => true,
:memberships => [],
:anonymous? => false,
:name => "A Test >User",
:projects => Project,
:groups => [],
:css_classes => 'user_active')
User.stub(:current).and_return(@current_user)
@current_user.stub(:allowed_to?).and_return(true)
@current_user.stub(:pref).and_return(Factory(:user_preference, :user_id => @current_user.id))
end

it 'should be successful' do
get :show
response.should be_success
response.status.should == 200
end

it 'should have custom javascripts included' do
it 'should have custom javascripts included' do
get :show
response.should have_text(/raphael.min.js/)
response.should have_text(/raphael.arrow.js/)
response.body.should have_text(/raphael.min.js/)
response.body.should have_text(/raphael.arrow.js/)
end

it 'should insert issue ids and follow tags' do
get :show
response.should have_text(/div id='#{@preceding_issue.id}'/)
response.should have_text(/div id='#{@following_issue.id}' follows='#{@preceding_issue.id}'/)
response.body.should have_text(/div id='#{@preceding_issue.id}'/)
response.body.should have_text(/div id='#{@following_issue.id}' follows='#{@preceding_issue.id}'/)
end

it 'should insert blocked tags' do
get :show
response.should have_text(/div id='#{@blocks_issue.id}'/)
response.should have_text(/div id='#{@blocked_issue.id}' blocked='#{@blocks_issue.id}'/)
response.body.should have_text(/div id='#{@blocks_issue.id}'/)
response.body.should have_text(/div id='#{@blocked_issue.id}' blocked='#{@blocks_issue.id}'/)
end

it 'should insert duplicated tags' do
get :show
response.should have_text(/div id='#{@duplicates_issue.id}'/)
response.should have_text(/div id='#{@duplicated_issue.id}' duplicated='#{@duplicates_issue.id}'/)
response.body.should have_text(/div id='#{@duplicates_issue.id}'/)
response.body.should have_text(/div id='#{@duplicated_issue.id}' duplicated='#{@duplicates_issue.id}'/)
end

it 'should insert relates tags' do
get :show
response.should have_text(/div id='#{@one_issue.id}'/)
response.should have_text(/div id='#{@other_issue.id}' relates='#{@one_issue.id}'/)
response.body.should have_text(/div id='#{@one_issue.id}'/)
response.body.should have_text(/div id='#{@other_issue.id}' relates='#{@one_issue.id}'/)
end

it 'should insert an array of ids to a tag' do
@blocks_issue.relations << IssueRelation.create!(:issue_from => @blocks_issue, :issue_to => @duplicated_issue, :relation_type => "duplicates", :delay => 0)
@blocks_issue.save!

get :show
response.should have_text(/duplicated='#{@duplicates_issue.id},#{@blocks_issue.id}'/)
response.body.should have_text(/duplicated='#{@duplicates_issue.id},#{@blocks_issue.id}'/)
end

it 'should mix different relation types' do
it 'should mix different relation types' do
@blocks_issue.relations << IssueRelation.create!(:issue_from => @blocks_issue, :issue_to => @duplicated_issue, :relation_type => "duplicates", :delay => 0)
@blocks_issue.save!
@one_issue.relations << IssueRelation.create!(:issue_from => @one_issue, :issue_to => @duplicated_issue, :relation_type => "relates")
@one_issue.save!

get :show
response.should have_text(/duplicated='#{@duplicates_issue.id},#{@blocks_issue.id}' relates='#{@one_issue.id}'|relates='#{@one_issue.id}' duplicated='#{@duplicates_issue.id},#{@blocks_issue.id}'/)
response.body.should have_text(/duplicated='#{@duplicates_issue.id},#{@blocks_issue.id}' relates='#{@one_issue.id}'|relates='#{@one_issue.id}' duplicated='#{@duplicates_issue.id},#{@blocks_issue.id}'/)
end
end
11 changes: 5 additions & 6 deletions spec/controllers/issues_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

describe IssuesController do
include Redmine::I18n
integrate_views
render_views

before(:each) do
@current_user = Factory :user
#@current_user = mock_model(User, :admin? => true, :logged? => true, :language => :en, :active? => true, :memberships => [], :anonymous? => false, :name => "A Test >User", :projects => Project)
User.stub!(:current).and_return(@current_user)
@current_user.stub!(:allowed_to?).and_return(true)
@current_user.stub!(:pref).and_return(Factory(:user_preference, :user_id => @current_user.id))
@current_user.stub!(:mail)
User.stub(:current).and_return(@current_user)
@current_user.stub(:allowed_to?).and_return(true)
@current_user.stub(:pref).and_return(Factory(:user_preference, :user_id => @current_user.id))
@current_user.stub(:mail)
end

let!(:issue) { Factory(:issue) }
Expand Down
Loading

0 comments on commit aca8552

Please sign in to comment.